tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jarek Gawor (JIRA)" <>
Subject [jira] Updated: (OPENEJB-1117) ServiceManager does not work in OSGi environment
Date Thu, 10 Dec 2009 06:28:18 GMT


Jarek Gawor updated OPENEJB-1117:

    Attachment: OPENEJB-1117.patch

Attached patch is an attempt of making the ServiceManager work right in the OSGi environment.
The patch introduces a ServiceManagerExtender class that follows the extender pattern. The
ServiceManagerExtender tracks bundles with the ServerService resource files and starts or
stops the provided services. Once some ServerService service is started the ServiceManagerExtender
will also register the service into OSGi service registry with the given service properties.
The ServiceManagerExtender manages the ServerService services dynamically so the bundles that
provide the different ServerService services can be installed/uninstalled/started/stopped
at any point.

The patch re-factors the existing ServiceManager class a bit in order to provide different
subclasses (for different environments) and to reuse the code. But it tries to preserve the
core ServiceManager API (ServiceManager.get(), init(), start(), stop()) for backwards compatibility.
The ServiceManager is now an abstract class with a few common/reusable functions. The SimpleServiceManager
is the default implementation of  ServiceManager and works just like ServiceManager used to.
The ServiceManagerExtender is the new ServiceManager implementation that works in OSGi environment.
That implementation is automatically installed by the Activator. 

> ServiceManager does not work in OSGi environment
> ------------------------------------------------
>                 Key: OPENEJB-1117
>                 URL:
>             Project: OpenEJB
>          Issue Type: Improvement
>          Components: osgi
>    Affects Versions: 3.1.x
>            Reporter: Jarek Gawor
>         Attachments: OPENEJB-1117.patch
> ServiceManager essentially looks for the ServerService resource files in its classloader
hierarchy. This works well in regular Java environment where usually the openejb-server jar
would be in the same classloader as any of the ServerService implementations. However, in
OSGi environment the openejb-server and the different ServerService implementations are separate
bundles and effectively have separate classloaders. As a result, the ServiceManager in OSGi
environment is unable to discover the ServerService resource files provided by the different
"server" bundles.
> Side note: There are actually a number of problems here. One main problem is in the xbean
ResourceFinder class. It does not understand how to deal with "bundle" urls returned by classloader.getResource()
lookup. But even if it was fixed to support the "bundle" urls it would still not   find the
ServerService resources in other bundles since they would not be accessible from openejb-server
bundle classloader. There are ways of making the ServerService resources in other bundles
visible to openejb-server bundle but they are not desirable solutions (e.g. making "server"
bundles into fragment bundles or making openejb-server Require-Bundle the different "server"
bundles, etc.).

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message