Details
-
Type:
New Feature
-
Status:
Reopened
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.1.2
-
Fix Version/s: 2.0.1
-
Component/s: Whiteboard Extender
-
Labels:
-
Environment:All
Description
I try to use and share the same HttpContext between multiple Bundles. I have multiple HttpServlet and Filer to register with the same HttpContext. I use the org.ops4j.pax.web.service.WebContainer to register the filter. This class has the getDefaultSharedHttpContext method which is "package private" but the implementation is public. This is one of the issues but I find a workaround.
Now I have the org.ops4j.pax.web.service.internal.HttpServiceStarted#getOrCreateContext(HttpContext) where it's:
m_serverModel.associateHttpContext(context, m_bundle,
httpContext instanceof SharedWebContainerContext);
In the
org.ops4j.pax.web.service.spi.model.ServerModel
public void associateHttpContext( final HttpContext httpContext,
final Bundle bundle,
final boolean allowReAsssociation )
{
final Bundle currentBundle = m_httpContexts.putIfAbsent( httpContext, bundle );
if( ( !!allowReAsssociation ) && currentBundle != null && currentBundle != bundle )
}
I think the "!!allowReAsssociation" is a typo error and it should be !allowReAsssociation
How can I runtime register/remove Filer and Servlet but keep the same HttpServiceContext?
org.eclipse.jetty.server.handler.HandlerCollection#_handlers has my org.ops4j.pax.web.service.jetty.internal.HttpServiceContext but the ServletHandler _servletHandler filed has always new instance. If I register the Servlet the new HttpServiceServletHandler instance has no _filerMappings. If I register the filter afterward a new HttpServiceServletHandler instance has no servletNameMap.
How should I do this properly? I try to debug but I'd appreciate any help.

so you are trying to register multiple servlets and filters to a common httpContext? why don't you use the whiteboard extender then?
I think it's much easier to use.