|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.oddjob.framework.BaseComponent
org.oddjob.framework.BasePrimary
org.oddjob.framework.StructuralJob<Object>
org.oddjob.Oddjob
public class Oddjob
Read a configuration, creates child jobs and executes them.
Oddjob creates a 'root' job on which to create the hierarchy. Through this root Oddjob aquires the first job to run and also exposes some of it's own properties for the jobs in the configuration to use. The root job's properties are:
For these properties to be accessible the root oddjob must be given an id.
As can be seen from the examples, the author uses the id 'this'
but the choice is arbitrary.
An Oddjob job allows an Oddjob instance to be created within an existing Oddjob configuration. This way complicated processes can be created in manageable and separately testable units.
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.
The persister property on a nested Oddjob will allow it's state to
be saved. See the
User Guide
for more information on how to set a persister.
Oddjob's descriptorFactory and classLoader properties
allow bespoke components and
types to be used. The
developer guide
is all about writing custom job's for Oddjob.
EchoJob job.
<oddjob>
<job>
<echo id="echo">Hello World</echo>
</job>
</oddjob>
<oddjob id="this">
<job>
<sequential>
<jobs>
<state:if xmlns:state="http://rgordon.co.uk/oddjob/state">
<jobs>
<check value="${this.args[0]}"/>
<properties>
<values>
<value key="our.file.name" value="${this.args[0]}"/>
</values>
</properties>
<input>
<requests>
<input-text prompt="File Name?" property="our.file.name"/>
</requests>
</input>
</jobs>
</state:if>
<echo>File Name is ${our.file.name}</echo>
</jobs>
</sequential>
</job>
</oddjob>
dir property of the
Oddjob root is used as the path of the nested configuration file.
<oddjob id="this">
<job>
<sequential>
<jobs>
<oddjob id="nested" file="${this.dir}/HelloWorld.xml"/>
<echo>Nested job said: ${nested/echo.text}</echo>
</jobs>
</sequential>
</job>
</oddjob>
The nested job is the first example:
<oddjob>
<job>
<echo id="echo">Hello World</echo>
</job>
</oddjob>
This example also shows how a property within the nested file can be
accessed within the parent configuration.
<oddjob id="this">
<job>
<oddjob id="nested" file="${this.dir}/EchoArg.xml">
<args>
<list>
<values>
<value value="Hello World"/>
</values>
</list>
</args>
</oddjob>
</job>
</oddjob>
And EchoArg.xml:
<oddjob id="this">
<job>
<echo id="echo">${this.args[0]}</echo>
</job>
</oddjob>
<oddjob id="this">
<job>
<oddjob id="nested" file="${this.dir}/EchoProperty.xml">
<properties>
<properties>
<values>
<value key="our.greeting" value="Hello World"/>
</values>
</properties>
</properties>
</oddjob>
</job>
</oddjob>
And EchoProperty.xml:
<oddjob id="this">
<job>
<echo id="echo">${our.greeting}</echo>
</job>
</oddjob>
Unlike the properties of jobs, free format properties like this can't be
accessed using the nested convention.
${nested/our.greeting} DOES NOT WORK!
This may be fixed in future versions.
<oddjob>
<job>
<sequential>
<jobs>
<folder>
<jobs>
<echo id="secret">I'm a secret job</echo>
</jobs>
</folder>
<oddjob id="inner">
<export>
<value key="secret" value="${secret}"/>
</export>
<configuration>
<arooa:configuration xmlns:arooa="http://rgordon.co.uk/oddjob/arooa">
<xml>
<xml>
<oddjob>
<job>
<run job="${secret}"/>
</job>
</oddjob>
</xml>
</xml>
</arooa:configuration>
</configuration>
</oddjob>
</jobs>
</sequential>
</job>
</oddjob>
Here a job is exported into a nested Oddjob. The
exported object is actually a ValueType. The value is converted back
to the job when the job property of the run job is set. Expressions such
as ${secret.text} are not valid (because value does not have a
text property!). Even ${secret.value.text} will not work because
of value wraps the job in yet another layer of complexity.| Nested Class Summary | |
|---|---|
class |
Oddjob.OddjobRoot
The object which is the Oddjob root. |
static class |
Oddjob.OddjobRootArooa
Provide an ArooaBeanDescriptor for the root Oddjob bean. |
| Field Summary | |
|---|---|
static LogArchive |
CONSOLE
The archiver to which all console output will be captured. |
static ArooaElement |
ODDJOB_ELEMENT
The document root for an Oddjob configuration file. |
static String |
VERSION
Oddjob version. |
| Fields inherited from class org.oddjob.framework.StructuralJob |
|---|
childHelper, childStateReflector, stateHandler, stop, structuralState |
| Fields inherited from class org.oddjob.framework.BaseComponent |
|---|
iconHelper |
| Constructor Summary | |
|---|---|
Oddjob()
Only constructor. |
|
| Method Summary | |
|---|---|
void |
addOwnerStateListener(OwnerStateListener listener)
Add a listener. |
protected void |
execute()
Execute this job. |
String[] |
getArgs()
|
ClassLoader |
getClassLoader()
Return a class loader. |
ArooaDescriptorFactory |
getDescriptorFactory()
Getter. |
File |
getDir()
|
ArooaValue |
getExport(String key)
Getter |
File |
getFile()
|
OddjobInheritance |
getInheritance()
Getter. |
protected StateOperator |
getInitialStateOp()
Subclasses must provide the StateOperator that will decide
how to evaluate the children's state. |
InputHandler |
getInputHandler()
Getter. |
org.oddjob.Oddjob.Reset |
getLastReset()
Getter for last reset. |
OddjobExecutors |
getOddjobExecutors()
Getter for OddjobExecutors that have been given to this
instance of Oddjob. |
OddjobServices |
getOddjobServices()
Getter for OddjobServices. |
OddjobPersister |
getPersister()
|
Properties |
getProperties()
Getter. |
String |
getVersion()
|
boolean |
hardReset()
Perform a hard reset. |
boolean |
isLoadable()
Is the component currently loadable. |
void |
load()
Load the component. |
protected void |
onDestroy()
Subclasses override this method to clear up resources. |
BeanDirectory |
provideBeanDirectory()
Get the BeanDirectory. |
ConfigurationSession |
provideConfigurationSession()
Provide a ConfigurationSession. |
void |
removeOwnerStateListener(OwnerStateListener listener)
Remove a listener. |
DesignFactory |
rootDesignFactory()
Get the design factory for the configuration. |
ArooaElement |
rootElement()
Get the root element. |
void |
setArgs(String[] args)
|
void |
setClassLoader(ClassLoader classLoader)
|
void |
setConfiguration(ArooaConfiguration config)
Setter for configuration. |
void |
setDescriptorFactory(ArooaDescriptorFactory descriptorFactory)
Setter. |
void |
setExport(String key,
ArooaValue value)
Setter. |
void |
setFile(File file)
|
void |
setInheritance(OddjobInheritance inheritance)
Setter. |
void |
setInputHandler(InputHandler inputHandler)
Setter. |
void |
setOddjobExecutors(OddjobExecutors executors)
Setter. |
void |
setOddjobServices(OddjobServices oddjobServices)
Allow for injection of OddjobServices |
void |
setPersister(OddjobPersister persister)
|
void |
setProperties(Properties properties)
Setter. |
boolean |
softReset()
Perform a soft reset on the job. |
String |
toString()
Override toString. |
void |
unload()
Unload the component. |
| Methods inherited from class org.oddjob.framework.StructuralJob |
|---|
addStructuralListener, fireDestroyedState, force, getStateChanger, isStop, onReset, onStop, removeStructuralListener, run, startChildStateReflector, stateHandler, stop |
| Methods inherited from class org.oddjob.framework.BasePrimary |
|---|
configure, getName, logger, logger, loggerName, save, setName |
| Methods inherited from class org.oddjob.framework.BaseComponent |
|---|
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSession |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.oddjob.Stateful |
|---|
addStateListener, lastStateEvent, removeStateListener |
| Field Detail |
|---|
public static final String VERSION
public static final LogArchive CONSOLE
public static final ArooaElement ODDJOB_ELEMENT
| Constructor Detail |
|---|
public Oddjob()
| Method Detail |
|---|
public void setFile(File file)
Property: file
Description: The name of the configuration file. to configure this oddjob.
Required: No.
public File getFile()
public void setConfiguration(ArooaConfiguration config)
config - public void setClassLoader(ClassLoader classLoader)
Property: classLoader
Description: The classLoader to use when loading the configuration.
See also URLClassLoaderType
Required: No.
public ClassLoader getClassLoader()
public ConfigurationSession provideConfigurationSession()
ConfigurationOwnerConfigurationSession.
provideConfigurationSession in interface ConfigurationOwnerConfigurationSession. My be null if no session is available.public void addOwnerStateListener(OwnerStateListener listener)
ConfigurationOwner
addOwnerStateListener in interface ConfigurationOwnerpublic void removeOwnerStateListener(OwnerStateListener listener)
ConfigurationOwner
removeOwnerStateListener in interface ConfigurationOwnerpublic DesignFactory rootDesignFactory()
ConfigurationOwner
rootDesignFactory in interface ConfigurationOwnerpublic ArooaElement rootElement()
ConfigurationOwner
rootElement in interface ConfigurationOwnerprotected StateOperator getInitialStateOp()
StructuralJobStateOperator that will decide
how to evaluate the children's state.
getInitialStateOp in class StructuralJob<Object>public boolean isLoadable()
Loadable
isLoadable in interface LoadableProperty: loadable
Description: Can Oddjob be loaded. Used by the Load/Unload actions.
Required: Read only.
public void load()
Loadable
load in interface Loadable
protected void execute()
throws Exception
StructuralJob
execute in class StructuralJob<Object>Exception - If the unexpected occurs.public void unload()
Loadable
unload in interface Loadableprotected void onDestroy()
BaseComponent
onDestroy in class StructuralJob<Object>public boolean softReset()
StructuralJob
softReset in interface ResetablesoftReset in class StructuralJob<Object>public boolean hardReset()
hardReset in interface ResetablehardReset in class StructuralJob<Object>public OddjobPersister getPersister()
public void setPersister(OddjobPersister persister)
persister - The persister to set.public BeanDirectory provideBeanDirectory()
BeanDirectoryOwnerBeanDirectory. This method may return null if
the BeanDirectory isn't available.
provideBeanDirectory in interface BeanDirectoryOwnerBeanDirectory or null.public org.oddjob.Oddjob.Reset getLastReset()
public String[] getArgs()
public void setArgs(String[] args)
args - The args to set.public ArooaValue getExport(String key)
key - The key.
public void setExport(String key,
ArooaValue value)
key - value - public Properties getProperties()
public void setProperties(Properties properties)
properties - Optional properties.public OddjobInheritance getInheritance()
public void setInheritance(OddjobInheritance inheritance)
inheritance - Inheritance property.public File getDir()
Property: dir
Description: The name of the directory the configuration file is in.
Required: R/O
public String getVersion()
Property: version
Description: This Oddjob's version.
public ArooaDescriptorFactory getDescriptorFactory()
public void setDescriptorFactory(ArooaDescriptorFactory descriptorFactory)
descriptorFactory - And ArooaDescriptorFactory.public OddjobExecutors getOddjobExecutors()
OddjobExecutors that have been given to this
instance of Oddjob. This getter does not expose the internal executors.
public void setOddjobExecutors(OddjobExecutors executors)
executors - OddjobExecutorspublic OddjobServices getOddjobServices()
OddjobServices.
@Inject public void setOddjobServices(OddjobServices oddjobServices)
OddjobServices
oddjobServices - public String toString()
BasePrimary
toString in class BasePrimarypublic InputHandler getInputHandler()
public void setInputHandler(InputHandler inputHandler)
inputHandler - An InputHandler.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||