-
1. Re: JBoss module access to OSGi bundle
thomas.diesler Jan 13, 2012 4:12 AM (in response to swiderski.maciej)1 of 1 people found this helpfulA Module can load classes from a Bundle when it creates a dependency on the Bundle. This is equivalent to creating a dependency on another Module
builder.addManifestHeader("Dependencies", "org.osgi.core,org.jboss.modules,org.jboss.logging,org.jboss.osgi.framework,deployment.example-xservice-mab-target-bundle:0.0.0")
A Bundle can access a Module if the Module if the Module is explicitly registered with the OSGi layer. Modules can register MSC services under a special naming convention so that they are seen by the OSGi service registry
public static void addService(ServiceTarget serviceTarget) { // Add the service with an alias that the OSGi layer can use to lookup the service ServiceBuilder<Echo> serviceBuilder = serviceTarget.addService(SERVICE_NAME, new EchoService()); serviceBuilder.addAliases(ServiceName.of("jbosgi", "xservice", Echo.class.getName())); serviceBuilder.setInitialMode(Mode.ACTIVE); serviceBuilder.install(); log.infof("Service added: %s", SERVICE_NAME); log.infof("Echo Loader: %s", Echo.class.getClassLoader()); }
For more on this functionality you can study the xservice integration samples.
So in short: every bundle is a module, but not every module is also a bundle.
In future, we will move the OSGi Resolver a level down, so that every Module is also a Bundle - then the need of explicit registration should disappear and the two programming models should integrate more seamlessly.
-
2. Re: JBoss module access to OSGi bundle
swiderski.maciej Jan 15, 2012 11:00 AM (in response to thomas.diesler)Thanks Thomas, xservice was what I was looking for.
Another question, are META-INF content is loaded by module classloader? I have a jar (it is declared as resource-root) of a module and it has some xml files in META-INF but I can access them from, for instance web application. Is there any special configuration to be done in module.xml to make it visible for components that depend on the module?
Cheers
-
3. Re: JBoss module access to OSGi bundle
thomas.diesler Jan 25, 2012 8:57 AM (in response to swiderski.maciej)For jboss-modules questions or general complaints about their documentation, you probabaly need to go to the AS team. I know however that META-INF is not automatically exported. The export attribute means that the importer re-exports the paths from the dependee. The services attribute means the the importer sees META-INF services
<module name="com.sun.xml.bind" services="export" export="true"/>
You can check the schema for details.