| “Strategies in (*)ability” | [iDareMedia] [JWare] [PET] [CI-Dashboard] |
[guide] <alms-storagepolicy> |
The <alms-storagepolicy> component lets you define a custom ALMS storage policy that any ALMS-dependent catalog can use. A storage policy describes, among other things, how published antlib packages are organized at their source repositories, where local antlib packages will be stored, where published antlib packages can be can downloaded and post-processed before being stored locally, and how local antlib packages should be tested for “up-to-datedness”.
A storage policy is always associated with an ALMS instance (directly or indirectly through some catalog); by itself a storage policy has no useful function. To tell an ALMS instance how to store your antlib packages you must define an <almsdef> that includes your custom storage policy and then associate that almsdef with your catalog.
If you use an independent antlib repository synchronization tool, a storage policy lets you hook SAM into that tool’s local directory (or URL-accessible) storage or cache structure. In this scenario, the ALMS instance’s “download” operation becomes an optional local copy operation that ensures all antlib filters are applied as expected.
Every storage policy comes with a default name policy that governs how the ALMS instance converts your script-supplied retrieval method names into a published antlib package’s name. SAM supports four builtin naming policies and you are free to supply your own (see the NamePolicy interface in the SAM source distribution). Below the SAM policies are described briefly by name:
| Attribute | Description | Required |
| uploadsDir | Set to the path of the directory you would like used as the root of the local antlib repository. antlib packages are placed here after they have been expanded and optionally post-processed. The ALMS will look here before looking for a remote antlib package. | No; only one when specified. |
| uploads | Set to the base url you would like used as the root of the local antlib repository. Like uploadsDir except defined as a SAM base url; the url must refer to a read-writable directory. | |
| scratchDir | Set to the path of the directory you would like used as the root of the antlib download and processing area. antlib packages are downloaded and post-processed in the scratch area. | No; only one when specified. |
| scratch | Set to the base url you would like used as the antlib download and processing area. Like scratchDir except defined as a SAM base url; the url must refer to a read-writable directory. | |
| namepolicy | Set to one of “sams”, “simplearchive”, “simplefile”, “simpleartifact”, or a NamePolicy implementation class’s fully qualified class name. The name policy determines how an ALMS instance maps your script-supplied ARM names to antlib package names. | No; defaults “sams”. |
| ignoreOldUploads | Set to “yes” to force the ALMS to ignore antlib packages already existing in the local antlib repository (the uploadsDir directory). If not set explicitly, the ALMS assumes it can use any local antlib it finds. | No; defaults “no”. |
| uptodateTest | Set to the reference id of an AntX <criteria> definition you want used when the ALMS tries to determine if a pre-existing local antlib package is up-to-date. If ignoreOldUploads is true, this criteria is never called. | No. |
The <alms-storagepolicy> element does not support any nested elements.
The following snippet shows two ways to declare a custom storage policy for a reaction definition catalog; the first example uses SAM-based base urls, the second regular directory paths. The storage policy also declares that all antlib packages are distributed as simple single antlib files named like: method-name.xml.
<add-reactiondefs...>
<almsconfig>
<storagepolicy
scratch="userscratch"
uploads="adhoc.workspace"
namepolicy="simplefile"/>
</almsconfig>
…
</add-reactiondefs>
-OR-
<add-reactiondefs...>
<almsconfig>
<storagepolicy
scratchdir="${userscratch.dir}"
uploadsdir="${adhoc.workspace.dir}"
namepolicy="simplefile"/>
</almsconfig>
…
</add-reactiondefs>
The following snippet shows how to disable local caching of downloaded antlibs. The specific catalog is told to ignore any pre-existing antlib packages in favor of newly downloaded copies. Note that the iteration will use the default SAM locations for all antlib package processing.
<add-artifactdefs...>
<almsconfig>
<storagepolicy ignoreolduploads="yes"/>
</almsconfig>
…
</add-artifactdefs>
The following snippet shows how to use an AntX criteria (downloaded-today) to determine if a pre-existing antlib package is still usable. Usually this function is performed by an external repository synchronization tool; however, SAM has several hooks to let you either connect SAM to such a tool’s local cache or author your own Ant up-to-date tests.
<criteria id="downloaded-today">
…
</criteria>
…
<add-artifactdefs...>
<almsconfig>
<storagepolicy
uploads="local-antlibs"
uptodate="downloaded-today"/>
</almsconfig>
…
</add-artifactdefs>