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

Tomcat Provisioning

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

Tomcat Class Loading

tomcat-modularity

  • Common ‘lib’ folder contains jars visible to Tomcat itself and all WARs
  • Libs form a flat class path. Split packages cannot be supported
  • Common libs cannot be updated without Tomcat restart
  • No dependencies between WARs
  • All API that can be used/shared across WARs must go to lib
  • Implementation can be deployed as WAR

Tomcat Provisioner

Like with any other target container, Gravia provides a Tomcat Provisioner Service that allows a client to use a container agnostic API together with a set of portable meta data and artefacts. Provisioning works from the content of the associate Repository. It also possible to deploy any other WebApp to Tomcat by-passing the provisioning system - in this case we are talking about deployment which is not aware of the current runtime state of the container. Provisioning is aware of that runtime state and hence can guarantee to only provision the needed delta and guarantee transitions from one consistent runtime state to the next.

Repository Resource Definitions

Below is a simple resource definition in the repository. The first defines an abstract "camel.core.feature", the second defines an actual resource that references the camel-core maven artefact.

<repository xmlns="http://www.osgi.org/xmlns/repository/v1.0.0" name="PersistentRepository">

  <!-- 
    camel.core.feature 
  -->
  <resource>
    <capability namespace="gravia.identity">
      <attribute name="gravia.identity" value="camel.core.feature" />
      <attribute name="type" value="abstract" />
    </capability>
    <requirement namespace="gravia.identity">
      <attribute name="gravia.identity" value="org.apache.camel.core" />
      <attribute name="version" value="[2.11,3.0)" />
    </requirement>
  </resource>
  <!-- 
    org.apache.camel.core
  -->
  <resource>
    <capability namespace="gravia.identity">
      <attribute name="gravia.identity" value="org.apache.camel.core" />
      <attribute name="maven.identity" value="org.apache.camel:camel-core:jar:2.11.0" />
      <attribute name="version" value="2.11.0" />
      <attribute name="shared" value="true" />
    </capability>
    <requirement namespace="gravia.identity">
      <attribute name="gravia.identity" value="javax.api" />
    </requirement>
    <requirement namespace="gravia.identity">
      <attribute name="gravia.identity" value="org.slf4j" />
    </requirement>
  </resource>
</repository>

Dependencies generally work with resource identities. The abstract camel.core.feature has a single resource dependency with a given version range. The "org.apache.camel.core" resource has resource dependencies on "javax.api" and "org.slf4j". These must either be provided by the Environment or defined in the repository so that they can be included in the set of artefacts that need to be provisioned. In the case of the default Tomcat installation, "javax.api" and "org.slf4j" are provided by the environment.

The "org.apache.camel.core" resource has an attribute which indicates that this is shared resource

<attribute name="shared" value="true" />

Shared resources will be placed in common "lib" folder such that they are visible to web applications that get deployed/provisioned later. The Tomcat provisioner guarantees consistency of the shared class space (i.e. a single version of any given package)

Client API Usage

Client side usage of this API is simple. You can use any RequirementBuilder to build the requirement that you have on the runtime. Then pass that requirement to the provisioner, which on successful completion will return a set of resource handles. These handles can be used to interact with the associated modules or later to uninstall the resource from the runtime.

    ResourceIdentity identity = ResourceIdentity.fromString("camel.core.feature:0.0.0");
    Requirement req = new IdentityRequirementBuilder(identity).getRequirement();
    Set<ResourceHandle> result = provisioner.provisionResources(Collections.singleton(req));