net.officefloor.frame.impl.spi.team
Class ProcessContextTeam

java.lang.Object
  extended by net.officefloor.frame.impl.spi.team.ProcessContextTeam
All Implemented Interfaces:
ProcessContextListener, Team

public class ProcessContextTeam
extends Object
implements Team, ProcessContextListener

Team to re-use the invoking Thread of the ProcessState. Typically this will be the Thread invoking the Work via the WorkManager.

To enable the invoking Thread to be available for executing Task instances of the ProcessState, the Work by the WorkManager needs to be invoked with the doWork(WorkManager, Object) method.

As the typical focus of this Team is to integration with Application Servers (using correct Thread for JNDI lookups), assigned Job instances without a ProcessState context Thread will be executed passively (i.e. by the caller - Thread of previous Job).

Author:
Daniel Sagenschneider

Constructor Summary
ProcessContextTeam(TeamIdentifier teamIdentifier)
          Initiate.
 
Method Summary
 void assignJob(Job job, TeamIdentifier assignerTeam)
          Assigns a Job to be executed by this Team.
static void doProcess(ManagedObjectExecuteContext<?> executeContext, int flowIndex, Object parameter, ManagedObject managedObject, EscalationHandler escalationHandler)
           Wrap invoking ProcessState on the ManagedObjectExecuteContext to allow the Thread to be available to execute the Task instances of the ProcessState.
static
<F extends Enum<F>>
void
doProcess(ManagedObjectExecuteContext<F> executeContext, F flowKey, Object parameter, ManagedObject managedObject, EscalationHandler escalationHandler)
           Wrap invoking ProcessState on the ManagedObjectExecuteContext to allow the Thread to be available to execute the Task instances of the ProcessState.
static void doTask(TaskManager taskManager, Object parameter)
           Wrap invoking Task on the TaskManager to allow the Thread to be available to execute the Task instances of the ProcessState.
static void doWork(WorkManager workManager, Object parameter)
           Wrap invoking Work on the WorkManager to allow the Thread to be available to execute the Task instances of the ProcessState.
 void processCompleted(Object processIdentifier)
          Notifies that the ProcessState is completed.
 void processCreated(Object processIdentifier)
           Notifies that a ProcessState is created.
 void startWorking()
          Indicates for the Team to start working.
 void stopWorking()
           Indicates for the Team to stop working.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessContextTeam

public ProcessContextTeam(TeamIdentifier teamIdentifier)
Initiate.

Parameters:
teamIdentifier - TeamIdentifier of this Team.
Method Detail

doWork

public static void doWork(WorkManager workManager,
                          Object parameter)
                   throws NoInitialTaskException,
                          InvalidParameterTypeException,
                          InterruptedException

Wrap invoking Work on the WorkManager to allow the Thread to be available to execute the Task instances of the ProcessState.

This method blocks until the invoked ProcessState of the invoked Work is complete.

Parameters:
workManager - WorkManager managing the Work to invoked.
parameter - Parameter for the initial Task of the Work.
Throws:
NoInitialTaskException - If Work of the WorkManager has no initial Task.
InvalidParameterTypeException - Should the parameter type be invalid for the Task.
InterruptedException - Should this blocking call be interrupted.

doTask

public static void doTask(TaskManager taskManager,
                          Object parameter)
                   throws InvalidParameterTypeException,
                          InterruptedException

Wrap invoking Task on the TaskManager to allow the Thread to be available to execute the Task instances of the ProcessState.

This method blocks until the invoked ProcessState of the invoked Task is complete.

Parameters:
taskManager - TaskManager managing the Task to invoked.
parameter - Parameter for the Task.
Throws:
InvalidParameterTypeException - Should the parameter type be invalid for the Task.
InterruptedException - Should this blocking call be interrupted.

doProcess

public static <F extends Enum<F>> void doProcess(ManagedObjectExecuteContext<F> executeContext,
                                                 F flowKey,
                                                 Object parameter,
                                                 ManagedObject managedObject,
                                                 EscalationHandler escalationHandler)
                      throws InterruptedException

Wrap invoking ProcessState on the ManagedObjectExecuteContext to allow the Thread to be available to execute the Task instances of the ProcessState.

This method blocks until the invoked ProcessState is complete.

Parameters:
executeContext - ManagedObjectExecuteContext.
flowKey - JobSequence key.
parameter - Parameter for the initial Task.
managedObject - ManagedObject.
escalationHandler - EscalationHandler. May be null.
Throws:
InterruptedException - Should this blocking call be interrupted.

doProcess

public static void doProcess(ManagedObjectExecuteContext<?> executeContext,
                             int flowIndex,
                             Object parameter,
                             ManagedObject managedObject,
                             EscalationHandler escalationHandler)
                      throws InterruptedException

Wrap invoking ProcessState on the ManagedObjectExecuteContext to allow the Thread to be available to execute the Task instances of the ProcessState.

This method blocks until the invoked ProcessState is complete.

Parameters:
executeContext - ManagedObjectExecuteContext.
flowIndex - JobSequence index.
parameter - Parameter for the initial Task.
managedObject - ManagedObject.
escalationHandler - EscalationHandler. May be null.
Throws:
InterruptedException - Should this blocking call be interrupted.

startWorking

public void startWorking()
Description copied from interface: Team
Indicates for the Team to start working.

Specified by:
startWorking in interface Team

assignJob

public void assignJob(Job job,
                      TeamIdentifier assignerTeam)
Description copied from interface: Team
Assigns a Job to be executed by this Team.

Specified by:
assignJob in interface Team
Parameters:
job - Job.
assignerTeam - TeamIdentifier of the Team assigning the Job to this Team.

stopWorking

public void stopWorking()
Description copied from interface: Team

Indicates for the Team to stop working.

This method should block and only return control when the Team has stopped working and is no longer assigned Job instances to complete.

Specified by:
stopWorking in interface Team

processCreated

public void processCreated(Object processIdentifier)
Description copied from interface: ProcessContextListener

Notifies that a ProcessState is created.

This will be invoked by the same Thread creating the ProcessState.

Specified by:
processCreated in interface ProcessContextListener
Parameters:
processIdentifier - ProcessState identifier.

processCompleted

public void processCompleted(Object processIdentifier)
Description copied from interface: ProcessContextListener
Notifies that the ProcessState is completed.

Specified by:
processCompleted in interface ProcessContextListener
Parameters:
processIdentifier - ProcessState identifier.


Copyright © 2005-2013. All Rights Reserved.