Package net.officefloor.frame.util
Class ManagedObjectUserStandAlone
- java.lang.Object
-
- net.officefloor.frame.util.ManagedObjectUserStandAlone
-
- All Implemented Interfaces:
AsynchronousContext,ManagedObjectContext,ObjectRegistry,ManagedObjectUser
public class ManagedObjectUserStandAlone extends java.lang.Object implements ManagedObjectUser, ManagedObjectContext, AsynchronousContext, ObjectRegistry
Implementation of aManagedObjectUserto source an object from aManagedObjectSource.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description ManagedObjectUserStandAlone()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends java.lang.Throwable>
voidcomplete(AsynchronousOperation<T> operation)Indicates that theAsynchronousManagedObjecthas completed and is ready for another operation.java.lang.StringgetBoundName()Obtains the name thisManagedObjectis bound under.java.util.logging.LoggergetLogger()Obtains theLoggerfor theManagedObject.java.lang.ObjectgetObject(int index)Obtains the dependencyObjectby its index.java.lang.ObjectgetObject(java.lang.Enum key)Obtains the dependencyObjectfor the dependency key.voidmapDependency(int index, java.lang.Object dependency)Maps the dependency for theCoordinatingManagedObject.voidmapDependency(java.lang.Enum<?> key, java.lang.Object dependency)Maps the dependency for theCoordinatingManagedObject.<R,T extends java.lang.Throwable>
Rrun(ProcessSafeOperation<R,T> operation)Undertakes aProcessSafeOperation.voidsetAsynchronousListener(AsynchronousContext listener)Allows overriding theAsynchronousContextto initialise anAsynchronousManagedObject.voidsetBoundManagedObjectName(java.lang.String boundManagedObjectName)Specifies the bound name for aContextAwareManagedObject.voidsetFailure(java.lang.Throwable cause)Indicates failure to obtain theManagedObject.voidsetManagedObject(ManagedObject managedObject)Specifies theManagedObjectto be used.voidsetObjectRegistry(ObjectRegistry<?> objectRegistry)Allows overriding theObjectRegistryto initialise aCoordinatingManagedObject.voidsetSourceTimeout(long sourceTimeout)Specifies the timeout to source theManagedObject.ManagedObjectsourceManagedObject(ManagedObjectSource<?,?> source)Sources theManagedObjectfrom theManagedObjectSource.ManagedObjectsourceManagedObject(ManagedObjectSource<?,?> source, boolean isWait)Sources theManagedObjectfrom theManagedObjectSource.<T extends java.lang.Throwable>
voidstart(AsynchronousOperation<T> operation)Undertakes anAsynchronousOperation.
-
-
-
Method Detail
-
setSourceTimeout
public void setSourceTimeout(long sourceTimeout)
Specifies the timeout to source theManagedObject.- Parameters:
sourceTimeout- Timeout to source theManagedObject.
-
setBoundManagedObjectName
public void setBoundManagedObjectName(java.lang.String boundManagedObjectName)
Specifies the bound name for aContextAwareManagedObject.- Parameters:
boundManagedObjectName- Bound name for aContextAwareManagedObject.
-
setAsynchronousListener
public void setAsynchronousListener(AsynchronousContext listener)
Allows overriding theAsynchronousContextto initialise anAsynchronousManagedObject.- Parameters:
listener-AsynchronousContext.
-
setObjectRegistry
public void setObjectRegistry(ObjectRegistry<?> objectRegistry)
Allows overriding theObjectRegistryto initialise aCoordinatingManagedObject.- Parameters:
objectRegistry-ObjectRegistry.
-
mapDependency
public void mapDependency(int index, java.lang.Object dependency)Maps the dependency for theCoordinatingManagedObject.- Parameters:
index- Index of the dependency.dependency- Dependency.
-
mapDependency
public void mapDependency(java.lang.Enum<?> key, java.lang.Object dependency)Maps the dependency for theCoordinatingManagedObject.- Parameters:
key- Key of the dependency.dependency- Dependency.
-
sourceManagedObject
public ManagedObject sourceManagedObject(ManagedObjectSource<?,?> source) throws java.lang.Throwable
Sources theManagedObjectfrom theManagedObjectSource.- Parameters:
source-ManagedObjectSource.- Returns:
ManagedObjectfrom theManagedObjectSource.- Throws:
java.lang.Throwable- If fails to source theManagedObject.
-
sourceManagedObject
public ManagedObject sourceManagedObject(ManagedObjectSource<?,?> source, boolean isWait) throws java.lang.Throwable
Sources theManagedObjectfrom theManagedObjectSource.- Parameters:
source-ManagedObjectSource.isWait- Flags to wait forManagedObjectSourceto provide theManagedObject.- Returns:
ManagedObjectfrom theManagedObjectSourceornullif not waiting and not sourced immediately.- Throws:
java.lang.Throwable- If fails to source theManagedObject.
-
setManagedObject
public void setManagedObject(ManagedObject managedObject)
Description copied from interface:ManagedObjectUserSpecifies the
ManagedObjectto be used.This will be called by the
ManagedObjectSource.sourceManagedObject(ManagedObjectUser)method to provide theManagedObjectto thisManagedObjectUser.- Specified by:
setManagedObjectin interfaceManagedObjectUser- Parameters:
managedObject-ManagedObjectto be used.
-
setFailure
public void setFailure(java.lang.Throwable cause)
Description copied from interface:ManagedObjectUserIndicates failure to obtain theManagedObject.- Specified by:
setFailurein interfaceManagedObjectUser- Parameters:
cause- Cause of the failure.
-
getBoundName
public java.lang.String getBoundName()
Description copied from interface:ManagedObjectContextObtains the name this
ManagedObjectis bound under.This is useful to have a unique name identifying the
ManagedObject.- Specified by:
getBoundNamein interfaceManagedObjectContext- Returns:
- Name this
ManagedObjectis bound under.
-
getLogger
public java.util.logging.Logger getLogger()
Description copied from interface:ManagedObjectContextObtains theLoggerfor theManagedObject.- Specified by:
getLoggerin interfaceManagedObjectContext- Returns:
Loggerfor theManagedObject.
-
run
public <R,T extends java.lang.Throwable> R run(ProcessSafeOperation<R,T> operation) throws T extends java.lang.Throwable
Description copied from interface:ManagedObjectContextUndertakes aProcessSafeOperation.- Specified by:
runin interfaceManagedObjectContext- Type Parameters:
R- Return type from operationT- PossibleThrowabletype from operation.- Parameters:
operation-ProcessSafeOperation.- Returns:
- Return value.
- Throws:
T- PossibleThrowable.T extends java.lang.Throwable
-
start
public <T extends java.lang.Throwable> void start(AsynchronousOperation<T> operation)
Description copied from interface:AsynchronousContextUndertakes anAsynchronousOperation.- Specified by:
startin interfaceAsynchronousContext- Type Parameters:
T- Possible exception type fromAsynchronousOperation.- Parameters:
operation- Optional operation to be undertaken, once theAsynchronousManagedObjectis registered as started an asynchronous operation. May benull.
-
complete
public <T extends java.lang.Throwable> void complete(AsynchronousOperation<T> operation)
Description copied from interface:AsynchronousContextIndicates that theAsynchronousManagedObjecthas completed and is ready for another operation.- Specified by:
completein interfaceAsynchronousContext- Type Parameters:
T- Possible exception type fromAsynchronousOperation.- Parameters:
operation- Optional operation to be undertaken, once theAsynchronousManagedObjectis unregistered from undertaking an asynchronous operation. May benull.
-
getObject
public java.lang.Object getObject(java.lang.Enum key)
Description copied from interface:ObjectRegistryObtains the dependencyObjectfor the dependency key.- Specified by:
getObjectin interfaceObjectRegistry- Parameters:
key- Key identifying the dependencyObject.- Returns:
- Dependency
Objectfor the key.
-
getObject
public java.lang.Object getObject(int index)
Description copied from interface:ObjectRegistryObtains the dependency
Objectby its index.This enables a dynamic number of dependencies for the
ManagedObject.- Specified by:
getObjectin interfaceObjectRegistry- Parameters:
index- Index identifying the dependencyObject.- Returns:
- Dependency
Objectfor the index.
-
-