Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Tomcat Integration

Thomas Diesler edited this page Jan 22, 2014 · 16 revisions

Preparing Tomcat

Gravia provides a patch for Tomcat 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, common jars and the gravia webapp.

Preparing a WebApp

Gravia works with already resolved Modules that have a valid ClassLoader. In this case with the WebApp ClassLoader created by Tomcat.

In order for the WebApp 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

The module lifecycle can be controlled by a ServletContextListener. When using web.xml you can add the WebAppContextListener like this

<listener>
    <listener-class>org.jboss.gravia.runtime.WebAppContextListener</listener-class>
</listener>

or when using servlet 3.0 (without web.xml) an annotated listener like this

@WebListener
public class AnnotatedContextListener extends WebAppContextListener { }

Activating the Module

The Module headers may contain a module activator entry that defines the fully qualified name of a ModuleActivator.

In a manifest this can be defined like this

Module-Activator: org.acme.foo.Activator

In the ModuleActivator you can register/lookup services, work with DS defined components, etc.