openejb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacek Laskowski <ja...@laskowski.net.pl>
Subject Re: For adventurous: first run of OSGified OpenEJB *seems* running fine
Date Wed, 04 Nov 2009 07:44:16 GMT
On Wed, Nov 4, 2009 at 1:10 AM, Jonathan Gallimore
<jonathan.gallimore@gmail.com> 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

Mime
View raw message