com.sun.grizzly.http.jk.util.threads
Class ThreadWithAttributes

java.lang.Object
  extended by java.lang.Thread
      extended by com.sun.grizzly.http.jk.util.threads.ThreadWithAttributes
All Implemented Interfaces:
Runnable

public class ThreadWithAttributes
extends Thread

Special thread that allows storing of attributes and notes. A guard is used to prevent untrusted code from accessing the attributes. This avoids hash lookups and provide something very similar with ThreadLocal ( but compatible with JDK1.1 and faster on JDK < 1.4 ). The main use is to store 'state' for monitoring ( like "processing request 'GET /' ").


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static int MAX_NOTES
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ThreadWithAttributes(Object control, Runnable r)
           
 
Method Summary
 Hashtable getAttributes(Object control)
          Generic attributes.
 String getCurrentStage(Object control)
          Information about the curent performed operation
 Object getNote(Object control, int id)
           
 Object getParam(Object control)
          Information about the current request ( or the main object we are processing )
 Object[] getThreadData(Object control)
           
 void setCurrentStage(Object control, String currentStage)
           
 void setNote(Object control, int id, Object value)
          Notes - for attributes that need fast access ( array ) The application is responsible for id management
 void setParam(Object control, Object param)
           
 void setThreadData(Object control, Object[] thData)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_NOTES

public static final int MAX_NOTES
See Also:
Constant Field Values
Constructor Detail

ThreadWithAttributes

public ThreadWithAttributes(Object control,
                            Runnable r)
Method Detail

getThreadData

public final Object[] getThreadData(Object control)

setThreadData

public final void setThreadData(Object control,
                                Object[] thData)

setNote

public final void setNote(Object control,
                          int id,
                          Object value)
Notes - for attributes that need fast access ( array ) The application is responsible for id management


getCurrentStage

public final String getCurrentStage(Object control)
Information about the curent performed operation


getParam

public final Object getParam(Object control)
Information about the current request ( or the main object we are processing )


setCurrentStage

public final void setCurrentStage(Object control,
                                  String currentStage)

setParam

public final void setParam(Object control,
                           Object param)

getNote

public final Object getNote(Object control,
                            int id)

getAttributes

public final Hashtable getAttributes(Object control)
Generic attributes. You'll need a hashtable lookup - you can use notes for array access.



Copyright © 2013 Oracle Corporation. All Rights Reserved.