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)
PerthreadManager
PerthreadManager.cleanup()
.addThreadCleanupListener
in interface PerthreadManager
listener
- to addpublic void addThreadCleanupCallback(Runnable callback)
PerthreadManager
PerthreadManager.cleanup()
is invoked; callbacks are then removed.addThreadCleanupCallback
in interface PerthreadManager
public void cleanup()
cleanup
in interface PerthreadManager
public <T> ObjectCreator<T> createValue(ObjectCreator<T> delegate)
PerthreadManager
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. The instance is stored in the
PerthreadManager
and will be released at the end of the request.createValue
in interface PerthreadManager
public <T> PerThreadValue<T> createValue()
PerthreadManager
createValue
in interface PerthreadManager
public void run(Runnable runnable)
PerthreadManager
Runnable.run()
, providing a try...finally to cleanup after.run
in interface PerthreadManager
public <T> T invoke(Invokable<T> invokable)
PerthreadManager
invoke
in interface PerthreadManager
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.