Hi,

Ian Boston schrieb:
> You can make a filter available to a servlet managed by the
> MainSlingServlet, by creating a declarative service implementing the
> java.servlet.Filter Interface.

Basically, you register an OSGi service for the javax.servlet.Filter
interface. You do not need to use declarative services.

> 
> eg
> 
> RequestProgressTrackerLogFilter
> 
> Unfortunately OSGi and the Main Sling Servlet do not directly support
> <init-param> so or web.xml, you have several options.

Actually, the Sling Main Servlet initializes servlets and filters by
calling the respective init(ServletConfig) and init(FilterConfig) methods.

The parameters provided by the ServletConfig and/or FilterConfig (the
traditional init-param settings) are taken from the OSGi service
registration properties.

This is actually quite interesting: For example by using declarative
services you may have OSGi Configuration (from ConfigurationAdmin) added
as service registration properties and thus as ServletConfig or
FilterConfig parameters. This means you will have live-configuration
support for such parameters !

Regards
Felix

> 
> provide an activate(ComponentContext context) in the servlet and it will
> be invoked when the component starts, at which point you could get hold
> of the OSGi configuration and create a fake context to initialize the
> filter.
> 
> -------------------
> 
> If your servlet are not loaded by the MainSlingServlet then you can
> always implement your own version of the same and get it to invoke your
> filters manually, or possibly use the PAX Web Extender which does
> understand web.xml (however I don't know if that is compatible with Sling).
> 
> HTH
> Ian
> 
> On 8 Jun 2009, at 19:23, Christian Sprecher wrote:
> 
>> Hi all
>>
>> In order to make a servlet filter available to sling, how are the the
>> <init-param> made available to the servlet filter? Those parameters
>> are usually defined in web.xml
>>
>> Thx in advance
> 
> 

Reply via email to