-
Notifications
You must be signed in to change notification settings - Fork 7
Tomcat Integration
Gravia provides a patch for for Tomcat as a Maven artefact
<dependency>
<groupId>org.jboss.gravia</groupId>
<artifactId>gravia-container-tomcat</artifactId>
<classifier>patch</classifier>
<type>zip</type>
</dependency>
It contains a number of jars that get copied to the common lib folder.
Gravia works with already resolved modules. In this case with the WebApp ClassLoader created by Tomcat.
Before the WebApp becomes operational the target container (i.e. Tomcat) has to do the following
- Create the global Runtime instance
- Install the WebApp as a Module in the Runtime
- Start the WebApp Module
When a WebApp gets undeployed the target container has to do the following
- Stop the WebApp Module
- Uninstall the WebApp Module from the Runtime
The Tomcat integration provides provides a ServletContextListener that does all of the above - add this to your WebApp.
A Module combines a ClassLoader, a Resource and optional runtime headers. The Resource is the immutable set of Capabilities/Requirements associated with the Module. The ResourceIdentity is a mandatory capability for every Module.
There are various ResourceBuilders available.
To define a Module through its Manifest and install it to the Runtime you can do this
Runtime runtime = RuntimeLocator.getRuntime();
ResourceBuilder resbuilder = new ManifestResourceBuilder().load(manifest);
ManifestHeadersProvider headers = new ManifestHeadersProvider(manifest);
Module module = runtime.installModule(classLoader, resbuilder.getResource(), headers.getHeaders());
For this to work the manifest must define the Module's identity like this
Gravia-Identity: org.acme.webapp;version=1.0.0