Introduction

(This information is based on the final shape of the design proposed in Template mechanism.)

Some artifacts (see Object graph in Client) can need some customization before being provisioned, e.g. configuration files might need some information that is managed by one of the licenses. For more detailed information, see the interface of ArtifactPreprocessor.

The customization will be done when a new version is created, i.e., on call of approve() on a StatefulGatewayObject. A customized version of the artifact (which is located somewhere in an OBR, reachable using a URL) is uploaded to the same OBR, and the URL to the customized one is stored in the DeploymentVersionObject.

Basic mechanism

When creating a new version, StatefulGatewayObject will instruct ArtifactRepository to handle preprocessing for a given artifact, for a given deployment version and gateway ID. ArtifactRepository will locate a helper for the artifact, retrieve the processor it proposes, and process the artifact.

For each type of artifact, there is an ArtifactHelper (see Object graph in Client). Each of these can provide an ArtifactPreprocessor by means of its getPreprocessor() method. If not suitable preprocessor is available, null should be returned, and no preprocessing will be done.

Template preprocessors

An ArtifactPreprocessor is responsible for

  • Determining whether a new version is necessary,
  • if so, processing of the template,
  • if necessary, storing the processed artifact in the obr,
  • and determining the new URL of the processed artifact (or, if no processing was done, the original URL).

When processing or determining whether a new version is needed, a preprocessor gets a PropertyResolver object, which can give information about the current 'environment'. For information on how to use this object, see ArtifactPreprocessor.

Creating a new version is not likely to happen that often, so efficiency is not really a concern there. Determining whether a new version is necessary, however, will happen very often, and should be as 'cheap' as possible. Preprocessors could, for instance, cache previously generated versions to lower network traffic.

Helpers

Same basic helpers are available. Package net.luminis.liq.helper.base contains an ArtifactPreprocessorBase, which can be extended by specific preprocessors, and provides basic upload capabilities.

Furthermore, it contains a VelocityBasedPreprocessor, which processes artifacts using the Velocity template engine. It is exported by a bundled version of package net.luminis.liq.helper.base, and can be instantiated and returned by any class that has a use for Velocity's template processing.

It should, however, be noted that using Velocity template syntax in an artifact may cause the ArtifactRecognizer to no longer recognize the artifact. One possible solution is to create a specific Recognizer and Helper for the type of artifact that needs to be preprocessed, which then has a specific recognition mechanism (for instance, some special extension).

  • No labels