org.apache.avalon.excalibur.lang
Class DefaultThreadContextPolicy

java.lang.Object
  |
  +--org.apache.avalon.excalibur.lang.DefaultThreadContextPolicy
All Implemented Interfaces:
ThreadContextPolicy

public class DefaultThreadContextPolicy
extends java.lang.Object
implements ThreadContextPolicy

Default ThreadContextPolicy that just maintains the ContextClassLoader ThreadLocal variable. This is a useful class to extend for those wanting to write their own Policy.

Author:
Peter Donald

Fields inherited from interface org.apache.avalon.excalibur.lang.ThreadContextPolicy
CLASSLOADER
 
Constructor Summary
DefaultThreadContextPolicy()
           
 
Method Summary
 void activate(ThreadContextAccessor accessor)
          The activate method is called when the ThreadContext is associated with a thread.
 void deactivate(ThreadContextAccessor accessor)
          The deactivate method is called when the ThreadContext is dis-associated with a thread.
protected  java.lang.Object get(ThreadContextAccessor accessor, java.lang.String key, java.lang.Object defaultValue, java.lang.Class type)
          Get a value for specified key, using specified default if none present and making sure value is of specified type.
 void verifyKeyValue(java.lang.String key, java.lang.Object value)
          Verify that the key/value pair is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultThreadContextPolicy

public DefaultThreadContextPolicy()
Method Detail

activate

public void activate(ThreadContextAccessor accessor)
The activate method is called when the ThreadContext is associated with a thread. This method sets the ContextClassLoader if CLASSLOADER key is present in context.
Specified by:
activate in interface ThreadContextPolicy
Parameters:
accessor - the accessor to retrieve values from ThreadContext

deactivate

public void deactivate(ThreadContextAccessor accessor)
The deactivate method is called when the ThreadContext is dis-associated with a thread.
Specified by:
deactivate in interface ThreadContextPolicy
Parameters:
accessor - the accessor to retrieve values from ThreadContext

verifyKeyValue

public void verifyKeyValue(java.lang.String key,
                           java.lang.Object value)
                    throws java.lang.IllegalArgumentException
Verify that the key/value pair is valid.
Specified by:
verifyKeyValue in interface ThreadContextPolicy
Parameters:
key - The key
value - the value
Throws:
java.lang.IllegalArgumentException - if pair is not valid

get

protected java.lang.Object get(ThreadContextAccessor accessor,
                               java.lang.String key,
                               java.lang.Object defaultValue,
                               java.lang.Class type)
Get a value for specified key, using specified default if none present and making sure value is of specified type.
Parameters:
key - the key used to lookup value
defaultValue - the default value if the key does not specify value
type - the expected type of value
Returns:
the value


Copyright 2001 Apache Jakarta Project. All Rights Reserved.