On Wed, Nov 4, 2009 at 1:10 AM, Jonathan Gallimore
<[email protected]> wrote:
> The plugin itself listens for EJB bundles like this:
> 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();
> }
>
> The EJB bundle calls this on startup:
>
> OpenEjbApplication application = new OpenEjbApplication(bundle);
> context.registerService(OpenEjbApplication.class.getName(),
> application, null);
That's exactly how I wish it worked. OpenEJB would emit events upon
successful/unsuccessful deployment or any other interesting changes in
its work. Clean as far as OSGi's concerned. I didn't mean to introduce
any osgi changes in the main code before we really settle on it. I
didn't look at the source code of the plugin, but it turns out I'll
have to. Thanks.
Jacek
--
Jacek Laskowski
Notatnik Projektanta Java EE - http://www.JacekLaskowski.pl