Package org.apache.tapestry5.ioc.internal.services

# 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

  Modifier and Type
  Method
  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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PerthreadManagerImpl

    public PerthreadManagerImpl(org.slf4j.Logger logger)

- ## Method Details

  - ### 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 the `PerthreadManager.cleanup()`.
    Specified by:
      `addThreadCleanupListener` in interface `PerthreadManager`
    Parameters:
      `listener` - to add

  - ### addThreadCleanupCallback

    public void addThreadCleanupCallback(Runnable callback)
    Description copied from interface: `PerthreadManager`
    Adds a callback to be invoked when `PerthreadManager.cleanup()` is invoked; callbacks are then removed.
    Specified by:
      `addThreadCleanupCallback` in interface `PerthreadManager`

  - ### 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 interface `PerthreadManager`

  - ### createValue

    public <T> ObjectCreator<T> createValue(ObjectCreator<T> delegate)
    Description copied from interface: `PerthreadManager`
    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. The instance is stored in the `PerthreadManager` and will be released at the end of the request.
    Specified by:
      `createValue` in interface `PerthreadManager`

  - ### createValue

    public <T> PerThreadValue<T> createValue()
    Description copied from interface: `PerthreadManager`
    Creates a value using a unique internal key.
    Specified by:
      `createValue` in interface `PerthreadManager`

  - ### run

    public void run(Runnable runnable)
    Description copied from interface: `PerthreadManager`
    Invokes `Runnable.run()`, providing a try...finally to cleanup after.
    Specified by:
      `run` in interface `PerthreadManager`

  - ### 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 interface `PerthreadManager`