openejb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Gallimore <jonathan.gallim...@gmail.com>
Subject Re: For adventurous: first run of OSGified OpenEJB *seems* running fine
Date Wed, 04 Nov 2009 00:10:11 GMT
I've been reading this thread with a lot of interest, this is looking like a
really nice piece of functionality. I've had a bit too much on my plate to
have a proper play around with this functionality but I'm hoping to get into
shortly.

>
>
> The missing pieces are to create a service bundle so JNDI namespace is
> visible to other bundles being ejb clients or exposing ejb interfaces
> as osgi services and finally create a osgified deployer (picks up
> instaled bundles that are ejbs as well, passes them to openejb and
> registers osgi services). Fancy helping out?
>

One thing I did mean to mention here was that in the Eclipse plugin we have
a org.apache.openejb.server plugin, which was contributed a while back by
Deryck Brown, to help build an Eclipse RCP application with OpenEJB embedded
in it. This contribution has some code which listens for certain services
being registered with the OSGi container, and deploying the app with
OpenEJB. The org.apache.openejb.server wraps all of OpenEJB presenting it as
one big bundle, and I've only had it working with Equinox, but I wonder
whether whether this code might be useful or not.

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);


Anyway, I don't know if its any use, but I thought I'd mention it.

Thanks for the work you've done on this - hopefully I'll give it a go some
point this week and give you some feedback.

Jon

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message