Class OfficeBuilderImpl
- java.lang.Object
-
- net.officefloor.frame.impl.construct.office.OfficeBuilderImpl
-
- All Implemented Interfaces:
OfficeBuilder
,OfficeConfiguration
public class OfficeBuilderImpl extends java.lang.Object implements OfficeBuilder, OfficeConfiguration
Implements theOfficeBuilder
.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description OfficeBuilderImpl(java.lang.String officeName)
Initiate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEscalation(java.lang.Class<? extends java.lang.Throwable> typeOfCause, java.lang.String functionName)
Adds anEscalationFlow
for issues not handled within theOffice
.<E,F extends java.lang.Enum<F>>
GovernanceBuilder<F>addGovernance(java.lang.String governanceName, java.lang.Class<E> extensionInterface, GovernanceFactory<? super E,F> governanceFactory)
AddsGovernance
within theOffice
.<O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>
ManagedFunctionBuilder<O,F>addManagedFunction(java.lang.String functionName, ManagedFunctionFactory<O,F> mangedFunctionFactory)
Adds aManagedFunction
to be executed within theOffice
.void
addOfficeEnhancer(OfficeEnhancer officeEnhancer)
AddsOfficeEnhancer
for thisOffice
.ThreadDependencyMappingBuilder
addProcessManagedObject(java.lang.String processManagedObjectName, java.lang.String officeManagedObjectName)
void
addStartupFunction(java.lang.String functionName, java.lang.Object parameter)
Adds aManagedFunction
to invoke on start up of theOffice
.ThreadDependencyMappingBuilder
addThreadManagedObject(java.lang.String threadManagedObjectName, java.lang.String officeManagedObjectName)
void
addThreadSynchroniser(ThreadSynchroniserFactory threadSynchroniserFactory)
BoundInputManagedObjectConfiguration[]
getBoundInputManagedObjectConfiguration()
Obtains the configuration of theManagedObjectSource
to be bound for the inputManagedObject
.OfficeBuilder
getBuilder()
Obtains theOfficeBuilder
for thisOffice
.long
getDefaultAsynchronousFlowTimeout()
Obtains the defaultAsynchronousFlow
timeout forAsynchronousFlow
instances instigated by theOffice
.EscalationConfiguration[]
getEscalationConfiguration()
Obtains theEscalationConfiguration
instances for theOffice
.FlowBuilder<?>
getFlowBuilder(java.lang.String namespace, java.lang.String functionName)
Obtains aFunctionBuilder
registered with thisOfficeBuilder
.GovernanceConfiguration<?,?>[]
getGovernanceConfiguration()
Obtains theGovernanceConfiguration
.ManagedFunctionConfiguration<?,?>[]
getManagedFunctionConfiguration()
Obtains the configuration for theManagedFunction
instances.int
getMaximumFunctionStateChainLength()
Obtains the maximumFunctionState
chain length.MonitorClock
getMonitorClock()
Obtains theMonitorClock
.long
getMonitorOfficeInterval()
Obtains the interval in milli-seconds between each time theOfficeManager
monitors theOffice
.static java.lang.String
getNamespacedName(java.lang.String namespace, java.lang.String name)
Obtains the name with the added namespace.java.lang.String
getOfficeDefaultTeamName()
OfficeEnhancer[]
getOfficeEnhancers()
Obtains theOfficeEnhancer
instances for thisOffice
.java.lang.String
getOfficeName()
Obtains the name of thisOffice
.ManagedObjectConfiguration<?>[]
getProcessManagedObjectConfiguration()
Profiler
getProfiler()
LinkedManagedObjectSourceConfiguration[]
getRegisteredManagedObjectSources()
Obtains the links to theOfficeFloor
ManagedObjectSource
instances.LinkedTeamConfiguration[]
getRegisteredTeams()
Obtains the links to theOfficeFloor
Team
instances.ManagedFunctionInvocation[]
getStartupFunctions()
Obtains the list ofManagedFunctionInvocation
instances referencing theManagedFunction
instances to invoke onOffice
start up.ManagedObjectConfiguration<?>[]
getThreadManagedObjectConfiguration()
ThreadSynchroniserFactory[]
getThreadSynchronisers()
Obtains theThreadSynchroniserFactory
instances to synchronise theThreadLocal
state betweenTeam
instances.boolean
isManuallyManageGovernance()
Indicates if manually managingGovernance
viaAdministration
.void
registerManagedObjectSource(java.lang.String officeManagedObjectName, java.lang.String officeFloorManagedObjectSourceName)
Registers theManagedObject
within thisOffice
.void
registerTeam(java.lang.String officeTeamName, java.lang.String officeFloorTeamName)
void
setBoundInputManagedObject(java.lang.String inputManagedObjectName, java.lang.String managedObjectSourceName)
Specifies the inputManagedObject
to be bound to theProcessState
should there be multiple instances and it was not input.void
setDefaultAsynchronousFlowTimeout(long timeout)
Specifies the default timeout forAsynchronousFlow
instances.void
setDefaultTeam(java.lang.String officeTeamName)
void
setManuallyManageGovernance(boolean isManuallyManageGovernance)
Flags whether to manually manageGovernance
viaAdministration
instances.void
setMaximumFunctionStateChainLength(int maximumFunctionStateChainLength)
Specifies the maximumFunctionState
chain length.void
setMonitorClock(MonitorClock clock)
Allows providing anMonitorClock
implementation to obtain the current time.void
setMonitorOfficeInterval(long monitorOfficeInterval)
Specifies the interval in milli-seconds between each time theOfficeManager
monitors theOffice
.void
setProfiler(Profiler profiler)
-
-
-
Constructor Detail
-
OfficeBuilderImpl
public OfficeBuilderImpl(java.lang.String officeName)
Initiate.- Parameters:
officeName
- Name of thisOffice
.
-
-
Method Detail
-
getNamespacedName
public static java.lang.String getNamespacedName(java.lang.String namespace, java.lang.String name)
Obtains the name with the added namespace.- Parameters:
namespace
- Namespace.name
- Name.- Returns:
- Name within the namespace.
-
setMonitorClock
public void setMonitorClock(MonitorClock clock)
Description copied from interface:OfficeBuilder
Allows providing an
MonitorClock
implementation to obtain the current time.Should no
MonitorClock
be provided, a default implementation will be used.Typically this is useful in testing to fix to a deterministic time. However, should there be native implementations of keeping time that is efficient, this enables overriding the default implementation.
- Specified by:
setMonitorClock
in interfaceOfficeBuilder
- Parameters:
clock
-MonitorClock
.
-
setMonitorOfficeInterval
public void setMonitorOfficeInterval(long monitorOfficeInterval)
Description copied from interface:OfficeBuilder
Specifies the interval in milli-seconds between each time theOfficeManager
monitors theOffice
.- Specified by:
setMonitorOfficeInterval
in interfaceOfficeBuilder
- Parameters:
monitorOfficeInterval
- Interval in milli-seconds between each time theOfficeManager
monitors theOffice
.
-
setMaximumFunctionStateChainLength
public void setMaximumFunctionStateChainLength(int maximumFunctionStateChainLength)
Description copied from interface:OfficeBuilder
Specifies the maximum
FunctionState
chain length.This value is a trade off between limiting
Thread
stack calls and performance. Setting this value low runs the risk ofStackOverflowError
occurring in having recursively call into theFunctionState
chain. Setting this value high, has moreThread
overheads in breaking the recursive chain, slowing performance.- Specified by:
setMaximumFunctionStateChainLength
in interfaceOfficeBuilder
- Parameters:
maximumFunctionStateChainLength
- MaximumFunctionState
chain length.
-
setDefaultAsynchronousFlowTimeout
public void setDefaultAsynchronousFlowTimeout(long timeout)
Description copied from interface:OfficeBuilder
Specifies the default timeout forAsynchronousFlow
instances.- Specified by:
setDefaultAsynchronousFlowTimeout
in interfaceOfficeBuilder
- Parameters:
timeout
- Default timeout.
-
registerTeam
public void registerTeam(java.lang.String officeTeamName, java.lang.String officeFloorTeamName)
Description copied from interface:OfficeBuilder
- Specified by:
registerTeam
in interfaceOfficeBuilder
- Parameters:
officeTeamName
- Name of theTeam
to be referenced locally by thisOffice
.officeFloorTeamName
- Name of theTeam
within theOfficeFloor
.
-
setDefaultTeam
public void setDefaultTeam(java.lang.String officeTeamName)
Description copied from interface:OfficeBuilder
- Specified by:
setDefaultTeam
in interfaceOfficeBuilder
- Parameters:
officeTeamName
- Name of theTeam
within thisOffice
to use as defaultTeam
.
-
registerManagedObjectSource
public void registerManagedObjectSource(java.lang.String officeManagedObjectName, java.lang.String officeFloorManagedObjectSourceName)
Description copied from interface:OfficeBuilder
Registers theManagedObject
within thisOffice
.- Specified by:
registerManagedObjectSource
in interfaceOfficeBuilder
- Parameters:
officeManagedObjectName
- Name of theManagedObject
to be referenced locally by thisOffice
.officeFloorManagedObjectSourceName
- Name of theManagedObjectSource
within theOfficeFloor
.
-
setBoundInputManagedObject
public void setBoundInputManagedObject(java.lang.String inputManagedObjectName, java.lang.String managedObjectSourceName)
Description copied from interface:OfficeBuilder
Specifies the inputManagedObject
to be bound to theProcessState
should there be multiple instances and it was not input.- Specified by:
setBoundInputManagedObject
in interfaceOfficeBuilder
- Parameters:
inputManagedObjectName
- InputManagedObject
name.managedObjectSourceName
-ManagedObjectSource
name.
-
addThreadManagedObject
public ThreadDependencyMappingBuilder addThreadManagedObject(java.lang.String threadManagedObjectName, java.lang.String officeManagedObjectName)
Description copied from interface:OfficeBuilder
Adds a
ThreadState
boundManagedObject
to thisOffice
.Dependency scope:
- Other
ManagedObject
instances added via this method. ProcessState
boundManagedObject
instances.
- Specified by:
addThreadManagedObject
in interfaceOfficeBuilder
- Parameters:
threadManagedObjectName
- Name to link theManagedObject
forManagedFunction
instances.officeManagedObjectName
- Name of theManagedObject
registered within thisOffice
.- Returns:
ThreadDependencyMappingBuilder
to build any necessary dependencies for theManagedObject
. See scope above.
- Other
-
addProcessManagedObject
public ThreadDependencyMappingBuilder addProcessManagedObject(java.lang.String processManagedObjectName, java.lang.String officeManagedObjectName)
Description copied from interface:OfficeBuilder
Adds a
ProcessState
boundManagedObject
to thisOffice
.Dependency scope:
- Other
ManagedObject
instances added via this method.
- Specified by:
addProcessManagedObject
in interfaceOfficeBuilder
- Parameters:
processManagedObjectName
- Name to link theManagedObject
forManagedFunction
instances.officeManagedObjectName
- Name of theManagedObject
registered within thisOffice
.- Returns:
ThreadDependencyMappingBuilder
to build any necessary dependencies for theManagedObject
. See scope above.
- Other
-
setManuallyManageGovernance
public void setManuallyManageGovernance(boolean isManuallyManageGovernance)
Description copied from interface:OfficeBuilder
Flags whether to manually manageGovernance
viaAdministration
instances.- Specified by:
setManuallyManageGovernance
in interfaceOfficeBuilder
- Parameters:
isManuallyManageGovernance
-true
to manually manageGovernance
viaAdministration
instances.
-
addGovernance
public <E,F extends java.lang.Enum<F>> GovernanceBuilder<F> addGovernance(java.lang.String governanceName, java.lang.Class<E> extensionInterface, GovernanceFactory<? super E,F> governanceFactory)
Description copied from interface:OfficeBuilder
AddsGovernance
within theOffice
.- Specified by:
addGovernance
in interfaceOfficeBuilder
- Type Parameters:
E
- Extension interface type.F
- Flow key type.- Parameters:
governanceName
- Name of theGovernance
to be referenced locally by thisOffice
.extensionInterface
- Extension interface.governanceFactory
-GovernanceFactory
class.- Returns:
GovernanceBuilder
.
-
addManagedFunction
public <O extends java.lang.Enum<O>,F extends java.lang.Enum<F>> ManagedFunctionBuilder<O,F> addManagedFunction(java.lang.String functionName, ManagedFunctionFactory<O,F> mangedFunctionFactory)
Description copied from interface:OfficeBuilder
Adds aManagedFunction
to be executed within theOffice
.- Specified by:
addManagedFunction
in interfaceOfficeBuilder
- Type Parameters:
O
- Dependency key type.F
- Flow key type.- Parameters:
functionName
- Name of theManagedFunction
.mangedFunctionFactory
-ManagedFunctionFactory
to create theManagedFunction
.- Returns:
ManagedFunctionBuilder
for theManagedFunction
.
-
addOfficeEnhancer
public void addOfficeEnhancer(OfficeEnhancer officeEnhancer)
Description copied from interface:OfficeBuilder
Adds
OfficeEnhancer
for thisOffice
.This enables enhancing the
Office
after theManagedObjectSource
instances are registered.- Specified by:
addOfficeEnhancer
in interfaceOfficeBuilder
- Parameters:
officeEnhancer
-OfficeEnhancer
.
-
addEscalation
public void addEscalation(java.lang.Class<? extends java.lang.Throwable> typeOfCause, java.lang.String functionName)
Description copied from interface:OfficeBuilder
Adds anEscalationFlow
for issues not handled within theOffice
.- Specified by:
addEscalation
in interfaceOfficeBuilder
- Parameters:
typeOfCause
- Type of cause handled by thisEscalationFlow
.functionName
- Name ofManagedFunction
to handle theEscalationFlow
.
-
addStartupFunction
public void addStartupFunction(java.lang.String functionName, java.lang.Object parameter)
Description copied from interface:OfficeBuilder
Adds aManagedFunction
to invoke on start up of theOffice
.- Specified by:
addStartupFunction
in interfaceOfficeBuilder
- Parameters:
functionName
- Name ofManagedFunction
.parameter
- Parameter value to be passed to theManagedFunction
. May benull
.
-
setProfiler
public void setProfiler(Profiler profiler)
Description copied from interface:OfficeBuilder
- Specified by:
setProfiler
in interfaceOfficeBuilder
- Parameters:
profiler
-Profiler
.
-
addThreadSynchroniser
public void addThreadSynchroniser(ThreadSynchroniserFactory threadSynchroniserFactory)
Description copied from interface:OfficeBuilder
- Specified by:
addThreadSynchroniser
in interfaceOfficeBuilder
- Parameters:
threadSynchroniserFactory
-ThreadSynchroniserFactory
to create theThreadSynchroniser
.
-
getOfficeName
public java.lang.String getOfficeName()
Description copied from interface:OfficeConfiguration
Obtains the name of thisOffice
.- Specified by:
getOfficeName
in interfaceOfficeConfiguration
- Returns:
- Name of this
Office
.
-
getMonitorClock
public MonitorClock getMonitorClock()
Description copied from interface:OfficeConfiguration
Obtains theMonitorClock
.- Specified by:
getMonitorClock
in interfaceOfficeConfiguration
- Returns:
MonitorClock
. May benull
to use a default implementation.
-
getMonitorOfficeInterval
public long getMonitorOfficeInterval()
Description copied from interface:OfficeConfiguration
Obtains the interval in milli-seconds between each time theOfficeManager
monitors theOffice
.- Specified by:
getMonitorOfficeInterval
in interfaceOfficeConfiguration
- Returns:
- Interval in milli-seconds between each time the
OfficeManager
monitors theOffice
.
-
getMaximumFunctionStateChainLength
public int getMaximumFunctionStateChainLength()
Description copied from interface:OfficeConfiguration
Obtains the maximumFunctionState
chain length.- Specified by:
getMaximumFunctionStateChainLength
in interfaceOfficeConfiguration
- Returns:
- Maximum
FunctionState
chain length.
-
getBuilder
public OfficeBuilder getBuilder()
Description copied from interface:OfficeConfiguration
Obtains the
OfficeBuilder
for thisOffice
.This is to allow
Asset
instances (such as aManagedObjectSource
) to provide additional configuration for theOffice
.- Specified by:
getBuilder
in interfaceOfficeConfiguration
- Returns:
OfficeBuilder
.
-
getRegisteredTeams
public LinkedTeamConfiguration[] getRegisteredTeams()
Description copied from interface:OfficeConfiguration
Obtains the links to theOfficeFloor
Team
instances.- Specified by:
getRegisteredTeams
in interfaceOfficeConfiguration
- Returns:
- Links to the
OfficeFloor
Team
instances.
-
getOfficeDefaultTeamName
public java.lang.String getOfficeDefaultTeamName()
Description copied from interface:OfficeConfiguration
- Specified by:
getOfficeDefaultTeamName
in interfaceOfficeConfiguration
- Returns:
- Default
Team
name for theOffice
. May benull
to use anyTeam
(typically the invokingThread
).
-
getRegisteredManagedObjectSources
public LinkedManagedObjectSourceConfiguration[] getRegisteredManagedObjectSources()
Description copied from interface:OfficeConfiguration
Obtains the links to theOfficeFloor
ManagedObjectSource
instances.- Specified by:
getRegisteredManagedObjectSources
in interfaceOfficeConfiguration
- Returns:
- Links to the
OfficeFloor
ManagedObjectSource
instances.
-
getBoundInputManagedObjectConfiguration
public BoundInputManagedObjectConfiguration[] getBoundInputManagedObjectConfiguration()
Description copied from interface:OfficeConfiguration
Obtains the configuration of theManagedObjectSource
to be bound for the inputManagedObject
.- Specified by:
getBoundInputManagedObjectConfiguration
in interfaceOfficeConfiguration
- Returns:
- Configuration of the
ManagedObjectSource
to be bound for the inputManagedObject
.
-
getProcessManagedObjectConfiguration
public ManagedObjectConfiguration<?>[] getProcessManagedObjectConfiguration()
Description copied from interface:OfficeConfiguration
- Specified by:
getProcessManagedObjectConfiguration
in interfaceOfficeConfiguration
- Returns:
- Listing of the configuration of the
ManagedObject
instances bound to theProcessState
.
-
getThreadManagedObjectConfiguration
public ManagedObjectConfiguration<?>[] getThreadManagedObjectConfiguration()
Description copied from interface:OfficeConfiguration
- Specified by:
getThreadManagedObjectConfiguration
in interfaceOfficeConfiguration
- Returns:
- Listing of the configuration of the
ManagedObject
instances bound to theThreadState
.
-
isManuallyManageGovernance
public boolean isManuallyManageGovernance()
Description copied from interface:OfficeConfiguration
Indicates if manually managingGovernance
viaAdministration
.- Specified by:
isManuallyManageGovernance
in interfaceOfficeConfiguration
- Returns:
true
to manually managedGovernance
.
-
getGovernanceConfiguration
public GovernanceConfiguration<?,?>[] getGovernanceConfiguration()
Description copied from interface:OfficeConfiguration
Obtains theGovernanceConfiguration
.- Specified by:
getGovernanceConfiguration
in interfaceOfficeConfiguration
- Returns:
GovernanceConfiguration
.
-
getManagedFunctionConfiguration
public ManagedFunctionConfiguration<?,?>[] getManagedFunctionConfiguration()
Description copied from interface:OfficeConfiguration
Obtains the configuration for theManagedFunction
instances.- Specified by:
getManagedFunctionConfiguration
in interfaceOfficeConfiguration
- Returns:
- Configuration for the
ManagedFunction
instances.
-
getOfficeEnhancers
public OfficeEnhancer[] getOfficeEnhancers()
Description copied from interface:OfficeConfiguration
Obtains theOfficeEnhancer
instances for thisOffice
.- Specified by:
getOfficeEnhancers
in interfaceOfficeConfiguration
- Returns:
- Listing of the
OfficeEnhancer
for thisOffice
.
-
getEscalationConfiguration
public EscalationConfiguration[] getEscalationConfiguration()
Description copied from interface:OfficeConfiguration
Obtains theEscalationConfiguration
instances for theOffice
.- Specified by:
getEscalationConfiguration
in interfaceOfficeConfiguration
- Returns:
EscalationConfiguration
instances for theOffice
.
-
getFlowBuilder
public FlowBuilder<?> getFlowBuilder(java.lang.String namespace, java.lang.String functionName)
Description copied from interface:OfficeConfiguration
Obtains a
FunctionBuilder
registered with thisOfficeBuilder
.This enables addition configuration of
ManagedFunction
instances registered by aManagedObjectSource
.- Specified by:
getFlowBuilder
in interfaceOfficeConfiguration
- Parameters:
namespace
- Namespace. Likely theManagedObjectSource
name.functionName
- Name of theManagedFunction
.- Returns:
FlowBuilder
for theManagedFunction
.
-
getStartupFunctions
public ManagedFunctionInvocation[] getStartupFunctions()
Description copied from interface:OfficeConfiguration
Obtains the list ofManagedFunctionInvocation
instances referencing theManagedFunction
instances to invoke onOffice
start up.- Specified by:
getStartupFunctions
in interfaceOfficeConfiguration
- Returns:
- List of start up
ManagedFunctionInvocation
references.
-
getProfiler
public Profiler getProfiler()
Description copied from interface:OfficeConfiguration
- Specified by:
getProfiler
in interfaceOfficeConfiguration
- Returns:
Profiler
for theOffice
.
-
getThreadSynchronisers
public ThreadSynchroniserFactory[] getThreadSynchronisers()
Description copied from interface:OfficeConfiguration
Obtains theThreadSynchroniserFactory
instances to synchronise theThreadLocal
state betweenTeam
instances.- Specified by:
getThreadSynchronisers
in interfaceOfficeConfiguration
- Returns:
ThreadSynchroniserFactory
instances.
-
getDefaultAsynchronousFlowTimeout
public long getDefaultAsynchronousFlowTimeout()
Description copied from interface:OfficeConfiguration
Obtains the defaultAsynchronousFlow
timeout forAsynchronousFlow
instances instigated by theOffice
.- Specified by:
getDefaultAsynchronousFlowTimeout
in interfaceOfficeConfiguration
- Returns:
- Default
AsynchronousFlow
timeout forAsynchronousFlow
instances instigated by theOffice
.
-
-