|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
com.marringtons.util.ThreadData
This class adds thread specific data storage and retrieval - important for client/server systems to keep conversation specific information.
| Field Summary |
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Method Summary | |
static Object |
get(Class itemClass)
Retrieve data associated with this thread for single class instance per thread using the class name as a key. |
static Object |
get(Object key)
Retrieve data associated with this thread - if it has been set. |
static Object |
get(Object key,
Class itemClass)
Retrieve application data associated with this thread, creating a new one if it does not exist. |
static void |
reset()
At the start of a converstion it is a good idea to clear the thread data as a different thread will act since last time and without this we can end up sharing data between users. |
static void |
set(Object key,
Object value)
If you use the data() method that returns null rather than creating a new data item, you will need setData() to create the item. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
public static Object get(Object key,
Class itemClass)
MyData myData = ThreadData.data( "myData", MyData.class);
key - Key used for retrieval.itemClass - Class used to create item if it does not yet exist.
public static void reset()
public static Object get(Object key)
MyData myData = ThreadData.get( "myData"); if (myData == null) ThreadData.set( "myData", myData = new MyData( "My Data"));
key - Key used for retrieval.
public static void set(Object key,
Object value)
MyData myData = ThreadData.data( "myData"); if (myData == null) ThreadData.setData( "myData", myData = new MyData( "My Data");
key - Key to save/retrieve the data item.value - Content to be set to the new data item.public static Object get(Class itemClass)
MyData myData = ThreadData.get( MyData.class);
itemClass - Class used to create item if it does not yet exist.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||