com.interface21.util
Class ThreadObjectManager
java.lang.Object
|
+--com.interface21.util.ThreadObjectManager
- public class ThreadObjectManager
- extends java.lang.Object
Provides static methods for managing key/value pairs that are bound to the
current thread. Supports one thread value per key without overwriting, i.e.
a value needs to be removed before a new one can be set for the same key.
Used by DataSourceTransactionManager to keep a JDBC transaction per
DataSource and thread. Does not need to be used by application developers.
- Since:
- 02.05.2003
- Author:
- Juergen Hoeller
- See Also:
DataSourceUtils.getConnection(javax.sql.DataSource),
DataSourceTransactionManager
|
Method Summary |
void |
bindThreadObject(java.lang.Object key,
java.lang.Object value)
Bind the given value for the given key to the current thread. |
java.lang.Object |
getThreadObject(java.lang.Object key)
Retrieve a value for the given key that is bound to the current thread. |
boolean |
hasThreadObject(java.lang.Object key)
Check if there is a value for the given key bound to the current thread. |
void |
removeThreadObject(java.lang.Object key)
Remove a value for the key from the current thread. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ThreadObjectManager
public ThreadObjectManager()
hasThreadObject
public boolean hasThreadObject(java.lang.Object key)
- Check if there is a value for the given key bound to the current thread.
- Parameters:
key - key to check- Returns:
- if there is a value bound to the current thread
getThreadObject
public java.lang.Object getThreadObject(java.lang.Object key)
- Retrieve a value for the given key that is bound to the current thread.
- Parameters:
key - key to check- Returns:
- a value bound to the current thread, or null if none
bindThreadObject
public void bindThreadObject(java.lang.Object key,
java.lang.Object value)
- Bind the given value for the given key to the current thread.
- Parameters:
key - key to bind the value tovalue - value to bind- Throws:
java.lang.IllegalStateException - if there is already a value bound to the thread
removeThreadObject
public void removeThreadObject(java.lang.Object key)
- Remove a value for the key from the current thread.
- Parameters:
key - key to check- Throws:
java.lang.IllegalStateException - if there is no value bound to the thread
Rod Johnson and Spring contributors 2001-2003.