Hi Juanjo,

Juan José Vázquez Delgado schrieb:
> Hi Felix,
> 
> 
>>  The implementation on the Sling or OSGi side, though, is currently
>> missing. One thing is, that such a thing is not part of the OSGi
>> HttpService specification (which is based on the Servlet API 2.1). The
>> other missing thing is support by Sling itself.
>>
> 
> Yes I know, Although, I have had a look at PAX Web HTTP Service Extensions
> [1]  and it seems to solve this issue. Anyway, I don´t know how can I make
> this thing work with Servlets deployed to Sling...

Maybe a listener -- say ServletListenerHelper -- could be added in Sling
which listens for the various Servlet API EventListeners registered as
OSGi services. Upon registration of such listeners, the
ServletListenerHelper would call into the registerEventListener of the
PAX WebContainer. Upon unregistration, the unregisterEventListener would
be called.

This could be implemented in its own bundle and would just require the
PAX Web Extender to be installed into the framework.

> 
> 
>> For plain Sling applications, I would think, that SlingServletContext
>> and SlingMainServlet would be extended to support such a
>> ServletContextAttributeListener functionality.
>>
>> For example:
>>
>>  * SlingMainServlet would act as a proxy providing the attributeAdded,
>>        attributeRemoved and attributeReplaced methods
>>  * SlingMainServlet would dispatch the method calls to registered
>>        services.
>>  * SlingServletContext would call the respective methods of the
>>        SlingMainServlet to dispatch the events
>>
>> WDYT ? Does this sound reasonable ?
>>
> 
> Yep, this sounds good. However, I´m not sure if this is a must have for the
> Sling core development.

Given the PAX Web Extender, this does not require changes to Sling core,
but it might be an addition to Sling, say an extension. Hint, Hint ;-)

> 
> Now, I´m working in a Bayeux (comet) [2] server layer over Sling. My first
> attempt has been re-use the cometd-jetty project [3] and to develope a
> Servlet extending SuspendingCometdServlet. If you see the cometd-jetty demo
> [4], the bayeux object is initialized and set as a context attribute. Thanks
> to a ServletContextAttributeListener [5], the bayeux services are
> initialized. Therefore, i wondered about servlet listener support in Sling.
> 

Given the ServletListenerHelper above, this could help with PAX Wenb
Extender, I suppose.

> Maybe you can help me with my use case in other way.

One point comes to mind: If we are referring to the Standalone Sling
Launcher, which includes PAX Web Server, everything is fine. A different
issue occurrs in case the SLing Web App is used inside another servlet
container.

In this case, I would suspect to register a SerlvetListerProxy to the
servlet container which forwards any events to registered Servlet API
Listener services. Such a proxy would be registered through the Sling
Web App's web.xml and would know the OSGi container to access the services.

The ultimate goal is, that Servlet API listeners may just register
themselves as OSGi services and from then on be fed with the respective
events.

WDYT ?

Regards
Felix

> 
> Thanks in advance,
> 
> BR,
> 
> Juanjo.
> 
> [1]
> http://wiki.ops4j.org/confluence/display/ops4j/Pax+Web+-+Http+Service+Extensions
> [2] http://cometdproject.dojotoolkit.org/
> [3] http://repo1.maven.org/maven2/org/mortbay/jetty/cometd-jetty/
> [4]
> http://svn.codehaus.org/jetty-contrib/branches/jetty-6.1.x/contrib/cometd/demo/
> [5]
> http://svn.codehaus.org/jetty-contrib/branches/jetty-6.1.x/contrib/cometd/demo/src/main/java/org/cometd/demo/BayeuxServicesListener.java
> 

Reply via email to