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.StringEXECUTION_STRATEGY_NAMEDefaultExecutionStrategyname.
-
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 ExecutivecreateExecutive(ExecutiveSourceContext context)Creates theExecutive.java.util.concurrent.ExecutorcreateExecutor(ProcessIdentifier processIdentifier)Creates anExecutorthat MUST execute theRunnablein a differentThreadto the caller.ExecutionStrategy[]getExcutionStrategies()Obtains theExecutionStrategystrategies.java.util.Map<java.lang.String,java.util.concurrent.ThreadFactory[]>getExecutionStrategyMap()Obtains theExecutionStrategyinstances by name.java.lang.StringgetExecutionStrategyName()Obtains the name of theExecutionStrategy.java.util.concurrent.ThreadFactory[]getThreadFactories()protected voidloadSpecification(AbstractExecutiveSource.SpecificationContext context)Overridden to load specification.voidschedule(long delay, java.lang.Runnable runnable)Schedules theRunnableto be executed after the delay.voidschedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)Schedules theRunnableto execute so many milliseconds in the future.voidstartManaging(ExecutiveStartContext context)Starts managing theOfficeFloor.voidstopManaging()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
DefaultExecutionStrategyname.- 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 theExecutionStrategyinstances by name.- Returns:
ExecutionStrategyinstances by name.
-
loadSpecification
protected void loadSpecification(AbstractExecutiveSource.SpecificationContext context)
Description copied from class:AbstractExecutiveSourceOverridden to load specification.- Specified by:
loadSpecificationin classAbstractExecutiveSource- Parameters:
context-AbstractExecutiveSource.SpecificationContext.
-
createExecutive
public Executive createExecutive(ExecutiveSourceContext context) throws java.lang.Exception
Description copied from interface:ExecutiveSourceCreates theExecutive.- Specified by:
createExecutivein interfaceExecutiveSource- Parameters:
context-ExecutiveSourceContext.- Returns:
Executive.- Throws:
java.lang.Exception- If fails to configure theExecutiveSource.
-
getExcutionStrategies
public ExecutionStrategy[] getExcutionStrategies()
Description copied from interface:ExecutiveObtains theExecutionStrategystrategies.- Specified by:
getExcutionStrategiesin interfaceExecutive- Returns:
ExecutionStrategyinstances.
-
startManaging
public void startManaging(ExecutiveStartContext context) throws java.lang.Exception
Description copied from interface:ExecutiveStarts managing theOfficeFloor.- Specified by:
startManagingin 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:ExecutiveCreates an
Executorthat MUST execute theRunnablein a differentThreadto the caller.This is used in various places within
OfficeFloor:- By
ManagedFunctionin executingRunnablein anotherThread - To avoid stack over flow issues, the stack call chain is broken by
invoking further
FunctionStatedelegation in anotherThread. This allows further depth to a thread stack than offered by a singleThread.
- Specified by:
createExecutorin interfaceExecutive- Parameters:
processIdentifier-ProcessIdentifierofProcessStaterequiring theExecutor.- Returns:
Executorthat will executeRunnableinstances in a differentThreadto caller.
- By
-
schedule
public void schedule(ProcessIdentifier processIdentifier, long delay, java.lang.Runnable runnable)
Description copied from interface:ExecutiveSchedules the
Runnableto execute so many milliseconds in the future.Note that the
Executivemay determine theProcessStatecomplete and not execute theRunnable.- Specified by:
schedulein interfaceExecutive- Parameters:
processIdentifier-ProcessIdentifierof theProcessStaterequiring the scheduled execution.delay- Delay in milliseconds to execute theRunnable.runnable-Runnableto execute.
-
stopManaging
public void stopManaging() throws java.lang.ExceptionDescription copied from interface:ExecutiveStops managing theOfficeFloor.- Specified by:
stopManagingin interfaceExecutive- Throws:
java.lang.Exception- If fails to stop managing.
-
schedule
public void schedule(long delay, java.lang.Runnable runnable)Description copied from interface:BackgroundSchedulerSchedules theRunnableto be executed after the delay.- Specified by:
schedulein interfaceBackgroundScheduler- Parameters:
delay- Delay in milliseconds.runnable-Runnable.
-
getExecutionStrategyName
public java.lang.String getExecutionStrategyName()
Description copied from interface:ExecutionStrategyObtains the name of theExecutionStrategy.- Specified by:
getExecutionStrategyNamein interfaceExecutionStrategy- Returns:
- Name of the
ExecutionStrategy.
-
getThreadFactories
public java.util.concurrent.ThreadFactory[] getThreadFactories()
Description copied from interface:ExecutionStrategy- Specified by:
getThreadFactoriesin interfaceExecutionStrategy- Returns:
ThreadFactoryinstances.
-
-