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 Object
implements ManagedObjectUser, ManagedObjectContext, AsynchronousContext, ObjectRegistry
Implementation of a
ManagedObjectUser to source an object from a
ManagedObjectSource.- Author:
- Daniel Sagenschneider
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends Throwable>
voidcomplete(AsynchronousOperation<T> operation) Indicates that theAsynchronousManagedObjecthas completed and is ready for another operation.Obtains the name thisManagedObjectis bound under.Obtains theLoggerfor theManagedObject.getObject(int index) Obtains the dependencyObjectby its index.Obtains the dependencyObjectfor the dependency key.voidmapDependency(int index, Object dependency) Maps the dependency for theCoordinatingManagedObject.voidmapDependency(Enum<?> key, Object dependency) Maps the dependency for theCoordinatingManagedObject.<R,T extends Throwable>
Rrun(ProcessSafeOperation<R, T> operation) Undertakes aProcessSafeOperation.voidsetAsynchronousListener(AsynchronousContext listener) Allows overriding theAsynchronousContextto initialise anAsynchronousManagedObject.voidsetBoundManagedObjectName(String boundManagedObjectName) Specifies the bound name for aContextAwareManagedObject.voidsetFailure(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.sourceManagedObject(ManagedObjectSource<?, ?> source) Sources theManagedObjectfrom theManagedObjectSource.sourceManagedObject(ManagedObjectSource<?, ?> source, boolean isWait) Sources theManagedObjectfrom theManagedObjectSource.<T extends Throwable>
voidstart(AsynchronousOperation<T> operation) Undertakes anAsynchronousOperation.
-
Constructor Details
-
ManagedObjectUserStandAlone
public ManagedObjectUserStandAlone()
-
-
Method Details
-
setSourceTimeout
public void setSourceTimeout(long sourceTimeout) Specifies the timeout to source theManagedObject.- Parameters:
sourceTimeout- Timeout to source theManagedObject.
-
setBoundManagedObjectName
Specifies the bound name for aContextAwareManagedObject.- Parameters:
boundManagedObjectName- Bound name for aContextAwareManagedObject.
-
setAsynchronousListener
Allows overriding theAsynchronousContextto initialise anAsynchronousManagedObject.- Parameters:
listener-AsynchronousContext.
-
setObjectRegistry
Allows overriding theObjectRegistryto initialise aCoordinatingManagedObject.- Parameters:
objectRegistry-ObjectRegistry.
-
mapDependency
Maps the dependency for theCoordinatingManagedObject.- Parameters:
index- Index of the dependency.dependency- Dependency.
-
mapDependency
Maps the dependency for theCoordinatingManagedObject.- Parameters:
key- Key of the dependency.dependency- Dependency.
-
sourceManagedObject
Sources theManagedObjectfrom theManagedObjectSource.- Parameters:
source-ManagedObjectSource.- Returns:
ManagedObjectfrom theManagedObjectSource.- Throws:
Throwable- If fails to source theManagedObject.
-
sourceManagedObject
public ManagedObject sourceManagedObject(ManagedObjectSource<?, ?> source, boolean isWait) throws ThrowableSources theManagedObjectfrom theManagedObjectSource.- Parameters:
source-ManagedObjectSource.isWait- Flags to wait forManagedObjectSourceto provide theManagedObject.- Returns:
ManagedObjectfrom theManagedObjectSourceornullif not waiting and not sourced immediately.- Throws:
Throwable- If fails to source theManagedObject.
-
setManagedObject
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
Description copied from interface:ManagedObjectUserIndicates failure to obtain theManagedObject.- Specified by:
setFailurein interfaceManagedObjectUser- Parameters:
cause- Cause of the failure.
-
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
Description copied from interface:ManagedObjectContextObtains theLoggerfor theManagedObject.- Specified by:
getLoggerin interfaceManagedObjectContext- Returns:
Loggerfor theManagedObject.
-
run
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.
-
start
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
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
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
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.
-