public abstract class AbstractJobContainer<W extends Work,N extends JobMetaData> extends AbstractLinkedListSetEntry<JobNode,JobSequence> implements Job, JobNode, JobExecuteContext, ContainerContext
Modifier and Type | Field and Description |
---|---|
static TeamIdentifier |
ASYNCHRONOUS_FLOW_TEAM_IDENTIFIER
TeamIdentifier for decoupling current Team from invoking
the asynchronous flow. |
protected JobSequence |
flow
|
protected N |
nodeMetaData
|
protected WorkContainer<W> |
workContainer
|
Constructor and Description |
---|
AbstractJobContainer(JobSequence flow,
WorkContainer<W> workContainer,
N nodeMetaData,
JobNode parallelOwner,
ManagedObjectIndex[] requiredManagedObjects,
boolean[] requiredGovernance,
GovernanceDeactivationStrategy governanceDeactivationStrategy)
Initiate.
|
Modifier and Type | Method and Description |
---|---|
void |
activateJob(TeamIdentifier currentTeam)
|
void |
addGovernanceActivity(GovernanceActivity<?,?> activity)
Adds a
GovernanceActivity to be executed before the current
JobNode . |
void |
addSetupTask(TaskMetaData<?,?,?> taskMetaData,
Object parameter)
|
void |
cancelJob(Exception cause)
Triggers to cancel the
Job . |
void |
clearNodes(JobNodeActivateSet activateSet,
TeamIdentifier currentTeam)
|
FlowFuture |
doFlow(FlowMetaData<?> flowMetaData,
Object parameter)
Invokes the
JobSequence for the input FlowMetaData . |
boolean |
doJob(JobContext jobContext)
Executes the
Job . |
protected abstract Object |
executeJob(JobExecuteContext context,
JobContext jobContext,
JobNodeActivateSet activateSet)
Overridden by specific container to execute the
Job . |
void |
flagJobToWait()
Flags for the
JobNode to wait and be activated at a later time
once a dependency is ready. |
EscalationProcedure |
getEscalationProcedure()
Obtains the
EscalationProcedure for this JobNode . |
JobSequence |
getJobSequence()
Obtains the
JobSequence containing this JobNode . |
JobSequence |
getLinkedListSetOwner()
Obtains the owner of the
LinkedListSet that this
LinkedListSetEntry may be added. |
Job |
getNextJob()
Obtains the next
Job . |
JobNode |
getNextNode()
|
JobNode |
getParallelNode()
|
JobNode |
getParallelOwner()
Obtains the parallel owner of this
JobNode . |
Object |
getProcessIdentifier()
Obtains the identifier for the
ProcessState containing this
Job . |
boolean |
isJobNodeComplete()
Indicates if this
JobNode is completed. |
void |
joinFlow(FlowFuture flowFuture,
long timeout,
Object token)
Joins on the
JobSequence for the FlowFuture . |
protected abstract void |
loadJobName(StringBuilder message)
Loads the
Job name to the message. |
void |
setJobComplete(boolean isComplete)
Specifies whether the job is complete.
|
void |
setNextJob(Job task)
Specifies the next
Job . |
void |
setNextNode(JobNode jobNode)
|
void |
setParallelNode(JobNode jobNode)
|
void |
setParallelOwner(JobNode jobNode)
Specifies the parallel owner of this
JobNode . |
getNext, getPrev, setNext, setPrev
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getNext, getPrev, setNext, setPrev
protected final JobSequence flow
protected final WorkContainer<W extends Work> workContainer
protected final N extends JobMetaData nodeMetaData
public static TeamIdentifier ASYNCHRONOUS_FLOW_TEAM_IDENTIFIER
TeamIdentifier
for decoupling current Team
from invoking
the asynchronous flow.
Note that asynchronous flows should be queued and not executed
immediately by the current Team
. Should execution be required
immediately please use parallel flow.
public AbstractJobContainer(JobSequence flow, WorkContainer<W> workContainer, N nodeMetaData, JobNode parallelOwner, ManagedObjectIndex[] requiredManagedObjects, boolean[] requiredGovernance, GovernanceDeactivationStrategy governanceDeactivationStrategy)
flow
- JobSequence
containing this Job
.workContainer
- WorkContainer
of the Work
for this
Task
.nodeMetaData
- JobMetaData
for this node.parallelOwner
- If this is invoked as or a parallel Task
or from a
parallel Task
this will be the invoker. If not
parallel then will be null
.requiredManagedObjects
- Work
ManagedObjectIndex
instances to the
ManagedObject
instances that must be loaded before the
Task
may be executed.requiredGovernance
- Identifies the required activation state of the
Governance
for this Job
.governanceDeactivationStrategy
- GovernanceDeactivationStrategy
for
ActiveGovernance
.protected abstract void loadJobName(StringBuilder message)
Job
name to the message.message
- Message to receive the Job
name.protected abstract Object executeJob(JobExecuteContext context, JobContext jobContext, JobNodeActivateSet activateSet) throws Throwable
Job
.context
- JobExecuteContext
.jobContext
- JobContext
.activateSet
- JobNodeActivateSet
.Job
.Throwable
- If failure in executing the Job
.public JobSequence getLinkedListSetOwner()
LinkedListSetEntry
Obtains the owner of the LinkedListSet
that this
LinkedListSetEntry
may be added.
LinkedListSetEntry
instances may only be added to the
LinkedListSet
they were intended for and can not be shared
between LinkedListSet
instances. This constraint:
JobNode
, JobSequence
,
ThreadState
, ProcessState
structure, andLinkedListSetEntry.getNext()
and
LinkedListSetEntry.getPrev()
both returning null
indicates not addedgetLinkedListSetOwner
in interface LinkedListSetEntry<JobNode,JobSequence>
LinkedListSet
that may contain this
LinkedListSetEntry
.public void flagJobToWait()
ContainerContext
JobNode
to wait and be activated at a later time
once a dependency is ready.flagJobToWait
in interface ContainerContext
public void addSetupTask(TaskMetaData<?,?,?> taskMetaData, Object parameter)
ContainerContext
Adds a setup Task
to be executed before the current
JobNode
.
This is available to ManagedObject
and Duty
setup. Note
that if it is added during Task
execution it will be executed
after the Task
.
addSetupTask
in interface ContainerContext
taskMetaData
- TaskMetaData
for the setup Task
.parameter
- Parameter for the Task
.public void addGovernanceActivity(GovernanceActivity<?,?> activity)
ContainerContext
Adds a GovernanceActivity
to be executed before the current
JobNode
.
This is available to ManagedObject
and Duty
setup. Note
that if it is added during Task
execution it will be executed
after the Task
.
addGovernanceActivity
in interface ContainerContext
activity
- GovernanceActivity
.public final void setNextJob(Job task)
Job
Specifies the next Job
. This provides ability to create a linked
list of Job
instances.
Note there is no thread-safety guaranteed on this method.
setNextJob
in interface Job
task
- Job
that is next in the list to this Job
.Job.getNextJob()
public final Job getNextJob()
Job
Obtains the next Job
. This provides ability to create a linked
list of Job
instances.
Note there is no thread-safety guaranteed on this method.
getNextJob
in interface Job
Job
after this in the list.Job.setNextJob(Job)
public Object getProcessIdentifier()
Job
Obtains the identifier for the ProcessState
containing this
Job
.
This allows the Team
executing the Job
to be aware of the
ProcessState
context in which the Job
is to be executed.
An example use would be embedding OfficeFloor
within an
Application Server and using this identifier and a
ProcessContextListener
to know the invoking Thread
for
interaction with JNDI.
getProcessIdentifier
in interface Job
ProcessState
containing this
Job
ProcessContextListener
public void cancelJob(Exception cause)
Job
Job
.public final boolean doJob(JobContext jobContext)
Job
public final void setJobComplete(boolean isComplete)
JobExecuteContext
setJobComplete
in interface JobExecuteContext
isComplete
- true
if complete.public final void joinFlow(FlowFuture flowFuture, long timeout, Object token)
JobExecuteContext
JobSequence
for the FlowFuture
.joinFlow
in interface JobExecuteContext
flowFuture
- FlowFuture
of the JobSequence
to join.timeout
- Timeout in milliseconds for the JobSequence
join.token
- JobSequence
join token.public final FlowFuture doFlow(FlowMetaData<?> flowMetaData, Object parameter)
JobExecuteContext
JobSequence
for the input FlowMetaData
.doFlow
in interface JobExecuteContext
flowMetaData
- FlowMetaData
.parameter
- Parameter for the JobSequence
.FlowFuture
of the JobSequence
.public final void activateJob(TeamIdentifier currentTeam)
JobNode
activateJob
in interface JobNode
currentTeam
- Current TeamIdentifier
that is activating the
JobNode
. This enables continuing execution with the
current Thread
should it be the same Team
.public boolean isJobNodeComplete()
JobNode
JobNode
is completed.isJobNodeComplete
in interface JobNode
true
if this JobNode
is completed.public JobSequence getJobSequence()
JobNode
JobSequence
containing this JobNode
. The
returned JobSequence
provides access to the ThreadState
and subsequent ProcessState
that this JobNode
is involved
in.getJobSequence
in interface JobNode
JobSequence
containing this JobNode
.public EscalationProcedure getEscalationProcedure()
JobNode
EscalationProcedure
for this JobNode
.getEscalationProcedure
in interface JobNode
EscalationProcedure
for this JobNode
.public final void setParallelOwner(JobNode jobNode)
JobNode
Specifies the parallel owner of this JobNode
.
The input JobNode
is executed once the current
JobSequence
that this JobNode
is involved with is
complete.
setParallelOwner
in interface JobNode
jobNode
- Parallel owner of this JobNode
.public final JobNode getParallelOwner()
JobNode
JobNode
.getParallelOwner
in interface JobNode
JobNode
.public final void setParallelNode(JobNode jobNode)
JobNode
JobNode
to the current JobNode
.
The current JobNode
will not complete until the input parallel
JobNode
is complete.setParallelNode
in interface JobNode
jobNode
- Parallel JobNode
.public final JobNode getParallelNode()
JobNode
getParallelNode
in interface JobNode
JobNode
to the current JobNode
.public final void setNextNode(JobNode jobNode)
JobNode
setNextNode
in interface JobNode
jobNode
- Next JobNode
.public final JobNode getNextNode()
JobNode
getNextNode
in interface JobNode
JobNode
.public final void clearNodes(JobNodeActivateSet activateSet, TeamIdentifier currentTeam)
JobNode
clearNodes
in interface JobNode
activateSet
- JobNodeActivateSet
.currentTeam
- TeamIdentifier
of the current Team
clearing
the JobNode
instances.Copyright © 2005–2016. All rights reserved.