-
Notifications
You must be signed in to change notification settings - Fork 7
OSGi Integration
Gravia provides a patch for for Karaf as a Maven artefact
<dependency>
<groupId>org.jboss.gravia</groupId>
<artifactId>gravia-container-tomcat-patch</artifactId>
<type>zip</type>
</dependency>
It contains a number of config files and bundles.
Gravia works with already resolved Bundles that have a valid ClassLoader. In this case with the ClassLoader provided by the Framework.
In order for a bundle to become a runtime module it must be a valid resource. The minimum criteria is that it has a resource identity (for details see defining a module). The resource identity can be given as a manifest header like this:
Gravia-Identity: org.acme.foo;version=1.0.0
or, in case you want to reuse the bundle symbolic name and version, like this
Gravia-Enabled: true
A Gravia artefact is meant to be portable across the set of supported target containers. Therefore, not every OSGi bundle is also a Gravia resource. OSGi API is generally not supported. To make a portable resource from a bundle, you would want to replace all usages of OSGi API with the Gravia equivalent. In most cases this will be a matter of changing the import package statement from org.osgi.framework
to org.jboss.gravia
. OSGi functionality that breaks portability because it is currently not supported in other target containers includes
- Embedded jars
- Fragments
- StartLevel
- etc.
Low level dynamic services, declarative services that are configurable and the http service are supported. The recommended programming model is to use declarative services.
Gravia currently still exposes the original APIs for the above services to the client
In future we will likely decouple from these APIs too and offer a Gravia equivalent.
The portable way for Gravia module activation is to use a ModuleActivator. In order for this to tie correctly into the bundle lifecycle it must be called from the BundleActivator. Gravia provides a ModuleActivatorBridge that calls the defined ModuleActivator reflectively
In a manifest this can be defined like this
Bundle-Activator: org.jboss.gravia.runtime.ModuleActivatorBridge
Module-Activator: org.acme.webapp.Activator
In the ModuleActivator you can register/lookup services, work with DS defined components, etc.