|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectariba.util.core.ThreadDebugState
public class ThreadDebugState
This class maintains debug state for the current thread. The class is intended to allow callers to add and remove arbitrary debug information as processing of a transation continues. This way when there is an error or a hang this information can be retrieved. It is very cheap to add and remove items as there is no synchronization. All static methods are safe to call.
Non static calls should be made with extreme caution - as that code will have to be able to handle all types of exceptions due to possible synchronization issues.
The only non static methods are for reading data exclusivly. This way a thread trying to look at the debug state of another thread will not be able to, under any circumstances, damage the thread it is looking at. Although it certainly may trigger exceptions in its own thread if race conditions are hit.
| Nested Class Summary | |
|---|---|
static class |
ThreadDebugState.StateMap
|
| Field Summary | |
|---|---|
static boolean |
threadStateEnabled
|
| Method Summary | |
|---|---|
static void |
clear()
Remove all values that are currently stored. |
static Object |
get(ThreadDebugKey key)
Retrieve a value for a specified key. |
static ThreadDebugState |
getUnsafeThreadDebugState()
This method is thread safe, but is the first step towards getting non safe data. |
static String |
makeString()
Return a string representing the contents of the state. |
static Object |
nullSafeObject(Object o)
This is just a convinence for callers who wish to create Hashtables or Lists that contain objects that may be null. |
static Object |
remove(ThreadDebugKey key)
Remove a value for a specified key. |
static void |
set(ThreadDebugKey key,
Object value)
The key specified will overwrite any other date stored with a pointer equal key. |
String |
toString()
This is the method to call to print state from a different thread. |
Object |
unsafeGet(ThreadDebugKey key)
This is an unsafe method. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static boolean threadStateEnabled
| Method Detail |
|---|
public static void set(ThreadDebugKey key,
Object value)
If value implements DebugState the debugState()
method will be called instead of toString() on
value when it is needed. This should happen
rarely, so this method implementation may also be expensive
without hurting performance of the overall application.
The toString() method of the value object must be be made safe for other threads to call, even if the value is being modified at the time. Throwing exceptions from the toString if the thread gets unlucky is acceptable, but data corruption is not.
key - the ThreadDebugKey to use for this object when
printed. key may not be null.value - the object to print out as part of the
state. value may be null.DebugStatepublic static Object get(ThreadDebugKey key)
public static Object remove(ThreadDebugKey key)
key - the ThreadDebugKey to delete from the current
application state.
public static void clear()
public static String makeString()
public String toString()
toString in class Objectpublic Object unsafeGet(ThreadDebugKey key)
public static ThreadDebugState getUnsafeThreadDebugState()
public static Object nullSafeObject(Object o)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||