avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/threadcontext/src/java/org/apache/excalibur/threadcontext/impl DefaultThreadContextPolicy.java
Date Thu, 02 May 2002 03:10:46 GMT
donaldp     02/05/01 20:10:46

  Modified:    threadcontext/src/java/org/apache/excalibur/threadcontext/impl
                        DefaultThreadContextPolicy.java
  Log:
  Include name of Thread in the items that are handled by ThreadContextPolicy
  
  Revision  Changes    Path
  1.6       +28 -1     jakarta-avalon-excalibur/threadcontext/src/java/org/apache/excalibur/threadcontext/impl/DefaultThreadContextPolicy.java
  
  Index: DefaultThreadContextPolicy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/threadcontext/src/java/org/apache/excalibur/threadcontext/impl/DefaultThreadContextPolicy.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultThreadContextPolicy.java	26 Apr 2002 06:34:49 -0000	1.5
  +++ DefaultThreadContextPolicy.java	2 May 2002 03:10:46 -0000	1.6
  @@ -16,7 +16,7 @@
    * class to extend for those wanting to write their own Policy.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.5 $ $Date: 2002/04/26 06:34:49 $
  + * @version $Revision: 1.6 $ $Date: 2002/05/02 03:10:46 $
    */
   public class DefaultThreadContextPolicy
       extends AbstractThreadContextPolicy
  @@ -26,9 +26,16 @@
        */
       public final static String CLASSLOADER = ClassLoader.class.getName();
   
  +    /**
  +     * Key used to store the Thread name ThreadContextAccessor.
  +     */
  +    public static final String THREAD_NAME = Thread.class.getName();
  +
  +
       public DefaultThreadContextPolicy()
       {
           addEntry( CLASSLOADER, ClassLoader.class, true );
  +        addEntry( THREAD_NAME, String.class, false );
       }
   
       /**
  @@ -51,6 +58,18 @@
                   (ClassLoader)get( accessor, CLASSLOADER, null );
               Thread.currentThread().setContextClassLoader( newLoader );
           }
  +
  +
  +        if( accessor.containsKey( THREAD_NAME ) )
  +        {
  +            final String newName =
  +                (String)get( accessor, THREAD_NAME, null );
  +
  +            final Thread thread = Thread.currentThread();
  +            final String oldName = thread.getName();
  +            thread.setName( newName );
  +            store.put( THREAD_NAME, oldName );
  +        }
       }
   
       /**
  @@ -63,6 +82,14 @@
       public void deactivate( final ThreadContextAccessor accessor,
                               final Map store )
       {
  +
  +        if( accessor.containsKey( THREAD_NAME ) )
  +        {
  +            final String name =
  +                (String)store.get( THREAD_NAME );
  +            Thread.currentThread().setName( name );
  +        }
  +
           if( accessor.containsKey( CLASSLOADER ) )
           {
               final ClassLoader classLoader =
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message