Hello, I hope this group is appropriate for asking this question, if not, my apologize and please suggest if there is appropriate place to ask.
I've submitted the issue https://ops4j1.jira.com/browse/PAXWEB-1105 because I need to register session listener for WebServices created by JaxrsPublisher. I've added parameter doing what is described in the issue, and after deploying and modifying configuration file, the shared http context instance is returned upon createDefaultHttpContext() call. (I've included the git diff of changes I've made locally). 2 bundles: jaxrs publisher and my session listener registrator are connected to http service: 2017-06-30T10:46:18,768 | INFO | pool-3-thread-1 | HttpServiceFactoryImpl | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Binding bundle: [com.eclipsesource.jaxrs.publisher [14]] to http service 2017-06-30T10:46:20,644 | INFO | pool-3-thread-1 | HttpServiceFactoryImpl | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Binding bundle: [pax-web-configurator [204]] to http service Jaxrs publisher registers servlet: 2017-06-30T10:46:20,010 | INFO | pool-3-thread-1 | HttpServiceStarted | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Register servlet (alias=/services). Using context [ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-5,name=,httpContext=org.ops4j.pax.web.service.internal.DefaultSharedWebContainerContext@f7bb2fe,contextParams={},virtualHosts={},connectors={}}] My stuff registers session listener and session attribute listener: 2017-06-30T10:46:20,645 | INFO | pool-3-thread-1 | HttpServiceStarted | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Register event listener (listener=com.riag.taxcloud.datamodel.channel.DatamodelSessionListener@18b607f1). Using context [ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-11,name=,httpContext=org.ops4j.pax.web.service.internal.DefaultSharedWebContainerContext@4f5b090a,contextParams={},virtualHosts={},connectors={}}] 2017-06-30T10:46:20,655 | INFO | pool-3-thread-1 | HttpServiceStarted | 199 - org.ops4j.pax.web.pax-web-runtime - 6.1.0.SNAPSHOT | Register event listener (listener=com.riag.taxcloud.datamodel.channel.DatamodelSessionAttributeListener@7e902b64). Using context [ContextModel{id=org.ops4j.pax.web.service.spi.model.ContextModel-13,name=,httpContext=org.ops4j.pax.web.service.internal.DefaultSharedWebContainerContext@56ba6785,contextParams={},virtualHosts={},connectors={}}] This is how I register/unregister listeners: public void bindSessionListener(HttpSessionListener listener) { LOGGER.info("bindSessionListener {}", listener); webContainer.registerEventListener(listener, null); //servletContext.addListener(listener); IllegalStateException } public void unbindSessionListener(HttpSessionListener listener) { LOGGER.info("unbindSessionListener {}", listener); if (listener == null) return; webContainer.unregisterEventListener(listener); } public void bindSessionAttributeListener(HttpSessionAttributeListener listener) { LOGGER.info("bindSessionAttributeListener {}", listener); webContainer.registerEventListener(listener, null); // servletContext.addListener(listener); IllegalStateException } public void unbindSessionAttributeListener(HttpSessionAttributeListener listener) { LOGGER.info("unbindSessionAttributeListener {}", listener); if (listener == null) return; webContainer.unregisterEventListener(listener); } <?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"> <bean id="paxWebConfigurator" class="com.riag.taxcloud.paxweb.configurator.PaxWebSessionConfigurator"> <property name="context" ref="blueprintBundleContext" /> <property name="webContainer" ref="webContainer"/> <property name="servletConfiguration" ref="jaxRsServletConfiguration"/> <property name="servletContext" ref="jaxbServletContext"/> </bean> <reference id="webContainer" interface="org.ops4j.pax.web.service.WebContainer"/> <reference-list id="sessionListeners" interface="javax.servlet.http.HttpSessionListener" availability="optional"> <reference-listener bind-method="bindSessionListener" unbind-method="unbindSessionListener" ref="paxWebConfigurator" /> </reference-list> <reference-list id="sessionAttributeListeners" interface="javax.servlet.http.HttpSessionAttributeListener" availability="optional"> <reference-listener bind-method="bindSessionAttributeListener" unbind-method="unbindSessionAttributeListener" ref="paxWebConfigurator" /> </reference-list> </blueprint> However, the session listener is not called when new session is created by WebService call. I've set a breakpoint within org.eclipse.jetty.server.session.AbstractSessionManager.addSession(AbstractSession, boolean) and _sessionListeners list is empty. Do I get something conceptually wrong? I thought that if both bundles will register stuff using the same HttpContext, one of them could register listener that would listen to events for servlets created by the second one. Is the concept of bundles working with different HttpContext somehow deeply build-in in pax-web so I can't change that behavior with such simple 'hack'? Anyway, my patch (after cleanup - I've increased log level to see what happens and commented out the baselining so that I'm able to compile with maven) seems to solve the JIRA issue. However I'm not sure if the JIRA issue solves any issue, or I lack understanding the concept of 'shared' and 'non-shared' HttpContext in pax-web.... Best regards, Lukasz Lech -- -- ------------------ OPS4J - http://www.ops4j.org - [email protected] --- You received this message because you are subscribed to the Google Groups "OPS4J" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
PAXWEB-1105.diff
Description: PAXWEB-1105.diff
