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 voidaddEscalation(java.lang.Class<? extends java.lang.Throwable> typeOfCause, java.lang.String functionName)Adds anEscalationFlowfor 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)AddsGovernancewithin 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 aManagedFunctionto be executed within theOffice.voidaddOfficeEnhancer(OfficeEnhancer officeEnhancer)AddsOfficeEnhancerfor thisOffice.ThreadDependencyMappingBuilderaddProcessManagedObject(java.lang.String processManagedObjectName, java.lang.String officeManagedObjectName)voidaddStartupFunction(java.lang.String functionName)Adds aManagedFunctionto invoke on start up of theOffice.ThreadDependencyMappingBuilderaddThreadManagedObject(java.lang.String threadManagedObjectName, java.lang.String officeManagedObjectName)voidaddThreadSynchroniser(ThreadSynchroniserFactory threadSynchroniserFactory)BoundInputManagedObjectConfiguration[]getBoundInputManagedObjectConfiguration()Obtains the configuration of theManagedObjectSourceto be bound for the inputManagedObject.OfficeBuildergetBuilder()Obtains theOfficeBuilderfor thisOffice.longgetDefaultAsynchronousFlowTimeout()Obtains the defaultAsynchronousFlowtimeout forAsynchronousFlowinstances instigated by theOffice.EscalationConfiguration[]getEscalationConfiguration()Obtains theEscalationConfigurationinstances for theOffice.FlowBuilder<?>getFlowBuilder(java.lang.String namespace, java.lang.String functionName)Obtains aFunctionBuilderregistered with thisOfficeBuilder.GovernanceConfiguration<?,?>[]getGovernanceConfiguration()Obtains theGovernanceConfiguration.ManagedFunctionConfiguration<?,?>[]getManagedFunctionConfiguration()Obtains the configuration for theManagedFunctioninstances.intgetMaximumFunctionStateChainLength()Obtains the maximumFunctionStatechain length.MonitorClockgetMonitorClock()Obtains theMonitorClock.longgetMonitorOfficeInterval()Obtains the interval in milli-seconds between each time theOfficeManagermonitors theOffice.static java.lang.StringgetNamespacedName(java.lang.String namespace, java.lang.String name)Obtains the name with the added namespace.java.lang.StringgetOfficeDefaultTeamName()OfficeEnhancer[]getOfficeEnhancers()Obtains theOfficeEnhancerinstances for thisOffice.java.lang.StringgetOfficeName()Obtains the name of thisOffice.ManagedObjectConfiguration<?>[]getProcessManagedObjectConfiguration()ProfilergetProfiler()LinkedManagedObjectSourceConfiguration[]getRegisteredManagedObjectSources()Obtains the links to theOfficeFloorManagedObjectSourceinstances.LinkedTeamConfiguration[]getRegisteredTeams()Obtains the links to theOfficeFloorTeaminstances.ManagedFunctionReference[]getStartupFunctions()Obtains the list ofManagedFunctionReferenceinstances referencing theManagedFunctioninstances to invoke onOfficestart up.ManagedObjectConfiguration<?>[]getThreadManagedObjectConfiguration()ThreadSynchroniserFactory[]getThreadSynchronisers()Obtains theThreadSynchroniserFactoryinstances to synchronise theThreadLocalstate betweenTeaminstances.booleanisManuallyManageGovernance()Indicates if manually managingGovernanceviaAdministration.voidregisterManagedObjectSource(java.lang.String officeManagedObjectName, java.lang.String officeFloorManagedObjectSourceName)Registers theManagedObjectwithin thisOffice.voidregisterTeam(java.lang.String officeTeamName, java.lang.String officeFloorTeamName)voidsetBoundInputManagedObject(java.lang.String inputManagedObjectName, java.lang.String managedObjectSourceName)Specifies the inputManagedObjectto be bound to theProcessStateshould there be multiple instances and it was not input.voidsetDefaultAsynchronousFlowTimeout(long timeout)Specifies the default timeout forAsynchronousFlowinstances.voidsetDefaultTeam(java.lang.String officeTeamName)voidsetManuallyManageGovernance(boolean isManuallyManageGovernance)Flags whether to manually manageGovernanceviaAdministrationinstances.voidsetMaximumFunctionStateChainLength(int maximumFunctionStateChainLength)Specifies the maximumFunctionStatechain length.voidsetMonitorClock(MonitorClock clock)Allows providing anMonitorClockimplementation to obtain the current time.voidsetMonitorOfficeInterval(long monitorOfficeInterval)Specifies the interval in milli-seconds between each time theOfficeManagermonitors theOffice.voidsetProfiler(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:OfficeBuilderAllows providing an
MonitorClockimplementation to obtain the current time.Should no
MonitorClockbe 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:
setMonitorClockin interfaceOfficeBuilder- Parameters:
clock-MonitorClock.
-
setMonitorOfficeInterval
public void setMonitorOfficeInterval(long monitorOfficeInterval)
Description copied from interface:OfficeBuilderSpecifies the interval in milli-seconds between each time theOfficeManagermonitors theOffice.- Specified by:
setMonitorOfficeIntervalin interfaceOfficeBuilder- Parameters:
monitorOfficeInterval- Interval in milli-seconds between each time theOfficeManagermonitors theOffice.
-
setMaximumFunctionStateChainLength
public void setMaximumFunctionStateChainLength(int maximumFunctionStateChainLength)
Description copied from interface:OfficeBuilderSpecifies the maximum
FunctionStatechain length.This value is a trade off between limiting
Threadstack calls and performance. Setting this value low runs the risk ofStackOverflowErroroccurring in having recursively call into theFunctionStatechain. Setting this value high, has moreThreadoverheads in breaking the recursive chain, slowing performance.- Specified by:
setMaximumFunctionStateChainLengthin interfaceOfficeBuilder- Parameters:
maximumFunctionStateChainLength- MaximumFunctionStatechain length.
-
setDefaultAsynchronousFlowTimeout
public void setDefaultAsynchronousFlowTimeout(long timeout)
Description copied from interface:OfficeBuilderSpecifies the default timeout forAsynchronousFlowinstances.- Specified by:
setDefaultAsynchronousFlowTimeoutin interfaceOfficeBuilder- Parameters:
timeout- Default timeout.
-
registerTeam
public void registerTeam(java.lang.String officeTeamName, java.lang.String officeFloorTeamName)Description copied from interface:OfficeBuilder- Specified by:
registerTeamin interfaceOfficeBuilder- Parameters:
officeTeamName- Name of theTeamto be referenced locally by thisOffice.officeFloorTeamName- Name of theTeamwithin theOfficeFloor.
-
setDefaultTeam
public void setDefaultTeam(java.lang.String officeTeamName)
Description copied from interface:OfficeBuilder- Specified by:
setDefaultTeamin interfaceOfficeBuilder- Parameters:
officeTeamName- Name of theTeamwithin thisOfficeto use as defaultTeam.
-
registerManagedObjectSource
public void registerManagedObjectSource(java.lang.String officeManagedObjectName, java.lang.String officeFloorManagedObjectSourceName)Description copied from interface:OfficeBuilderRegisters theManagedObjectwithin thisOffice.- Specified by:
registerManagedObjectSourcein interfaceOfficeBuilder- Parameters:
officeManagedObjectName- Name of theManagedObjectto be referenced locally by thisOffice.officeFloorManagedObjectSourceName- Name of theManagedObjectSourcewithin theOfficeFloor.
-
setBoundInputManagedObject
public void setBoundInputManagedObject(java.lang.String inputManagedObjectName, java.lang.String managedObjectSourceName)Description copied from interface:OfficeBuilderSpecifies the inputManagedObjectto be bound to theProcessStateshould there be multiple instances and it was not input.- Specified by:
setBoundInputManagedObjectin interfaceOfficeBuilder- Parameters:
inputManagedObjectName- InputManagedObjectname.managedObjectSourceName-ManagedObjectSourcename.
-
addThreadManagedObject
public ThreadDependencyMappingBuilder addThreadManagedObject(java.lang.String threadManagedObjectName, java.lang.String officeManagedObjectName)
Description copied from interface:OfficeBuilderAdds a
ThreadStateboundManagedObjectto thisOffice.Dependency scope:
- Other
ManagedObjectinstances added via this method. ProcessStateboundManagedObjectinstances.
- Specified by:
addThreadManagedObjectin interfaceOfficeBuilder- Parameters:
threadManagedObjectName- Name to link theManagedObjectforManagedFunctioninstances.officeManagedObjectName- Name of theManagedObjectregistered within thisOffice.- Returns:
ThreadDependencyMappingBuilderto 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:OfficeBuilderAdds a
ProcessStateboundManagedObjectto thisOffice.Dependency scope:
- Other
ManagedObjectinstances added via this method.
- Specified by:
addProcessManagedObjectin interfaceOfficeBuilder- Parameters:
processManagedObjectName- Name to link theManagedObjectforManagedFunctioninstances.officeManagedObjectName- Name of theManagedObjectregistered within thisOffice.- Returns:
ThreadDependencyMappingBuilderto build any necessary dependencies for theManagedObject. See scope above.
- Other
-
setManuallyManageGovernance
public void setManuallyManageGovernance(boolean isManuallyManageGovernance)
Description copied from interface:OfficeBuilderFlags whether to manually manageGovernanceviaAdministrationinstances.- Specified by:
setManuallyManageGovernancein interfaceOfficeBuilder- Parameters:
isManuallyManageGovernance-trueto manually manageGovernanceviaAdministrationinstances.
-
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:OfficeBuilderAddsGovernancewithin theOffice.- Specified by:
addGovernancein interfaceOfficeBuilder- Type Parameters:
E- Extension interface type.F- Flow key type.- Parameters:
governanceName- Name of theGovernanceto be referenced locally by thisOffice.extensionInterface- Extension interface.governanceFactory-GovernanceFactoryclass.- 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:OfficeBuilderAdds aManagedFunctionto be executed within theOffice.- Specified by:
addManagedFunctionin interfaceOfficeBuilder- Type Parameters:
O- Dependency key type.F- Flow key type.- Parameters:
functionName- Name of theManagedFunction.mangedFunctionFactory-ManagedFunctionFactoryto create theManagedFunction.- Returns:
ManagedFunctionBuilderfor theManagedFunction.
-
addOfficeEnhancer
public void addOfficeEnhancer(OfficeEnhancer officeEnhancer)
Description copied from interface:OfficeBuilderAdds
OfficeEnhancerfor thisOffice.This enables enhancing the
Officeafter theManagedObjectSourceinstances are registered.- Specified by:
addOfficeEnhancerin interfaceOfficeBuilder- Parameters:
officeEnhancer-OfficeEnhancer.
-
addEscalation
public void addEscalation(java.lang.Class<? extends java.lang.Throwable> typeOfCause, java.lang.String functionName)Description copied from interface:OfficeBuilderAdds anEscalationFlowfor issues not handled within theOffice.- Specified by:
addEscalationin interfaceOfficeBuilder- Parameters:
typeOfCause- Type of cause handled by thisEscalationFlow.functionName- Name ofManagedFunctionto handle theEscalationFlow.
-
addStartupFunction
public void addStartupFunction(java.lang.String functionName)
Description copied from interface:OfficeBuilderAdds aManagedFunctionto invoke on start up of theOffice.- Specified by:
addStartupFunctionin interfaceOfficeBuilder- Parameters:
functionName- Name ofManagedFunction.
-
setProfiler
public void setProfiler(Profiler profiler)
Description copied from interface:OfficeBuilder- Specified by:
setProfilerin interfaceOfficeBuilder- Parameters:
profiler-Profiler.
-
addThreadSynchroniser
public void addThreadSynchroniser(ThreadSynchroniserFactory threadSynchroniserFactory)
Description copied from interface:OfficeBuilder- Specified by:
addThreadSynchroniserin interfaceOfficeBuilder- Parameters:
threadSynchroniserFactory-ThreadSynchroniserFactoryto create theThreadSynchroniser.
-
getOfficeName
public java.lang.String getOfficeName()
Description copied from interface:OfficeConfigurationObtains the name of thisOffice.- Specified by:
getOfficeNamein interfaceOfficeConfiguration- Returns:
- Name of this
Office.
-
getMonitorClock
public MonitorClock getMonitorClock()
Description copied from interface:OfficeConfigurationObtains theMonitorClock.- Specified by:
getMonitorClockin interfaceOfficeConfiguration- Returns:
MonitorClock. May benullto use a default implementation.
-
getMonitorOfficeInterval
public long getMonitorOfficeInterval()
Description copied from interface:OfficeConfigurationObtains the interval in milli-seconds between each time theOfficeManagermonitors theOffice.- Specified by:
getMonitorOfficeIntervalin interfaceOfficeConfiguration- Returns:
- Interval in milli-seconds between each time the
OfficeManagermonitors theOffice.
-
getMaximumFunctionStateChainLength
public int getMaximumFunctionStateChainLength()
Description copied from interface:OfficeConfigurationObtains the maximumFunctionStatechain length.- Specified by:
getMaximumFunctionStateChainLengthin interfaceOfficeConfiguration- Returns:
- Maximum
FunctionStatechain length.
-
getBuilder
public OfficeBuilder getBuilder()
Description copied from interface:OfficeConfigurationObtains the
OfficeBuilderfor thisOffice.This is to allow
Assetinstances (such as aManagedObjectSource) to provide additional configuration for theOffice.- Specified by:
getBuilderin interfaceOfficeConfiguration- Returns:
OfficeBuilder.
-
getRegisteredTeams
public LinkedTeamConfiguration[] getRegisteredTeams()
Description copied from interface:OfficeConfigurationObtains the links to theOfficeFloorTeaminstances.- Specified by:
getRegisteredTeamsin interfaceOfficeConfiguration- Returns:
- Links to the
OfficeFloorTeaminstances.
-
getOfficeDefaultTeamName
public java.lang.String getOfficeDefaultTeamName()
Description copied from interface:OfficeConfiguration- Specified by:
getOfficeDefaultTeamNamein interfaceOfficeConfiguration- Returns:
- Default
Teamname for theOffice. May benullto use anyTeam(typically the invokingThread).
-
getRegisteredManagedObjectSources
public LinkedManagedObjectSourceConfiguration[] getRegisteredManagedObjectSources()
Description copied from interface:OfficeConfigurationObtains the links to theOfficeFloorManagedObjectSourceinstances.- Specified by:
getRegisteredManagedObjectSourcesin interfaceOfficeConfiguration- Returns:
- Links to the
OfficeFloorManagedObjectSourceinstances.
-
getBoundInputManagedObjectConfiguration
public BoundInputManagedObjectConfiguration[] getBoundInputManagedObjectConfiguration()
Description copied from interface:OfficeConfigurationObtains the configuration of theManagedObjectSourceto be bound for the inputManagedObject.- Specified by:
getBoundInputManagedObjectConfigurationin interfaceOfficeConfiguration- Returns:
- Configuration of the
ManagedObjectSourceto be bound for the inputManagedObject.
-
getProcessManagedObjectConfiguration
public ManagedObjectConfiguration<?>[] getProcessManagedObjectConfiguration()
Description copied from interface:OfficeConfiguration- Specified by:
getProcessManagedObjectConfigurationin interfaceOfficeConfiguration- Returns:
- Listing of the configuration of the
ManagedObjectinstances bound to theProcessState.
-
getThreadManagedObjectConfiguration
public ManagedObjectConfiguration<?>[] getThreadManagedObjectConfiguration()
Description copied from interface:OfficeConfiguration- Specified by:
getThreadManagedObjectConfigurationin interfaceOfficeConfiguration- Returns:
- Listing of the configuration of the
ManagedObjectinstances bound to theThreadState.
-
isManuallyManageGovernance
public boolean isManuallyManageGovernance()
Description copied from interface:OfficeConfigurationIndicates if manually managingGovernanceviaAdministration.- Specified by:
isManuallyManageGovernancein interfaceOfficeConfiguration- Returns:
trueto manually managedGovernance.
-
getGovernanceConfiguration
public GovernanceConfiguration<?,?>[] getGovernanceConfiguration()
Description copied from interface:OfficeConfigurationObtains theGovernanceConfiguration.- Specified by:
getGovernanceConfigurationin interfaceOfficeConfiguration- Returns:
GovernanceConfiguration.
-
getManagedFunctionConfiguration
public ManagedFunctionConfiguration<?,?>[] getManagedFunctionConfiguration()
Description copied from interface:OfficeConfigurationObtains the configuration for theManagedFunctioninstances.- Specified by:
getManagedFunctionConfigurationin interfaceOfficeConfiguration- Returns:
- Configuration for the
ManagedFunctioninstances.
-
getOfficeEnhancers
public OfficeEnhancer[] getOfficeEnhancers()
Description copied from interface:OfficeConfigurationObtains theOfficeEnhancerinstances for thisOffice.- Specified by:
getOfficeEnhancersin interfaceOfficeConfiguration- Returns:
- Listing of the
OfficeEnhancerfor thisOffice.
-
getEscalationConfiguration
public EscalationConfiguration[] getEscalationConfiguration()
Description copied from interface:OfficeConfigurationObtains theEscalationConfigurationinstances for theOffice.- Specified by:
getEscalationConfigurationin interfaceOfficeConfiguration- Returns:
EscalationConfigurationinstances for theOffice.
-
getFlowBuilder
public FlowBuilder<?> getFlowBuilder(java.lang.String namespace, java.lang.String functionName)
Description copied from interface:OfficeConfigurationObtains a
FunctionBuilderregistered with thisOfficeBuilder.This enables addition configuration of
ManagedFunctioninstances registered by aManagedObjectSource.- Specified by:
getFlowBuilderin interfaceOfficeConfiguration- Parameters:
namespace- Namespace. Likely theManagedObjectSourcename.functionName- Name of theManagedFunction.- Returns:
FlowBuilderfor theManagedFunction.
-
getStartupFunctions
public ManagedFunctionReference[] getStartupFunctions()
Description copied from interface:OfficeConfigurationObtains the list ofManagedFunctionReferenceinstances referencing theManagedFunctioninstances to invoke onOfficestart up.- Specified by:
getStartupFunctionsin interfaceOfficeConfiguration- Returns:
- List of start up
ManagedFunctionReferencereferences.
-
getProfiler
public Profiler getProfiler()
Description copied from interface:OfficeConfiguration- Specified by:
getProfilerin interfaceOfficeConfiguration- Returns:
Profilerfor theOffice.
-
getThreadSynchronisers
public ThreadSynchroniserFactory[] getThreadSynchronisers()
Description copied from interface:OfficeConfigurationObtains theThreadSynchroniserFactoryinstances to synchronise theThreadLocalstate betweenTeaminstances.- Specified by:
getThreadSynchronisersin interfaceOfficeConfiguration- Returns:
ThreadSynchroniserFactoryinstances.
-
getDefaultAsynchronousFlowTimeout
public long getDefaultAsynchronousFlowTimeout()
Description copied from interface:OfficeConfigurationObtains the defaultAsynchronousFlowtimeout forAsynchronousFlowinstances instigated by theOffice.- Specified by:
getDefaultAsynchronousFlowTimeoutin interfaceOfficeConfiguration- Returns:
- Default
AsynchronousFlowtimeout forAsynchronousFlowinstances instigated by theOffice.
-
-