1 Reply Latest reply: Apr 21, 2011 4:13 AM by Thomas Diesler RSS

EJB loading classes from an OSGi Bundle

David Bosschaert Expert

I'm looking at a scenario where an EJB shares an interface with an OSGi bundle. The OSGi bundle defines the interface in a publicly exported package and the EJB needs to use this interface. I would like the EJB to share the same module as the OSGi bundle for this interface.

 

How would this work in practise? I played with the jboss-modules Dependencies Manifest header, like

  Dependencies: my-osgi-bundle

but it seems like these dependencies are only resolved against modules that are actually stored in the /modules subdirectory of AS7. Is there a way to look up dynamically added modules (such as OSGi bundles) as well?

  • 1. EJB loading classes from an OSGi Bundle
    Thomas Diesler Master

    If you want one user deployment to have a dependency on another user deployment, you must name the deployment you depend on like this

    Dependencies: deployment.my-osgi-bundle

    This works in Beta2 but only if you deploy my-osgi-bundle through the AS7 deployment API. If you use BundleContext.installBundle() it is different and currently subject to change. You can monitor Make packages from OSGi deployments visible to EE for progress on this.

     

    Generally it boils down to the question of how to derive the module identity for a bundle deployment. This should be identical accross all deployment channels. The module associated with a bundle deployment must then be managed by a ModuleLoader that is queried for EE dependencies. The obvious solution is to use the same ModuleLoader in the OSGi layer as AS uses for its deployments (i.e. ServiceModuleLoader)

     

    Because the dependee is not known to the OSGi resolver we have the "human wiring dilemma" and there is no guaranty that you have class space consistency.