Dispatch-Command
Description
dispatch-command iterates over the results of a context selector and calls the named command with selected paramaters.
Selectors are specified as nested elements, you must specify exactly one. The selectors are any data type that implements the IDispatchContextSelector java interface.
Attributes
| Attribute | Description | Required |
|---|---|---|
| name | Workflow name | defaults to ${command.name} |
| macro | Name of macro to execute for command. If a macro name is specified but has not been declared it is ignored. | Defaults to dispatch-command-macro |
| requirematch | Requires one or more matches. The task will fail if no match is made. | true (default) |
| strategy | Execution strategy | localdispatch or nodedispatch |
| threadcount | Number of threads to execute the workflow | Any integer greater than 0 |
Parameters specified as nested elements
errorhandler
This task can optionally use an errorhandler. If an error occurs during the course of the execution, the errorhandler can be configured to handle the exception according to your specification.
selector
This task requires an IDispatchContextSelector nested element. This datatype is responsible for selecting matching object contexts. that will be the target of the dispatched command. Each implementation of the IDispatchContextSelector can lookup objects using its own algorithm. The task iterates over the matched objects and for each one executes the specified. command. One selector must be nested inside a <context></context> tag set.
The table below describes the standard attributes and elements common to all selectors:
| Attribute | Description | Required |
|---|---|---|
| sortkey | The sort key. All selectors support type and name sort keys. | true |
| sortorder | Sort order (ascending or descending). | Defaults to ascending. |
| depot | Project depot. | true. |
include element
Selectors can use an include tag to specifie filter patterns to the selector:
| name | Object name regex | yes |
| type | Type name regex | yes |
| Example | ||
|---|---|---|
<include name=".*" type="Managed-[A-Z]+"/> |
||
The table below describes the three existing selectors:
| select-objects | Selects from locally installed objects |
|---|---|
<context>
<select-objects sortkey="name" sortorder="ascending" depot="${context.depot}">
<include name=".*" type="Managed-Entity"/>
</select-objects>
</context>
|
|
| select-deployments | Selects from registered objects in deployments.properties |
<context>
<select-deployments sortkey="name" sortorder="ascending" depot="${context.depot}">
<include name="me[0-9]+" type="Managed-Entity"/>
</select-deployments>
</context>
|
|
| select-dependencies | Selects from object dependency data |
| This selector supports an open ended set of sortkey values typicaly of dependency data. The selector looks at the fourth string in the given the format: relationtype.type.name.sortkey. For example, "startup-rank" can be used as the sort key for this property: deployment.Service.me1.startup-rank. | |
<!-- Define dependency data in the current command context -->
<!-- format: relationtype.type.name.sortkey = value -->
<property name="deployment.Service.me1.startup-rank" value="1"/>
<property name="deployment.Service.me2.startup-rank" value="2"/>
<context>
<select-dependencies sortkey="startup-rank" depot="${context.depot}"
sortorder="descending"
relationtypes="deployment" source="context">
<include name="me.*" type="[^.]*"/>
</select-dependencies>
</context>
|
|
Examples
Example: select-dependencies
This example shows the use of the select-dependencies selector to dispatch the Install command using "package-install-rank" as the sort key:
<!-- define three package object dependencies -->
<property name="package.war.headlines-1.0.package-install-rank"
value="3"/>
<property name="package.jar.hncore-1.2.package-install-rank"
value="2"/>
<property name="package.zip.jakarta-tomcat-4.1.31.package-install-rank"
value="1"/>
<!--
** select the objects based on include patterns
** and sort by package-install-rank
-->
<dispatch-command name="Packages-Install" requirematch="false">
<command name="Install"/>
<arg line=""/>
<contexts>
<select-dependencies source="context"
sortkey="package-install-rank" sortorder="ascending"
depot="${context.depot}"
>
<include name=".*" type="(?:war|jar|zip)"/>
</select-dependencies>
</contexts>
</dispatch-command>
Example: select-deployments
This example shows the use of the select-deployments selector to dispatch the Install command:
deployments.properties content:
object-deployment.default.SimpleAntBuilder.tutorial=build-1
object-deployment.default.SimpleApacheService.tutorial=web-1
object-deployment.default.SimpleTomcatService.simple=app-1
object-deployment.default.Site.simple=adminhost
object-deployment.default.Updater.simple=adminhost
<dispatch-command name="Deploy" requirematch="false">
<command name="Deploy"/>
<arg line=""/>
<contexts>
<select-deployments
sortkey="type" sortorder="ascending"
depot="${context.depot}"
>
<include name=".*" type="(?:SimpleTomcatService|SimpleApacheService)"/>
</select-deployments>
</contexts>
</dispatch-command>



