FileDocCategorySizeDatePackage
ThreadWithAttributes.javaAPI DocGlassfish v2 API4483Fri May 04 22:33:18 BST 2007org.apache.tomcat.util.threads

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

Fields Summary
private Object
control
public static final int
MAX_NOTES
private Object[]
notes
private Hashtable
attributes
private String
currentStage
private Object
param
private Object[]
thData
Constructors Summary
public ThreadWithAttributes(Object control, Runnable r)


         
        super(r);
        this.control=control;
    
Methods Summary
public final java.util.HashtablegetAttributes(java.lang.Object control)
Generic attributes. You'll need a hashtable lookup - you can use notes for array access.

        return attributes;
    
public final java.lang.StringgetCurrentStage(java.lang.Object control)
Information about the curent performed operation

        if( this.control != control ) return null;
        return currentStage;
    
public final java.lang.ObjectgetNote(java.lang.Object control, int id)

        if( this.control != control ) return null;
        return notes[id];
    
public final java.lang.ObjectgetParam(java.lang.Object control)
Information about the current request ( or the main object we are processing )

        if( this.control != control ) return null;
        return param;
    
public final java.lang.Object[]getThreadData(java.lang.Object control)

        return thData;
    
public final voidsetCurrentStage(java.lang.Object control, java.lang.String currentStage)

        if( this.control != control ) return;
        this.currentStage = currentStage;
    
public final voidsetNote(java.lang.Object control, int id, java.lang.Object value)
Notes - for attributes that need fast access ( array ) The application is responsible for id management

        if( this.control != control ) return;
        notes[id]=value;
    
public final voidsetParam(java.lang.Object control, java.lang.Object param)

        if( this.control != control ) return;
        this.param=param;
    
public final voidsetThreadData(java.lang.Object control, java.lang.Object[] thData)

        this.thData=thData;