Interface Executive
-
- All Known Implementing Classes:
DefaultExecutive
,GoogleAppEngineExecutive
,WebThreadAffinityExecutive
public interface Executive
Executive.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.concurrent.Executor
createExecutor(ProcessIdentifier processIdentifier)
Creates anExecutor
that MUST execute theRunnable
in a differentThread
to the caller.default ProcessIdentifier
createProcessIdentifier(ExecutiveOfficeContext officeContext)
Creates a newProcessIdentifier
.default java.lang.Thread
createThread(java.lang.String threadName, java.lang.ThreadGroup threadGroup, java.lang.Runnable runnable)
Creates aThread
.ExecutionStrategy[]
getExcutionStrategies()
Obtains theExecutionStrategy
strategies.default OfficeManager
getOfficeManager(ProcessIdentifier processIdentifier, OfficeManager defaultOfficeManager)
Obtains theOfficeManager
for theProcessState
.default TeamOversight
getTeamOversight()
Obtains theTeamOversight
.default <T extends java.lang.Throwable>
ProcessManagermanageExecution(Execution<T> execution)
Manages theExecution
.default void
processComplete(ProcessIdentifier processIdentifier)
Invokes to notify theProcessState
identified by theProcessIdentifier
is complete.void
schedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)
Schedules theRunnable
to execute so many milliseconds in the future.void
startManaging(ExecutiveStartContext context)
Starts managing theOfficeFloor
.void
stopManaging()
Stops managing theOfficeFloor
.
-
-
-
Method Detail
-
createThread
default java.lang.Thread createThread(java.lang.String threadName, java.lang.ThreadGroup threadGroup, java.lang.Runnable runnable)
Creates aThread
.- Returns:
- New
Thread
.
-
getExcutionStrategies
ExecutionStrategy[] getExcutionStrategies()
Obtains theExecutionStrategy
strategies.- Returns:
ExecutionStrategy
instances.
-
getTeamOversight
default TeamOversight getTeamOversight()
Obtains theTeamOversight
.- Returns:
TeamOversight
.
-
startManaging
void startManaging(ExecutiveStartContext context) throws java.lang.Exception
Starts managing theOfficeFloor
.- Parameters:
context
-ExecutiveStartContext
.- Throws:
java.lang.Exception
- If fails to start managing.
-
manageExecution
default <T extends java.lang.Throwable> ProcessManager manageExecution(Execution<T> execution) throws T extends java.lang.Throwable
Manages the
Execution
.The
Thread.currentThread()
will provide the inboundThread
.- Type Parameters:
T
- Type ofThrowable
thrown.- Parameters:
execution
-Execution
to be undertaken.- Returns:
ProcessManager
for theProcessState
.- Throws:
T
- Propagation of failure fromExecution
.T extends java.lang.Throwable
-
createProcessIdentifier
default ProcessIdentifier createProcessIdentifier(ExecutiveOfficeContext officeContext)
Creates a newProcessIdentifier
.- Parameters:
officeContext
-ExecutiveOfficeContext
.- Returns:
- New
ProcessIdentifier
.
-
getOfficeManager
default OfficeManager getOfficeManager(ProcessIdentifier processIdentifier, OfficeManager defaultOfficeManager)
Obtains theOfficeManager
for theProcessState
.- Parameters:
processIdentifier
-ProcessIdentifier
created by thisExecutive
for theProcessState
.defaultOfficeManager
- DefaultOfficeManager
.- Returns:
OfficeManager
for theProcessState
.
-
createExecutor
java.util.concurrent.Executor createExecutor(ProcessIdentifier processIdentifier)
Creates an
Executor
that MUST execute theRunnable
in a differentThread
to the caller.This is used in various places within
OfficeFloor
:- By
ManagedFunction
in executingRunnable
in anotherThread
- To avoid stack over flow issues, the stack call chain is broken by
invoking further
FunctionState
delegation in anotherThread
. This allows further depth to a thread stack than offered by a singleThread
.
- Parameters:
processIdentifier
-ProcessIdentifier
ofProcessState
requiring theExecutor
.- Returns:
Executor
that will executeRunnable
instances in a differentThread
to caller.
- By
-
schedule
void schedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)
Schedules the
Runnable
to execute so many milliseconds in the future.Note that the
Executive
may determine theProcessState
complete and not execute theRunnable
.- Parameters:
processIdentifier
-ProcessIdentifier
of theProcessState
requiring the scheduled execution.delay
- Delay in milliseconds to execute theRunnable
.runnable
-Runnable
to execute.
-
processComplete
default void processComplete(ProcessIdentifier processIdentifier)
Invokes to notify theProcessState
identified by theProcessIdentifier
is complete.- Parameters:
processIdentifier
-ProcessIdentifier
of the completeProcessState
.
-
stopManaging
void stopManaging() throws java.lang.Exception
Stops managing theOfficeFloor
.- Throws:
java.lang.Exception
- If fails to stop managing.
-
-