}
deploymentTracker = new ServiceTracker(bundleContext, OpenEjbApplication.class.getName(), null);
deploymentTracker.open();
ServiceListener sl = new ServiceListener() {
public void serviceChanged(ServiceEvent ev) {
ServiceReference sr = ev.getServiceReference();
switch (ev.getType()) {
case ServiceEvent.REGISTERED:
deployApplication(sr);
break;
case ServiceEvent.UNREGISTERING:
undeployApplication(sr);
break;
}
}
};
// Generate a ServiceEvent for any existing OpenEJbApplication services.
String filter = "(objectclass=" + OpenEjbApplication.class.getName() + ")";
try {
bundleContext.addServiceListener(sl, filter);
ServiceReference[] srl = bundleContext.getServiceReferences(null, filter);
if (srl != null) {
for (ServiceReference sr : srl) {
sl.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, sr));
}
}
} catch (InvalidSyntaxException e) {
e.printStackTrace();
}