org.apache.tapestry5.ioc.services
Interface PerthreadManager

All Known Implementing Classes:
PerthreadManagerImpl

public interface PerthreadManager

Manages per-thread data, and provides a way for listeners to know when such data should be cleaned up. Typically, data is cleaned up at the end of the request (in a web application). Tapestry IoC has any number of objects that need to know when this event occurs, so that they can clean up any per-thread/per-request state.

Due to TAPESTRY-2141 (and the underlying JDK 1.5 bug 5025230), this service has expanded to manager per-thread data (not just end-of-request listeners).


Method Summary
 void addThreadCleanupListener(ThreadCleanupListener listener)
          Adds a listener to the hub.
 void cleanup()
          Immediately performs a cleanup of the thread, notifying all listeners then discarding the thread locale and the map it stores.
 Object get(Object key)
          Returns an object stored in the per-thread map.
 void put(Object key, Object value)
          Stores a value into the per-thread map.
 

Method Detail

addThreadCleanupListener

void addThreadCleanupListener(ThreadCleanupListener listener)
Adds a listener to the hub. All listeners are discarded at the cleanup().

Parameters:
listener - to add

cleanup

void cleanup()
Immediately performs a cleanup of the thread, notifying all listeners then discarding the thread locale and the map it stores.


get

Object get(Object key)
Returns an object stored in the per-thread map. When the object is a string, the expected name is service id.subkey. Unlike most of Tapestry, such keys will be case sensitive.

Parameters:
key - key used to retrieve object
Returns:
corresponding per-thread object, or null

put

void put(Object key,
         Object value)
Stores a value into the per-thread map.



Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.