Allow to configure if createDefaultHttpContext returns shared or non-shared context

Description

We would need the possibility to configure, if createDefaultHttpContext returns shared or non-shared http context.

Currently, an instance of DefaultHttpContext is returned, where one of the keys is the bundle context. Therefore, in the case of system I currently work on, JAX-RS Provider receives HttpContext with JAX-RS bundle id, and I'm unable to register HttpSessionListener in that context from another bundle.

When using the Equinox implementation (org.eclipse.equinox.http.servlet) I can get org.eclipse.jetty.server.Server instance where I can register HttpSessionListener that will work in global context (so for the sessions created by JAX-RS in particular). I was enable to find similar way in pax-web. When I use WebContainer.registerEventListener, my listener is not notified for sessions created by JAX-RS, because I'm unable to get the HttpContext that JAX-RS bundle is using.

If I was able to change how createDefaultHttpContext would work, we would have the same context.

The method would change from :

1 2 3 4 5 @Override public WebContainerContext createDefaultHttpContext() { return new DefaultHttpContext(serviceBundle, WebContainerContext.DefaultContextIds.DEFAULT.getValue()); }

to :

1 2 3 4 5 6 7 8 9 @Override public WebContainerContext createDefaultHttpContext() { if (isUseSharedContextByDefault()) { return createDefaultSharedHttpContext(); } else { return createDefaultHttpContext( WebContainerContext.DefaultContextIds.DEFAULT.getValue()); } }

Am I overseeing some reason, why the given solution would not work, or not give me the functionality or need, or is otherwise unappropriate?

Or there is already some (even hacky) solution to register global session listener that would be used by all contextes?

Environment

None

Status

Assignee

Unassigned

Reporter

LukaszL

Labels

None

Components

Fix versions

Affects versions

future

Priority

Major
Configure