essam
May 8th, 2009, 02:35 PM
I'm using dm Server 1.0.2 and need to somehow get notified when a war module is deployed. My wars use the shared libraries way as described in the developer's guide (http://static.springsource.com/projects/dm-server/1.0.x/programmer-guide/html/ch04.html#architecture-shared-libraries-war).
I first followed the "Listening to Extender events" section @ http://static.springframework.org/osgi/docs/1.1.0-m2/reference/html/app-deploy.html#app-deploy:extender-configuration:events, and implemented a Spring DM OsgiBundleApplicationContextListener as follows:
import org.springframework.osgi.context.event.OsgiBundleA pplicationContextEvent;
import org.springframework.osgi.context.event.OsgiBundleA pplicationContextListener;
import org.springframework.osgi.context.event.OsgiBundleC ontextRefreshedEvent;
public class MyBundleApplicationContextListener implements OsgiBundleApplicationContextListener {
@Override
public void onOsgiApplicationEvent(OsgiBundleApplicationContex tEvent event) {
if (event instanceof OsgiBundleContextRefreshedEvent) {
System.out.println(event);
}
}
and added the following to one of my (non-war) bundles:
<bean name="contextListenerImpl"
class="com.sample.impl.MyBundleApplicationContextListener"/>
<osgi:service id="contextListener" ref="contextListenerImpl"
interface="org.springframework.osgi.context.event.OsgiBundleA pplicationContextListener" />
But the listener gets called only for non-war bundles, which I guess makes sense since dm server does not use the Spring DM web extender (or something like that).
Is there a way to get notified when war bundles get deployed?
Thanks!
I first followed the "Listening to Extender events" section @ http://static.springframework.org/osgi/docs/1.1.0-m2/reference/html/app-deploy.html#app-deploy:extender-configuration:events, and implemented a Spring DM OsgiBundleApplicationContextListener as follows:
import org.springframework.osgi.context.event.OsgiBundleA pplicationContextEvent;
import org.springframework.osgi.context.event.OsgiBundleA pplicationContextListener;
import org.springframework.osgi.context.event.OsgiBundleC ontextRefreshedEvent;
public class MyBundleApplicationContextListener implements OsgiBundleApplicationContextListener {
@Override
public void onOsgiApplicationEvent(OsgiBundleApplicationContex tEvent event) {
if (event instanceof OsgiBundleContextRefreshedEvent) {
System.out.println(event);
}
}
and added the following to one of my (non-war) bundles:
<bean name="contextListenerImpl"
class="com.sample.impl.MyBundleApplicationContextListener"/>
<osgi:service id="contextListener" ref="contextListenerImpl"
interface="org.springframework.osgi.context.event.OsgiBundleA pplicationContextListener" />
But the listener gets called only for non-war bundles, which I guess makes sense since dm server does not use the Spring DM web extender (or something like that).
Is there a way to get notified when war bundles get deployed?
Thanks!