ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess JavaProcessContextPolicy.java
Date Fri, 26 Apr 2002 07:55:53 GMT
donaldp     02/04/26 00:55:53

  Modified:    aut/src/java/org/apache/aut/jprocess
                        JavaProcessContextPolicy.java
  Log:
  Allow binding of ThreadName
  
  Revision  Changes    Path
  1.2       +21 -1     jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess/JavaProcessContextPolicy.java
  
  Index: JavaProcessContextPolicy.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/aut/src/java/org/apache/aut/jprocess/JavaProcessContextPolicy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JavaProcessContextPolicy.java	26 Apr 2002 07:49:55 -0000	1.1
  +++ JavaProcessContextPolicy.java	26 Apr 2002 07:55:53 -0000	1.2
  @@ -21,7 +21,7 @@
    * just defines new constants that will be handled.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.1 $ $Date: 2002/04/26 07:49:55 $
  + * @version $Revision: 1.2 $ $Date: 2002/04/26 07:55:53 $
    */
   public class JavaProcessContextPolicy
       extends DefaultThreadContextPolicy
  @@ -32,6 +32,7 @@
       public static final String PROPERTIES = Properties.class.getName();
       public static final String URL_FACTORY = URLStreamHandlerFactory.class.getName();
       public static final String JNDI_FACTORY = InitialContextFactory.class.getName();
  +    public static final String THREAD_NAME = Thread.class.getName();
   
       /**
        * Construct the policy object and register the types
  @@ -45,6 +46,7 @@
           addEntry( PROPERTIES, Properties.class, true );
           addEntry( URL_FACTORY, URLStreamHandlerFactory.class, true );
           addEntry( JNDI_FACTORY, InitialContextFactory.class, true );
  +        addEntry( THREAD_NAME, String.class, false );
       }
   
       /**
  @@ -59,6 +61,17 @@
       {
           super.activate( accessor, store );
   
  +        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 );
  +        }
  +
           if( accessor.containsKey( INPUT ) )
           {
               final InputStream newStream =
  @@ -111,6 +124,13 @@
                               final Map store )
       {
           super.deactivate( accessor, store );
  +
  +        if( accessor.containsKey( THREAD_NAME ) )
  +        {
  +            final String oldName =
  +                (String)store.get( THREAD_NAME );
  +            Thread.currentThread().setName( oldName );
  +        }
   
           if( accessor.containsKey( INPUT ) )
           {
  
  
  

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


Mime
View raw message