Class PerthreadManagerImpl
- java.lang.Object
 - 
- org.apache.tapestry5.ioc.internal.services.PerthreadManagerImpl
 
 
- 
- All Implemented Interfaces:
 PerthreadManager
public class PerthreadManagerImpl extends 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 voidaddThreadCleanupCallback(Runnable callback)Adds a callback to be invoked whenPerthreadManager.cleanup()is invoked; callbacks are then removed.voidaddThreadCleanupListener(ThreadCleanupListener listener)Adds a listener to the hub.voidcleanup()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 delegateObjectCreatorto create an instance, and later calls will reuse the same per-thread instance.<T> Tinvoke(Invokable<T> invokable)Returns the result from the invocation, providing a try...finally to cleanup after.voidregisterForShutdown(RegistryShutdownHub hub)voidrun(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:PerthreadManagerAdds a listener to the hub. All listeners are discarded at thePerthreadManager.cleanup().- Specified by:
 addThreadCleanupListenerin interfacePerthreadManager- Parameters:
 listener- to add
 
- 
addThreadCleanupCallback
public void addThreadCleanupCallback(Runnable callback)
Description copied from interface:PerthreadManagerAdds a callback to be invoked whenPerthreadManager.cleanup()is invoked; callbacks are then removed.- Specified by:
 addThreadCleanupCallbackin 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:
 cleanupin interfacePerthreadManager
 
- 
createValue
public <T> ObjectCreator<T> createValue(ObjectCreator<T> delegate)
Description copied from interface:PerthreadManagerReturnObjectCreator, which for each thread, the first call will use the delegateObjectCreatorto create an instance, and later calls will reuse the same per-thread instance. The instance is stored in thePerthreadManagerand will be released at the end of the request.- Specified by:
 createValuein interfacePerthreadManager
 
- 
createValue
public <T> PerThreadValue<T> createValue()
Description copied from interface:PerthreadManagerCreates a value using a unique internal key.- Specified by:
 createValuein interfacePerthreadManager
 
- 
run
public void run(Runnable runnable)
Description copied from interface:PerthreadManagerInvokesRunnable.run(), providing a try...finally to cleanup after.- Specified by:
 runin interfacePerthreadManager
 
- 
invoke
public <T> T invoke(Invokable<T> invokable)
Description copied from interface:PerthreadManagerReturns the result from the invocation, providing a try...finally to cleanup after.- Specified by:
 invokein interfacePerthreadManager
 
 - 
 
 -