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

WildFly Provisioning

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

WildFly Class Loading

wildfly-modularity

  • Separation between system and application modules
  • Package visibility controlled by the module (hardly used)
  • Wiring controlled by hard coded values
  • Separation between API and implementation modules works
  • Dependencies between deployments not portable
  • Artefacts are usable with minor modifications in Tomcat, OSGi and WildFly

WildFly Provisioner

Like with any other target container, Gravia provides a WildFly 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 WildFly supported deployment 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 WildFly 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 the WildFly modules hierarchy such that they are visible to applications that get deployed/provisioned later. The WildFly provisioner guarantees consistency of the shared class space. Multiple versions of the same package are supported.

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));