Class PerthreadManagerImpl
- java.lang.Object
-
- org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl
-
- All Implemented Interfaces:
PerthreadManager
public class PerthreadManagerImpl extends java.lang.Object implements PerthreadManager
-
-
Constructor Summary
Constructors Constructor Description PerthreadManagerImpl(org.slf4j.Logger logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addThreadCleanupCallback(java.lang.Runnable callback)
Adds a callback to be invoked whenPerthreadManager.cleanup()
is invoked; callbacks are then removed.void
addThreadCleanupListener(ThreadCleanupListener listener)
Adds a listener to the hub.void
cleanup()
Instructs the hub to notify all its listeners (for the current thread).<T> PerThreadValue<T>
createValue()
Creates a value using a unique internal key.<T> ObjectCreator<T>
createValue(ObjectCreator<T> delegate)
ReturnObjectCreator
, which for each thread, the first call will use the delegateObjectCreator
to create an instance, and later calls will reuse the same per-thread instance.<T> T
invoke(Invokable<T> invokable)
Returns the result from the invocation, providing a try...finally to cleanup after.void
registerForShutdown(RegistryShutdownHub hub)
void
run(java.lang.Runnable runnable)
InvokesRunnable.run()
, providing a try...finally to cleanup after.
-
-
-
Constructor Detail
-
PerthreadManagerImpl
public PerthreadManagerImpl(org.slf4j.Logger logger)
-
-
Method Detail
-
registerForShutdown
public void registerForShutdown(RegistryShutdownHub hub)
-
addThreadCleanupListener
public void addThreadCleanupListener(ThreadCleanupListener listener)
Description copied from interface:PerthreadManager
Adds a listener to the hub. All listeners are discarded at thePerthreadManager.cleanup()
.- Specified by:
addThreadCleanupListener
in interfacePerthreadManager
- Parameters:
listener
- to add
-
addThreadCleanupCallback
public void addThreadCleanupCallback(java.lang.Runnable callback)
Description copied from interface:PerthreadManager
Adds a callback to be invoked whenPerthreadManager.cleanup()
is invoked; callbacks are then removed.- Specified by:
addThreadCleanupCallback
in interfacePerthreadManager
-
cleanup
public void cleanup()
Instructs the hub to notify all its listeners (for the current thread). It also discards its list of listeners.- Specified by:
cleanup
in interfacePerthreadManager
-
createValue
public <T> ObjectCreator<T> createValue(ObjectCreator<T> delegate)
Description copied from interface:PerthreadManager
ReturnObjectCreator
, which for each thread, the first call will use the delegateObjectCreator
to create an instance, and later calls will reuse the same per-thread instance. The instance is stored in thePerthreadManager
and will be released at the end of the request.- Specified by:
createValue
in interfacePerthreadManager
-
createValue
public <T> PerThreadValue<T> createValue()
Description copied from interface:PerthreadManager
Creates a value using a unique internal key.- Specified by:
createValue
in interfacePerthreadManager
-
run
public void run(java.lang.Runnable runnable)
Description copied from interface:PerthreadManager
InvokesRunnable.run()
, providing a try...finally to cleanup after.- Specified by:
run
in interfacePerthreadManager
-
invoke
public <T> T invoke(Invokable<T> invokable)
Description copied from interface:PerthreadManager
Returns the result from the invocation, providing a try...finally to cleanup after.- Specified by:
invoke
in interfacePerthreadManager
-
-