org.apache.tomcat.util.threads

Class ThreadWithAttributes


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 <321.4 ). The main use is to store 'state' for monitoring ( like "processing request 'GET /' ").

Field Summary

static int
MAX_NOTES

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, thData[] )

Field Details

MAX_NOTES

public static int MAX_NOTES

Constructor Details

ThreadWithAttributes

public ThreadWithAttributes(Object control,
                            Runnable r)

Method Details

getAttributes

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


getCurrentStage

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


getNote

public final Object getNote(Object control,
                            int id)


getParam

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


getThreadData

public final Object[] getThreadData(Object control)


setCurrentStage

public final void setCurrentStage(Object control,
                                  String currentStage)


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


setParam

public final void setParam(Object control,
                           Object param)


setThreadData

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


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.