Class DefaultExecutive
- java.lang.Object
-
- net.officefloor.frame.api.executive.source.impl.AbstractExecutiveSource
-
- net.officefloor.frame.impl.execute.executive.DefaultExecutive
-
- All Implemented Interfaces:
BackgroundScheduler
,ExecutionStrategy
,Executive
,ExecutiveSource
public class DefaultExecutive extends AbstractExecutiveSource implements Executive, ExecutionStrategy, BackgroundScheduler
DefaultExecutive
.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.officefloor.frame.api.executive.source.impl.AbstractExecutiveSource
AbstractExecutiveSource.SpecificationContext
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
EXECUTION_STRATEGY_NAME
DefaultExecutionStrategy
name.
-
Constructor Summary
Constructors Constructor Description DefaultExecutive()
Default construct to be used asExecutiveSource
.DefaultExecutive(ThreadFactoryManufacturer threadFactoryManufacturer)
Instantiate to use asExecutive
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Executive
createExecutive(ExecutiveSourceContext context)
Creates theExecutive
.java.util.concurrent.Executor
createExecutor(ProcessIdentifier processIdentifier)
Creates anExecutor
that MUST execute theRunnable
in a differentThread
to the caller.ExecutionStrategy[]
getExcutionStrategies()
Obtains theExecutionStrategy
strategies.java.util.Map<java.lang.String,java.util.concurrent.ThreadFactory[]>
getExecutionStrategyMap()
Obtains theExecutionStrategy
instances by name.java.lang.String
getExecutionStrategyName()
Obtains the name of theExecutionStrategy
.java.util.concurrent.ThreadFactory[]
getThreadFactories()
protected void
loadSpecification(AbstractExecutiveSource.SpecificationContext context)
Overridden to load specification.void
schedule(long delay, java.lang.Runnable runnable)
Schedules theRunnable
to be executed after the delay.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
.-
Methods inherited from class net.officefloor.frame.api.executive.source.impl.AbstractExecutiveSource
getSpecification
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.officefloor.frame.api.executive.Executive
createProcessIdentifier, createThread, getOfficeManager, getTeamOversight, manageExecution, processComplete
-
-
-
-
Field Detail
-
EXECUTION_STRATEGY_NAME
public static final java.lang.String EXECUTION_STRATEGY_NAME
DefaultExecutionStrategy
name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultExecutive
public DefaultExecutive()
Default construct to be used asExecutiveSource
.
-
DefaultExecutive
public DefaultExecutive(ThreadFactoryManufacturer threadFactoryManufacturer)
Instantiate to use asExecutive
.- Parameters:
threadFactoryManufacturer
-ThreadFactoryManufacturer
.
-
-
Method Detail
-
getExecutionStrategyMap
public java.util.Map<java.lang.String,java.util.concurrent.ThreadFactory[]> getExecutionStrategyMap()
Obtains theExecutionStrategy
instances by name.- Returns:
ExecutionStrategy
instances by name.
-
loadSpecification
protected void loadSpecification(AbstractExecutiveSource.SpecificationContext context)
Description copied from class:AbstractExecutiveSource
Overridden to load specification.- Specified by:
loadSpecification
in classAbstractExecutiveSource
- Parameters:
context
-AbstractExecutiveSource.SpecificationContext
.
-
createExecutive
public Executive createExecutive(ExecutiveSourceContext context) throws java.lang.Exception
Description copied from interface:ExecutiveSource
Creates theExecutive
.- Specified by:
createExecutive
in interfaceExecutiveSource
- Parameters:
context
-ExecutiveSourceContext
.- Returns:
Executive
.- Throws:
java.lang.Exception
- If fails to configure theExecutiveSource
.
-
getExcutionStrategies
public ExecutionStrategy[] getExcutionStrategies()
Description copied from interface:Executive
Obtains theExecutionStrategy
strategies.- Specified by:
getExcutionStrategies
in interfaceExecutive
- Returns:
ExecutionStrategy
instances.
-
startManaging
public void startManaging(ExecutiveStartContext context) throws java.lang.Exception
Description copied from interface:Executive
Starts managing theOfficeFloor
.- Specified by:
startManaging
in interfaceExecutive
- Parameters:
context
-ExecutiveStartContext
.- Throws:
java.lang.Exception
- If fails to start managing.
-
createExecutor
public java.util.concurrent.Executor createExecutor(ProcessIdentifier processIdentifier)
Description copied from interface:Executive
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
.
- Specified by:
createExecutor
in interfaceExecutive
- Parameters:
processIdentifier
-ProcessIdentifier
ofProcessState
requiring theExecutor
.- Returns:
Executor
that will executeRunnable
instances in a differentThread
to caller.
- By
-
schedule
public void schedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)
Description copied from interface:Executive
Schedules the
Runnable
to execute so many milliseconds in the future.Note that the
Executive
may determine theProcessState
complete and not execute theRunnable
.- Specified by:
schedule
in interfaceExecutive
- Parameters:
processIdentifier
-ProcessIdentifier
of theProcessState
requiring the scheduled execution.delay
- Delay in milliseconds to execute theRunnable
.runnable
-Runnable
to execute.
-
stopManaging
public void stopManaging() throws java.lang.Exception
Description copied from interface:Executive
Stops managing theOfficeFloor
.- Specified by:
stopManaging
in interfaceExecutive
- Throws:
java.lang.Exception
- If fails to stop managing.
-
schedule
public void schedule(long delay, java.lang.Runnable runnable)
Description copied from interface:BackgroundScheduler
Schedules theRunnable
to be executed after the delay.- Specified by:
schedule
in interfaceBackgroundScheduler
- Parameters:
delay
- Delay in milliseconds.runnable
-Runnable
.
-
getExecutionStrategyName
public java.lang.String getExecutionStrategyName()
Description copied from interface:ExecutionStrategy
Obtains the name of theExecutionStrategy
.- Specified by:
getExecutionStrategyName
in interfaceExecutionStrategy
- Returns:
- Name of the
ExecutionStrategy
.
-
getThreadFactories
public java.util.concurrent.ThreadFactory[] getThreadFactories()
Description copied from interface:ExecutionStrategy
- Specified by:
getThreadFactories
in interfaceExecutionStrategy
- Returns:
ThreadFactory
instances.
-
-