Interface HttpServiceExtension
- All Superinterfaces:
org.osgi.service.http.HttpService
- All Known Implementing Classes:
HttpServiceImpl
public interface HttpServiceExtension
extends org.osgi.service.http.HttpService
An extension to the OSGi
HttpService interface allowing the
registration/unregistration of Servlet Filter instances.- Since:
- 2.3.3
-
Method Summary
Modifier and TypeMethodDescriptionvoidregisterFilter(javax.servlet.Filter filter, String urlPattern, Dictionary initParams, org.osgi.service.http.HttpContext context) Registers aFilterand with theHttpService.voidunregisterFilter(javax.servlet.Filter filter) Removes the specifiedFilterfrom the service.Methods inherited from interface org.osgi.service.http.HttpService
createDefaultHttpContext, registerResources, registerServlet, unregister
-
Method Details
-
registerFilter
void registerFilter(javax.servlet.Filter filter, String urlPattern, Dictionary initParams, org.osgi.service.http.HttpContext context) throws javax.servlet.ServletException Registers aFilterand with theHttpService. As this is an extension to the standardHttpServiceand there are no clear rules on how the mapping of filters should occur, this implementation follows the mapping rules as defined by the Servlet specification. Additionally, it should be noted that the registeredFilters are effectively associated with a particularHttpContext. Therefore, if you wish to have multiple filters associated with a particularServlet, then you should use the sameHttpContextinstance to perform the registration.Filters will be invoked in registration order. This method will invokeFilter.init(javax.servlet.FilterConfig)during the registration process. When registering aFilter, take care not to reuse the same Filter instance across multiple registration invocations. This could cause issues when removing the Filter as it may remove more url matching possibilities than intended.- Parameters:
filter- theFilterto register.urlPattern- the url pattern that will invoke thisFilter.initParams- the initialization params that will be passed to the filter whenFilter.init(javax.servlet.FilterConfig)is invoked.context- theHttpContextassociated with thisFilter.- Throws:
javax.servlet.ServletException- if an error occurs duringFilterinitialization.
-
unregisterFilter
void unregisterFilter(javax.servlet.Filter filter) Removes the specifiedFilterfrom the service.- Parameters:
filter- theFilterto remove.
-