Hello,
I tried to hook a servletContextListener to my custom ServletContextHelper
but the contextInitialized method is not called.
-------------------Here is my ServletContextHelper:------------
@Component(
service = ServletContextHelper.class,
property = {
"osgi.http.whiteboard.context.name=ZkComponentsServletContextHelper",
"osgi.http.whiteboard.context.path=/components"
}
)
public class ZkComponentsServletContextHelper extends ServletContextHelper
{...}
--------------------------------My ServletContextListener----------
@Component(
name="ZkListener",
service= {
ServletContextListener.class
},
property= {
"osgi.http.whiteboard.listener=true",
"osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=ZkComponentsServletContextHelper)"
}
)
public final class ZkSessionListener implements ServletContextListener {
private WebManager webManager;
@Override
public void contextInitialized(ServletContextEvent sce) {
final ServletContext ctx = sce.getServletContext();
if (WebManager.getWebManagerIfAny(ctx) == null) {
webManager = new WebManager(ctx, "/zkau");
} else {
throw new IllegalStateException("ZK WebManager already exists. Could not
initialize via Spring Boot configuration.");
}
}
------------------------------Finally, my simple servlet-------------
@Component(
service = Servlet.class,
property= {
"osgi.http.whiteboard.servlet.pattern=*.zul",
"osgi.http.whiteboard.servlet.pattern=*.zhtml",
"osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=ZkComponentsServletContextHelper)"
}
)
public class ZulExtensionServlet extends HttpServlet{..}
---------------------equinox bundle info-------------
{org.osgi.service.http.context.ServletContextHelper}={service.id=95,
osgi.http.whiteboard.context.name=ZkComponentsServletContextHelper,
service.bundleid=59, service.scope=bundle,
component.name=com.castortech.iris.zk.components.ZkComponentsServletContextHelper,
osgi.http.whiteboard.context.path=/components, component.id=3}
{javax.servlet.Servlet}={service.id=97, service.bundleid=59,
service.scope=bundle, osgi.http.whiteboard.servlet.pattern=[*.zul,*.zhtml],
osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=ZkComponentsServletContextHelper),
component.name=com.castortech.iris.zk.components.ZulExtensionServlet,
component.id=5}
{javax.servlet.ServletContextListener}={service.id=98, service.bundleid=59,
service.scope=bundle,
osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=ZkComponentsServletContextHelper),
osgi.http.whiteboard.listener=true, component.name=ZkListener,
component.id=6}
{javax.servlet.ServletContext}={osgi.web.version=1.0.0.qualifier,
osgi.web.contextpath=/components, service.id=124,
osgi.web.symbolicname=com.castortech.iris.zk.components,
service.bundleid=59, service.scope=singleton,
osgi.web.contextname=ZkComponentsServletContextHelper}
As you can see, both the ServletContextListener and the servlet are bound
to the same ServletContextHelper and there is a ServletContext created from
the ServletContextHelper, however, the contextInitialized method was never
called. Am I missing anything?
Thai
--
--
------------------
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.