public class PerthreadManagerImpl extends Object implements PerthreadManager
| Constructor and Description |
|---|
PerthreadManagerImpl(org.slf4j.Logger logger) |
| Modifier and Type | Method and Description |
|---|---|
void |
addThreadCleanupCallback(Runnable callback)
Adds a callback to be invoked when
PerthreadManager.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)
Return
ObjectCreator, which for each thread,
the first call will use the delegate ObjectCreator 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(Runnable runnable)
Invokes
Runnable.run(), providing a try...finally to cleanup after. |
public PerthreadManagerImpl(org.slf4j.Logger logger)
public void registerForShutdown(RegistryShutdownHub hub)
public void addThreadCleanupListener(ThreadCleanupListener listener)
PerthreadManagerPerthreadManager.cleanup().addThreadCleanupListener in interface PerthreadManagerlistener - to addpublic void addThreadCleanupCallback(Runnable callback)
PerthreadManagerPerthreadManager.cleanup() is invoked; callbacks are then removed.addThreadCleanupCallback in interface PerthreadManagerpublic void cleanup()
cleanup in interface PerthreadManagerpublic <T> ObjectCreator<T> createValue(ObjectCreator<T> delegate)
PerthreadManagerObjectCreator, which for each thread,
the first call will use the delegate ObjectCreator to create
an instance, and later calls will reuse the same per-thread instance. The instance is stored in the
PerthreadManager and will be released at the end of the request.createValue in interface PerthreadManagerpublic <T> PerThreadValue<T> createValue()
PerthreadManagercreateValue in interface PerthreadManagerpublic void run(Runnable runnable)
PerthreadManagerRunnable.run(), providing a try...finally to cleanup after.run in interface PerthreadManagerpublic <T> T invoke(Invokable<T> invokable)
PerthreadManagerinvoke in interface PerthreadManager5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.