avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: avalon-excalibur/thread/src/test/org/apache/avalon/excalibur/thread/impl/test DefaultThreadPoolTestCase.java
Date Fri, 11 Apr 2003 06:00:29 GMT
donaldp     2003/04/10 23:00:29

  Modified:    thread   build.xml default.properties
               thread/src/java/org/apache/avalon/excalibur/thread/impl
                        BasicThreadPool.java DefaultThreadPool.java
                        ResourceLimitingThreadPool.java
                        SimpleWorkerThread.java
               thread/src/test/org/apache/avalon/excalibur/thread/impl/test
                        DefaultThreadPoolTestCase.java
  Log:
  Decouple from threadcontext
  
  Revision  Changes    Path
  1.36      +0 -2      avalon-excalibur/thread/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/build.xml,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- build.xml	5 Apr 2003 20:48:40 -0000	1.35
  +++ build.xml	11 Apr 2003 06:00:28 -0000	1.36
  @@ -16,7 +16,6 @@
           <pathelement location="${avalon-logkit.jar}"/> <!-- deprecated -->
           <pathelement location="${logkit.jar}"/>
           <pathelement location="${avalon-framework.jar}"/>
  -        <pathelement location="${excalibur-threadcontext.jar}"/>
           <pathelement location="${excalibur-instrument.jar}"/>
           <pathelement location="${commons-collections.jar}"/>
           <pathelement location="${util.concurrent.jar}"/>
  @@ -47,7 +46,6 @@
       <target name="dependencies" description="Check dependencies" unless="skip.dependencies">
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkCommon"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkLogkit"/>
  -        <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkThreadcontext"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkInstrument"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkFramework"/>
           <ant antfile="${depchecker.prefix}/depchecker.xml" target="checkPool"/>
  
  
  
  1.27      +0 -5      avalon-excalibur/thread/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/default.properties,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- default.properties	5 Apr 2003 19:39:38 -0000	1.26
  +++ default.properties	11 Apr 2003 06:00:28 -0000	1.27
  @@ -22,11 +22,6 @@
   avalon-framework.lib=${avalon-framework.home}/target/lib
   avalon-framework.jar=${avalon-framework.lib}/avalon-framework.jar
   
  -# ----- Excalibur ThreadContext, version 1.0 or later -----
  -excalibur-threadcontext.home=${basedir}/../threadcontext/dist
  -excalibur-threadcontext.lib=${excalibur-threadcontext.home}
  -excalibur-threadcontext.jar=${excalibur-threadcontext.lib}/excalibur-threadcontext-1.0.jar
  -
   # ----- Excalibur pool, version 1.1 or later -----
   excalibur-pool.home=${basedir}/../pool/dist
   excalibur-pool.lib=${excalibur-pool.home}
  
  
  
  1.14      +3 -18     avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/BasicThreadPool.java
  
  Index: BasicThreadPool.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/BasicThreadPool.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BasicThreadPool.java	10 Apr 2003 16:18:32 -0000	1.13
  +++ BasicThreadPool.java	11 Apr 2003 06:00:29 -0000	1.14
  @@ -61,7 +61,6 @@
   import org.apache.excalibur.thread.ThreadControl;
   import org.apache.excalibur.thread.impl.AbstractThreadPool;
   import org.apache.excalibur.thread.impl.WorkerThread;
  -import org.apache.excalibur.threadcontext.ThreadContext;
   
   /**
    * The ThreadPool that binds to Legacy Pooling implementation.
  @@ -85,24 +84,16 @@
       private Logger m_logger;
   
       /**
  -     * The base ThreadContext that can be duplicated for
  -     * each thread.
  -     */
  -    private ThreadContext m_context;
  -
  -    /**
        * Create a new ThreadPool with specified capacity.
        *
        * @param threadGroup the thread group used in pool
        * @param name the name of pool (used in naming threads)
        * @param pool the underling pool
  -     * @param context the thread context associated with pool (May be null).
        * @throws Exception if unable to create pool
        */
       public BasicThreadPool( final ThreadGroup threadGroup,
                               final String name,
  -                            final Pool pool,
  -                            final ThreadContext context )
  +                            final Pool pool )
           throws Exception
       {
           super( name, threadGroup );
  @@ -112,7 +103,6 @@
           }
   
           m_pool = pool;
  -        m_context = context;
       }
   
       /**
  @@ -154,13 +144,8 @@
        */
       protected WorkerThread newWorkerThread( final String name )
       {
  -        ThreadContext context = null;
  -        if( null != m_context )
  -        {
  -            context = m_context.duplicate();
  -        }
           final SimpleWorkerThread thread =
  -            new SimpleWorkerThread( this, getThreadGroup(), name, context );
  +            new SimpleWorkerThread( this, getThreadGroup(), name );
           ContainerUtil.enableLogging( thread, m_logger.getChildLogger( "worker" ) );
           return thread;
       }
  @@ -216,7 +201,7 @@
   
       /**
        * Release worker back into pool.
  -     * 
  +     *
        * FIX ME: do we want to verify if it is interrupted or interrupt the worker
        *         thread?
        *
  
  
  
  1.19      +4 -13     avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/DefaultThreadPool.java
  
  Index: DefaultThreadPool.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/DefaultThreadPool.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- DefaultThreadPool.java	5 Apr 2003 19:39:38 -0000	1.18
  +++ DefaultThreadPool.java	11 Apr 2003 06:00:29 -0000	1.19
  @@ -61,7 +61,6 @@
   import org.apache.avalon.framework.logger.LogKitLogger;
   import org.apache.avalon.framework.logger.Loggable;
   import org.apache.avalon.framework.logger.Logger;
  -import org.apache.excalibur.threadcontext.ThreadContext;
   
   /**
    * This class is the public frontend for the thread pool code.
  @@ -82,31 +81,23 @@
           this( "Worker Pool", capacity );
       }
   
  -    public DefaultThreadPool( final String name, final int capacity )
  -        throws Exception
  -    {
  -        this( name, capacity, null );
  -    }
  -
       public DefaultThreadPool( final String name,
  -                              final int capacity,
  -                              final ThreadContext context )
  +                              final int capacity )
           throws Exception
       {
           super( name );
           m_underlyingPool = new SoftResourceLimitingPool( this, capacity );
  -        m_pool = new BasicThreadPool( this, name, m_underlyingPool, context );
  +        m_pool = new BasicThreadPool( this, name, m_underlyingPool );
       }
   
       public DefaultThreadPool( final String name,
                                 final int min,
  -                  final int max,
  -                              final ThreadContext context )
  +                              final int max )
           throws Exception
       {
           super( name );
           m_underlyingPool = new SoftResourceLimitingPool( this, min, max );
  -        m_pool = new BasicThreadPool( this, name, m_underlyingPool, context );
  +        m_pool = new BasicThreadPool( this, name, m_underlyingPool );
       }
   
       public void setLogger( final org.apache.log.Logger logger )
  
  
  
  1.15      +2 -32     avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/ResourceLimitingThreadPool.java
  
  Index: ResourceLimitingThreadPool.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/ResourceLimitingThreadPool.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ResourceLimitingThreadPool.java	23 Mar 2003 03:00:44 -0000	1.14
  +++ ResourceLimitingThreadPool.java	11 Apr 2003 06:00:29 -0000	1.15
  @@ -61,7 +61,6 @@
   import org.apache.excalibur.instrument.Instrument;
   import org.apache.excalibur.instrument.Instrumentable;
   import org.apache.excalibur.thread.ThreadControl;
  -import org.apache.excalibur.threadcontext.ThreadContext;
   
   /**
    * A Thread Pool which can be configured to have a hard limit on the maximum number of
threads
  @@ -140,35 +139,6 @@
                                          final long blockTimeout,
                                          final long trimInterval )
       {
  -        this( name, max, maxStrict, blocking, blockTimeout, trimInterval, null );
  -    }
  -
  -    /**
  -     * Creates a new <code>ResourceLimitingThreadPool</code>.
  -     *
  -     * @param name Name which will used as the thread group name as well as the prefix
of the
  -     *  names of all threads created by the pool.
  -     * @param max Maximum number of WorkerThreads which can be stored in the pool,
  -     *  0 implies no limit.
  -     * @param maxStrict true if the pool should never allow more than max WorkerThreads
to
  -     *  be created.  Will cause an exception to be thrown if more than max WorkerThreads
are
  -     *  requested and blocking is false.
  -     * @param blocking true if the pool should cause a thread calling get() to block when
  -     *  WorkerThreads are not currently available on the pool.
  -     * @param blockTimeout The maximum amount of time, in milliseconds, that a call to
get() will
  -     *  block before an exception is thrown.  A value of 0 implies an indefinate wait.
  -     * @param trimInterval The minimum interval with which old unused WorkerThreads will
be
  -     *  removed from the pool.  A value of 0 will cause the pool to never trim WorkerThreads.
  -     * @param context ThreadContext
  -     */
  -    public ResourceLimitingThreadPool( final String name,
  -                                       final int max,
  -                                       final boolean maxStrict,
  -                                       final boolean blocking,
  -                                       final long blockTimeout,
  -                                       final long trimInterval,
  -                                       final ThreadContext context )
  -    {
           super( name );
   
           m_underlyingPool =
  @@ -177,7 +147,7 @@
                                         trimInterval );
           try
           {
  -            m_pool = new BasicThreadPool( this, name, m_underlyingPool, context );
  +            m_pool = new BasicThreadPool( this, name, m_underlyingPool );
           }
           catch( Exception e )
           {
  
  
  
  1.7       +1 -17     avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/SimpleWorkerThread.java
  
  Index: SimpleWorkerThread.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/java/org/apache/avalon/excalibur/thread/impl/SimpleWorkerThread.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SimpleWorkerThread.java	13 Mar 2003 05:48:11 -0000	1.6
  +++ SimpleWorkerThread.java	11 Apr 2003 06:00:29 -0000	1.7
  @@ -55,7 +55,6 @@
   import org.apache.avalon.framework.logger.Logger;
   import org.apache.excalibur.thread.impl.AbstractThreadPool;
   import org.apache.excalibur.thread.impl.WorkerThread;
  -import org.apache.excalibur.threadcontext.ThreadContext;
   
   /**
    * This class extends the Thread class to add recyclable functionalities.
  @@ -69,18 +68,15 @@
       implements Poolable, LogEnabled
   {
       private Logger m_logger;
  -    private ThreadContext m_context;
   
       /**
        * Allocates a new <code>Worker</code> object.
        */
       protected SimpleWorkerThread( final AbstractThreadPool pool,
                                     final ThreadGroup group,
  -                                  final String name,
  -                                  final ThreadContext context )
  +                                  final String name )
       {
           super( pool, group, name );
  -        m_context = context;
       }
   
       public void enableLogging( final Logger logger )
  @@ -88,18 +84,6 @@
           m_logger = logger;
       }
   
  -    protected void postExecute()
  -    {
  -        super.postExecute();
  -        ThreadContext.setThreadContext( null );
  -    }
  -
  -    protected void preExecute()
  -    {
  -        super.preExecute();
  -        ThreadContext.setThreadContext( m_context );
  -    }
  -    
       protected void debug( final String message )
       {
           if ( m_logger.isDebugEnabled() )
  
  
  
  1.8       +16 -26    avalon-excalibur/thread/src/test/org/apache/avalon/excalibur/thread/impl/test/DefaultThreadPoolTestCase.java
  
  Index: DefaultThreadPoolTestCase.java
  ===================================================================
  RCS file: /home/cvs/avalon-excalibur/thread/src/test/org/apache/avalon/excalibur/thread/impl/test/DefaultThreadPoolTestCase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultThreadPoolTestCase.java	22 Mar 2003 12:46:55 -0000	1.7
  +++ DefaultThreadPoolTestCase.java	11 Apr 2003 06:00:29 -0000	1.8
  @@ -3,34 +3,34 @@
    ============================================================================
                      The Apache Software License, Version 1.1
    ============================================================================
  - 
  +
    Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  - 
  +
    Redistribution and use in source and binary forms, with or without modifica-
    tion, are permitted provided that the following conditions are met:
  - 
  +
    1. Redistributions of  source code must  retain the above copyright  notice,
       this list of conditions and the following disclaimer.
  - 
  +
    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.
  - 
  +
    3. The end-user documentation included with the redistribution, if any, must
       include  the following  acknowledgment:  "This product includes  software
       developed  by the  Apache Software Foundation  (http://www.apache.org/)."
       Alternately, this  acknowledgment may  appear in the software itself,  if
       and wherever such third-party acknowledgments normally appear.
  - 
  - 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  -    must not be used to endorse or promote products derived from this  software 
  -    without  prior written permission. For written permission, please contact 
  +
  + 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  +    must not be used to endorse or promote products derived from this  software
  +    without  prior written permission. For written permission, please contact
       apache@apache.org.
  - 
  +
    5. Products  derived from this software may not  be called "Apache", nor may
       "Apache" appear  in their name,  without prior written permission  of the
       Apache Software Foundation.
  - 
  +
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  @@ -41,22 +41,17 @@
    ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
    (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
    THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  - 
  +
    This software  consists of voluntary contributions made  by many individuals
  - on  behalf of the Apache Software  Foundation. For more  information on the 
  + on  behalf of the Apache Software  Foundation. For more  information on the
    Apache Software Foundation, please see <http://www.apache.org/>.
  - 
  +
   */
   package org.apache.avalon.excalibur.thread.impl.test;
   
  -import java.util.HashMap;
  -
   import junit.framework.TestCase;
  -
   import org.apache.avalon.excalibur.thread.impl.DefaultThreadPool;
   import org.apache.avalon.framework.logger.ConsoleLogger;
  -import org.apache.excalibur.threadcontext.ThreadContext;
  -import org.apache.excalibur.threadcontext.impl.DefaultThreadContextPolicy;
   
   /**
    * TestCase for DefaultThreadPool.
  @@ -74,11 +69,7 @@
       public void testWithThreadContext()
           throws Exception
       {
  -        final DefaultThreadContextPolicy policy = new DefaultThreadContextPolicy();
  -        final HashMap map = new HashMap( 1 );
  -        map.put( DefaultThreadContextPolicy.CLASSLOADER, getClass().getClassLoader() );
  -        final ThreadContext threadContext = new ThreadContext( policy, map );
  -        final DefaultThreadPool pool = new DefaultThreadPool( "default", 10, threadContext
);
  +        final DefaultThreadPool pool = new DefaultThreadPool( "default", 10 );
           pool.setDaemon( false );
           pool.enableLogging( new ConsoleLogger() );
           pool.execute( new DummyRunnable() );
  @@ -87,8 +78,7 @@
       public void testWithoutThreadContext()
           throws Exception
       {
  -        final ThreadContext threadContext = ThreadContext.getThreadContext();
  -        final DefaultThreadPool pool = new DefaultThreadPool( "default", 10, threadContext
);
  +        final DefaultThreadPool pool = new DefaultThreadPool( "default", 10 );
           pool.setDaemon( false );
           pool.enableLogging( new ConsoleLogger() );
           pool.execute( new DummyRunnable() );
  
  
  

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


Mime
View raw message