Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Deploy org.apache.felix.http.proxy jar file inside the web applicaiton (WEB-INF/lib).
  • In a startup listener (like ServletContextListener) set the BundleContext as a servlet context attribute (see example).
  • Define org.apache.felix.http.proxy.ProxyServlet inside your web.xml and register it to serve on all requests /* (see example).
  • Define org.apache.felix.http.proxy.ProxyListener as a <listener> in your web.xml to allow HTTP Session related events to be forwarded (see the section of Servlet API Event forwarding below and example).
  • Be sure to add javax.servlet;javax.servlet.http;version=2.5 to OSGi system packages ((org.osgi.framework.system.packages).
  • Deploy org.apache.felix.http.bridge (or org.apache.felix.http.bundle) inside the OSGi framework.

...

  • org.apache.felix.http.jettyEnabled - True to enable jetty as the http container. The default is false.
  • org.apache.felix.http.whiteboardEnabled - True to enable the whiteboard implementation. The default is false.

Servlet API Events

The Servlet API defines a number of EventListener interfaces to catch Servlet API related events. As of HTTP Service 2.1.0 most events generated by the servlet container are forwarded to interested service. To be registered to receive events services must be registered with the respective EventListener interface:

Interface

Description

javax.servlet.ServletContextAttributeListener

Events on servlet context attribute addition, change and removal.

javax.servlet.ServletRequestAttributeListener

Events on request attribute addition, change and removal.

javax.servlet.ServletRequestListener

Events on request start and end.

javax.servlet.http.HttpSessionAttributeListener

Events on session attribute addition, change and removal. To receive such events in a bridged environment, the ProxyLister must be registered with the servlet container. See the Using the Servlet Bridge section above.

javax.servlet.http.HttpSessionListener

Events on session creation and destroyal. To receive such events in a bridged environment, the ProxyLister must be registered with the servlet container. See the Using the Servlet Bridge section above.

Of the defined EventListener interfaces in the Servlet API, the javax.servlet.ServletContextListener events are actually not support. For one thing they do not make much sense in an OSGi environment. On the other hand they are hard to capture and propagate. For example in a bridged environment the contextInitialized event may be sent before the framework and any of the contained bundles are actually ready to act. Likewise the contextDestroyed event may come to late.

Examples

A set of simple examples illustrating the various features are available.

...