I am trying to deploy my spring application within jetty. When jetty starts, ApplicationLifecycleListener beans get a ContextRefreshedEvent. However, when I stop the jetty Server, I don't get any ContextClosedEvent.
I'm trying to understand the linkage between the web container (jetty) and springs XmlWebApplicationContext. I clearly have to do something, but is that something:
- make my WebApplicationContext aware of jetty?
OR - make jetty aware of my spring WebApplicationContext?
And how?
I'm actually instantiating jetty as a bean, using spring and then launching it using some java code which gets called from a windows service:
Code:
<bean id="myAppContext" class="org.eclipse.jetty.webapp.WebAppContext">
<property name="contextPath" value="/myapp" />
<property name="war" value="${my.warfile}" />
<property name="extraClasspath" value="deploy/config" />
</bean>
<bean id="jettyServer" class="org.eclipse.jetty.server.Server">
<property name="handler" ref="myAppContext" />
<property name="gracefulShutdown" value="500" />
<property name="stopAtShutdown" value="true" />
</bean>
From the windows service I do:
Code:
ClassPathXmlApplicationContext jettyCtx = new ClasspathApplicationContext(...);
Server jettyServer = (Server)jettyCtx.getBean("jettyServer");
jettyServer.start();
...
jettyServer.stop();