An Oddjob job allows an Oddjob instance to be created within an existing Oddjob configuration. This way complicated processes can be created in managable and separately testable units.
An Oddjob job can be visualised as having two sides. One side is in the configuration that creates the Oddjob. The other side is in the configuration that the Oddjob job creates and runs. An Oddjob can have two different ids - that which identifies it in the outer and that which identifies it in the inner configuration files. An Oddjob job should only have it's properties set in the outer configuration file. To enforce this the top level <oddjob> element only supports the id attribute.
The args property allows arguments to be passed into a nested Oddjob from the the outer oddjob or from the command line.
Properties of jobs in a nested Oddjob can be accessed using the notation ${nested-oddjob-id/job-id.property} where nested-oddjob-id is the id in the outer configuration, not the inner one.
Oddjob has serveral properties to support registering bespoke jobs types, and property proxies. An example would be
...
<oddjob name="Nested Oddjob"
file="nested.xml">
<componentType>
<value name="myjob" value="com.mycomp.ProcessingJob"/>
</componentType>
</oddjob>
...
The file nested.xml can then contain something like.
<oddjob> <myjob/> </oddjob>The classpath that the nested Oddjob will use can also be configured.
| Name | Description | Required |
|---|---|---|
| name | A name, can be any text. | No. |
| file | The configuration file. | Yes. |
| persister | A component which is able to save and restore jobs. | No. |
| substitution | A value of STRICT will force Oddjob to check property substitutions for null values. Useful for debugging. | No. |
| args | An array of arguments the Oddjob configuration can use. | No. |
| classpath | The classpath property can be used to specify where Oddjob looks for additional jar files. The classpath is an inline files property. | No. |
| loadOnly | If set Oddjob will only load the job definitions. It will not execute them. This is useful when writing Oddjob configuration files to check that they parse correctly. | No. |
| file | The name of the configuration file. to configure this oddjob. | R/O |
| dir | The name of the directory the configuration file is in. | R/O |
| componentType | A mapped property for specifying additional component types. | No. |
| valueType | A mapped property for specifying additional value types. | No. |
| propertyProxy | A mapped property for specifying additional property proxies. | No. |
A simple nested Oddjob with one argument.
<oddjob id="this">
<oddjob file="${this.dir}/nested.xml">
<args>
<value value="apples"/>
</args>
</oddjob>
<l;/oddjob>
Oddjob with database persistance.
<oddjob file="${this.dir}\job.oddjob.persist.xml"
name="A Database Persisted Oddjob">
<persister>
<sqlPersister>
<connection driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost:11002/ojdb" username="sa"/>
</sqlPersister>
</persister>
</oddjob>