Make it easier to control the HttpContext of servlets registered on the whiteboard


When registering servlets on the whiteboard, pax-web-whiteboard-extender will pick it up and make it available on Jetty. This is described in I believe the way-of-least-surprise would be this

  1. If the bundle registering the servlet is a WAB (i.e. it exposes a service of type org.ops4j.pax.web.service.WebAppDependencyHolder), then associate the servlet with the HttpContext that already exists for the bundle

  2. If the bundle is not a WAB, create a new HttpContext and associate the servlet with this context (unless ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID is defined of course).

Point 2. is the implementation for all servlets today. This has several drawbacks

  • Any security constraints or other configuration in web.xml for the WAB will not be applied to the servlet

  • Any configuration in jetty-web.xml for the WAB will not be applied to the servlet

Todays impementation assumes use of ExtenderConstants.PROPERTY_HTTP_CONTEXT_ID in order to associate a servlet with a HttpContext. This is fine and well, but the HttpContext registered by pax-web for the WAB doesn't have a context id, thus making it impossible to associate a servlet with it.

Proposed changes

  1. Make it possible to associate servlets with the HttpContext already created for a WAB through the context id. Maybe by registering the context as a service with that property on the bundle?

  2. Introduce the default behaviour described above where servlets are default associated with existing HttpContexts for WABs






Jostein Gogstad




Fix versions

Affects versions