directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r411052 - in /directory/trunks/mina: core/src/main/java/org/apache/mina/common/ core/src/main/java/org/apache/mina/filter/ core/src/main/java/org/apache/mina/filter/thread/ core/src/test/java/org/apache/mina/filter/ core/src/test/java/org/a...
Date Fri, 02 Jun 2006 05:50:56 GMT
Author: trustin
Date: Thu Jun  1 22:50:55 2006
New Revision: 411052

URL: http://svn.apache.org/viewvc?rev=411052&view=rev
Log:
* Moved all thread pool classes to org.apache.mina.filter.thread
* Replaced the old ThreadPoolFilter with the new one
* Added default properties to ThreadPool
* Synchronized mismatches in behavior between the old version and the new version


Added:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/LeaderFollowersThreadPool.java
      - copied, changed from r411015, directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LeaderFollowersThreadPool.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPool.java
      - copied, changed from r411015, directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPool.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilterMBean.java
      - copied, changed from r411015, directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/filter/thread/ThreadPoolFilterRegressionTest.java
      - copied, changed from r411015, directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
    directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/thread/
    directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/thread/ExecutorThreadPool.java
      - copied, changed from r411015, directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/ExecutorThreadPool.java
Removed:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LeaderFollowersThreadPool.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPool.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolThreadPoolFilter.java
    directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
    directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/ExecutorThreadPool.java
Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
    directory/trunks/mina/java5/   (props changed)

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java?rev=411052&r1=411051&r2=411052&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/common/PooledThreadModel.java
Thu Jun  1 22:50:55 2006
@@ -18,7 +18,8 @@
  */
 package org.apache.mina.common;
 
-import org.apache.mina.filter.ThreadPoolFilter;
+import org.apache.mina.filter.thread.ThreadPool;
+import org.apache.mina.filter.thread.ThreadPoolFilter;
 
 /**
  * A {@link ThreadModel} which represents a thread model with an independant
@@ -38,16 +39,16 @@
     /**
      * @see ThreadPoolFilter#DEFAULT_MAXIMUM_POOL_SIZE
      */
-    public static final int DEFAULT_MAXIMUM_POOL_SIZE = ThreadPoolFilter.DEFAULT_MAXIMUM_POOL_SIZE;
+    public static final int DEFAULT_MAXIMUM_POOL_SIZE = ThreadPool.DEFAULT_MAXIMUM_POOL_SIZE;
 
     /**
      * @see ThreadPoolFilter#DEFAULT_KEEP_ALIVE_TIME
      */
-    public static final int DEFAULT_KEEP_ALIVE_TIME = ThreadPoolFilter.DEFAULT_KEEP_ALIVE_TIME;
+    public static final int DEFAULT_KEEP_ALIVE_TIME = ThreadPool.DEFAULT_KEEP_ALIVE_TIME;
     
     private static int id = 1;
     
-    private final ThreadPoolFilter pool = new ThreadPoolFilter();
+    private final ThreadPoolFilter filter = new ThreadPoolFilter();
 
     public PooledThreadModel()
     {
@@ -72,36 +73,36 @@
 
     public String getThreadNamePrefix()
     {
-        return pool.getThreadNamePrefix();
+        return filter.getThreadPool().getThreadNamePrefix();
     }
 
     public void setThreadNamePrefix( String threadNamePrefix )
     {
-        pool.setThreadNamePrefix( threadNamePrefix );
+        filter.getThreadPool().setThreadNamePrefix( threadNamePrefix );
     }
     
     public int getMaximumPoolSize()
     {
-        return pool.getMaximumPoolSize();
+        return filter.getThreadPool().getMaximumPoolSize();
     }
 
     public int getKeepAliveTime()
     {
-        return pool.getKeepAliveTime();
+        return filter.getThreadPool().getKeepAliveTime();
     }
 
     public void setMaximumPoolSize( int maximumPoolSize )
     {
-        pool.setMaximumPoolSize( maximumPoolSize );
+        filter.getThreadPool().setMaximumPoolSize( maximumPoolSize );
     }
 
     public void setKeepAliveTime( int keepAliveTime )
     {
-        pool.setKeepAliveTime( keepAliveTime );
+        filter.getThreadPool().setKeepAliveTime( keepAliveTime );
     }
 
     public void buildFilterChain( IoFilterChain chain ) throws Exception
     {
-        chain.addFirst( PooledThreadModel.class.getName(), pool );
+        chain.addFirst( PooledThreadModel.class.getName(), filter );
     }
 }

Copied: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/LeaderFollowersThreadPool.java
(from r411015, directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LeaderFollowersThreadPool.java)
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/LeaderFollowersThreadPool.java?p2=directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/LeaderFollowersThreadPool.java&p1=directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LeaderFollowersThreadPool.java&r1=411015&r2=411052&rev=411052&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/LeaderFollowersThreadPool.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/LeaderFollowersThreadPool.java
Thu Jun  1 22:50:55 2006
@@ -16,7 +16,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.mina.filter;
+package org.apache.mina.filter.thread;
 
 import org.apache.mina.util.BlockingQueue;
 import org.apache.mina.util.IdentityHashSet;
@@ -39,16 +39,6 @@
 public class LeaderFollowersThreadPool implements ThreadPool
 {
     /**
-     * Default maximum size of thread pool (16).
-     */
-    public static final int DEFAULT_MAXIMUM_POOL_SIZE = 16;
-
-    /**
-     * Default keep-alive time of thread pool (1 min).
-     */
-    public static final int DEFAULT_KEEP_ALIVE_TIME = 60 * 1000;
-
-    /**
      * A queue which contains {@link Integer}s which represents reusable
      * thread IDs.  {@link LeaderFollowersThreadPool.Worker} first checks this queue and
then
      * uses {@link #threadId} when no reusable thread ID is available.
@@ -180,6 +170,11 @@
     public void setKeepAliveTime( int keepAliveTime )
     {
         this.keepAliveTime = keepAliveTime;
+    }
+    
+    public boolean isStarted()
+    {
+        return leader != null;
     }
 
     public void init()

Copied: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPool.java
(from r411015, directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPool.java)
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPool.java?p2=directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPool.java&p1=directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPool.java&r1=411015&r2=411052&rev=411052&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPool.java (original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPool.java
Thu Jun  1 22:50:55 2006
@@ -16,7 +16,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.mina.filter;
+package org.apache.mina.filter.thread;
 
 /**
  * An interface for a pool of threads, capable of handling units of work that are <code>Runnable</code>.
@@ -27,6 +27,16 @@
 public interface ThreadPool
 {
     /**
+     * Default maximum size of thread pool (16).
+     */
+    static int DEFAULT_MAXIMUM_POOL_SIZE = 16;
+
+    /**
+     * Default keep-alive time of thread pool (1 min).
+     */
+    static int DEFAULT_KEEP_ALIVE_TIME = 60 * 1000;
+
+    /**
      * Submit a <code>Runnable</code> to this thread pool.
      *
      * @param runnable <code>Runnable</code> to submit to this pool
@@ -42,4 +52,54 @@
      * Destroy this pool.
      */
     void destroy();
+    
+    /**
+     * Returns <tt>true</tt> if and if only this pool is started.
+     */
+    boolean isStarted();
+    
+    /**
+     * Returns the name prefix string of the threads that this pool creates.
+     * 
+     * @return <tt>null</tt> if not supported
+     */
+    String getThreadNamePrefix();
+
+    /**
+     * Sets the name prefix string of the threads that this pool creates.
+     * This method does nothing if this property is not supported.
+     */
+    void setThreadNamePrefix( String threadNamePrefix );
+
+    /**
+     * Returns the current number of the threads which are serving the submissions.
+     */
+    int getPoolSize();
+
+    /**
+     * Returns the maximum number of the threads in this pool.
+     * 
+     * @return <tt>-1</tt> if not supported
+     */
+    int getMaximumPoolSize();
+
+    /**
+     * Returns the keep-alive time (milliseconds) of the threads in this pool.
+     * 
+     * @return <tt>-1</tt> if not supported
+     */
+    int getKeepAliveTime();
+
+    /**
+     * Sets the maximum number of the threads in this pool.
+     * This method does nothing if this property is not supported.
+     */
+    void setMaximumPoolSize( int maximumPoolSize );
+
+    
+    /**
+     * Sets the keep-alive time (milliseconds) of the threads in this pool.
+     * This method does nothing if this property is not supported.
+     */
+    void setKeepAliveTime( int keepAliveTime );
 }

Added: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java?rev=411052&view=auto
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java
(added)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilter.java
Thu Jun  1 22:50:55 2006
@@ -0,0 +1,308 @@
+package org.apache.mina.filter.thread;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoFilterAdapter;
+import org.apache.mina.common.IoFilterChain;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.util.ByteBufferUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A Thread-pooling filter.  This filter forwards {@link IoHandler} events to its thread
pool.
+ * <p>
+ * Use the {@link #init()} and {@link #destroy()} methods to force this filter
+ * to start/stop processing events. Alternatively, {@link #init()} will be
+ * called automatically the first time an instance of this filter is added
+ * to a filter chain. Calling {@link #destroy()} is not required either since
+ * all workers are daemon threads which means that any workers still alive
+ * when the JVM terminates will die automatically.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev: 350169 $, $Date: 2005-12-01 00:17:41 -0500 (Thu, 01 Dec 2005) $
+ */
+public class ThreadPoolFilter extends IoFilterAdapter
+{
+	private static final Logger logger = LoggerFactory.getLogger( ThreadPoolFilter.class.getName()
);
+	private final ThreadPool threadPool;
+
+    /**
+     * Creates a new instace with the default thread pool implementation
+     * (@link LeaderFollowersThreadPool}).
+     */
+    public ThreadPoolFilter()
+    {
+        this( new LeaderFollowersThreadPool() );
+    }
+    
+    /**
+     * Creates a new instance with the specified <tt>threadPool</tt>.
+     */
+	public ThreadPoolFilter( ThreadPool threadPool )
+	{
+        if( threadPool == null )
+        {
+            throw new NullPointerException( "threadPool" );
+        }
+
+		this.threadPool = threadPool;
+	}
+
+	public void init()
+	{
+		threadPool.init();
+	}
+
+	public void destroy()
+	{
+		threadPool.destroy();
+	}
+    
+    public void onPreAdd( IoFilterChain parent, String name, NextFilter nextFilter )
+            throws Exception
+    {
+        if( !getThreadPool().isStarted() )
+        {
+            init();
+        }
+    }
+
+    /**
+     * Returns the underlying {@link ThreadPool} instance this filter uses.
+     */
+    public ThreadPool getThreadPool()
+    {
+        return threadPool;
+    }
+
+	private void fireEvent( NextFilter nextFilter, IoSession session,
+							EventType type, Object data )
+	{
+		Event event = new Event( type, nextFilter, data );
+		SessionBuffer buf = SessionBuffer.getSessionBuffer( session );
+
+		synchronized( buf.eventQueue )
+		{
+			buf.eventQueue.add( event );
+			if( buf.processingCompleted )
+			{
+				buf.processingCompleted = false;
+				if ( logger.isDebugEnabled() ) {
+					logger.debug( "Launching thread for " + session.getRemoteAddress() );
+				}
+
+                threadPool.submit( new ProcessEventsRunnable( buf ) );
+			}
+		}
+	}
+
+	private static class SessionBuffer
+	{
+		private static final String KEY = SessionBuffer.class.getName() + ".KEY";
+
+		private static SessionBuffer getSessionBuffer( IoSession session )
+		{
+			synchronized( session )
+			{
+				SessionBuffer buf = (SessionBuffer)session.getAttribute( KEY );
+				if( buf == null )
+				{
+					buf = new SessionBuffer( session );
+					session.setAttribute( KEY, buf );
+				}
+				return buf;
+			}
+		}
+
+		private final IoSession session;
+		private final List eventQueue = new ArrayList();
+		private boolean processingCompleted = true;
+
+		private SessionBuffer( IoSession session )
+		{
+			this.session = session;
+		}
+	}
+
+	protected static class EventType
+	{
+		public static final EventType OPENED = new EventType( "OPENED" );
+
+		public static final EventType CLOSED = new EventType( "CLOSED" );
+
+		public static final EventType READ = new EventType( "READ" );
+
+		public static final EventType WRITTEN = new EventType( "WRITTEN" );
+
+		public static final EventType RECEIVED = new EventType( "RECEIVED" );
+
+		public static final EventType SENT = new EventType( "SENT" );
+
+		public static final EventType IDLE = new EventType( "IDLE" );
+
+		public static final EventType EXCEPTION = new EventType( "EXCEPTION" );
+
+		private final String value;
+
+		private EventType( String value )
+		{
+			this.value = value;
+		}
+
+		public String toString()
+		{
+			return value;
+		}
+	}
+
+	protected static class Event
+	{
+		private final EventType type;
+		private final NextFilter nextFilter;
+		private final Object data;
+
+		Event( EventType type, NextFilter nextFilter, Object data )
+		{
+			this.type = type;
+			this.nextFilter = nextFilter;
+			this.data = data;
+		}
+
+		public Object getData()
+		{
+			return data;
+		}
+
+		public NextFilter getNextFilter()
+		{
+			return nextFilter;
+		}
+
+		public EventType getType()
+		{
+			return type;
+		}
+	}
+
+	public void sessionCreated( NextFilter nextFilter, IoSession session )
+	{
+		nextFilter.sessionCreated( session );
+	}
+
+	public void sessionOpened( NextFilter nextFilter,
+							   IoSession session )
+	{
+		fireEvent( nextFilter, session, EventType.OPENED, null );
+	}
+
+	public void sessionClosed( NextFilter nextFilter,
+							   IoSession session )
+	{
+		fireEvent( nextFilter, session, EventType.CLOSED, null );
+	}
+
+	public void sessionIdle( NextFilter nextFilter,
+							 IoSession session, IdleStatus status )
+	{
+		fireEvent( nextFilter, session, EventType.IDLE, status );
+	}
+
+	public void exceptionCaught( NextFilter nextFilter,
+								 IoSession session, Throwable cause )
+	{
+		fireEvent( nextFilter, session, EventType.EXCEPTION, cause );
+	}
+
+	public void messageReceived( NextFilter nextFilter,
+								 IoSession session, Object message )
+	{
+		ByteBufferUtil.acquireIfPossible( message );
+		fireEvent( nextFilter, session, EventType.RECEIVED, message );
+	}
+
+	public void messageSent( NextFilter nextFilter,
+							 IoSession session, Object message )
+	{
+		ByteBufferUtil.acquireIfPossible( message );
+		fireEvent( nextFilter, session, EventType.SENT, message );
+	}
+
+	protected void processEvent( NextFilter nextFilter, IoSession session, EventType type, Object
data )
+	{
+		if( type == EventType.RECEIVED )
+		{
+			nextFilter.messageReceived( session, data );
+			ByteBufferUtil.releaseIfPossible( data );
+		}
+		else if( type == EventType.SENT )
+		{
+			nextFilter.messageSent( session, data );
+			ByteBufferUtil.releaseIfPossible( data );
+		}
+		else if( type == EventType.EXCEPTION )
+		{
+			nextFilter.exceptionCaught( session, (Throwable)data );
+		}
+		else if( type == EventType.IDLE )
+		{
+			nextFilter.sessionIdle( session, (IdleStatus)data );
+		}
+		else if( type == EventType.OPENED )
+		{
+			nextFilter.sessionOpened( session );
+		}
+		else if( type == EventType.CLOSED )
+		{
+			nextFilter.sessionClosed( session );
+		}
+	}
+
+	public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest
)
+	{
+		nextFilter.filterWrite( session, writeRequest );
+	}
+
+	public void filterClose( NextFilter nextFilter, IoSession session ) throws Exception
+	{
+		nextFilter.filterClose( session );
+	}
+
+	private class ProcessEventsRunnable implements Runnable
+	{
+		private final SessionBuffer buffer;
+
+		ProcessEventsRunnable( SessionBuffer buffer )
+		{
+			this.buffer = buffer;
+		}
+
+		public void run()
+		{
+			while( true )
+			{
+				Event event;
+
+				synchronized( buffer.eventQueue )
+				{
+					if( buffer.eventQueue.isEmpty() )
+					{
+						buffer.processingCompleted = true;
+						break;
+					}
+
+					event = ( Event ) buffer.eventQueue.remove( 0 );
+				}
+
+				processEvent( event.getNextFilter(), buffer.session, event.getType(), event.getData()
);
+			}
+
+			if ( logger.isDebugEnabled() ) {
+				logger.debug( "Exiting since queue is empty for " + buffer.session.getRemoteAddress()
);
+			}
+		}
+	}
+}

Copied: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilterMBean.java
(from r411015, directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java)
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilterMBean.java?p2=directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilterMBean.java&p1=directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java&r1=411015&r2=411052&rev=411052&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/thread/ThreadPoolFilterMBean.java
Thu Jun  1 22:50:55 2006
@@ -1,4 +1,4 @@
-package org.apache.mina.filter;
+package org.apache.mina.filter.thread;
 
 public interface ThreadPoolFilterMBean
 {

Copied: directory/trunks/mina/core/src/test/java/org/apache/mina/filter/thread/ThreadPoolFilterRegressionTest.java
(from r411015, directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java)
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/test/java/org/apache/mina/filter/thread/ThreadPoolFilterRegressionTest.java?p2=directory/trunks/mina/core/src/test/java/org/apache/mina/filter/thread/ThreadPoolFilterRegressionTest.java&p1=directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java&r1=411015&r2=411052&rev=411052&view=diff
==============================================================================
--- directory/trunks/mina/core/src/test/java/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
(original)
+++ directory/trunks/mina/core/src/test/java/org/apache/mina/filter/thread/ThreadPoolFilterRegressionTest.java
Thu Jun  1 22:50:55 2006
@@ -1,4 +1,4 @@
-package org.apache.mina.filter;
+package org.apache.mina.filter.thread;
 
 import java.net.SocketAddress;
 
@@ -41,13 +41,13 @@
     public void setUp() throws Exception
     {
         filter = new ThreadPoolFilter();
-        filter.start();
+        filter.init();
     }
     
     public void tearDown() throws Exception
     {
-        filter.stop();
-        Assert.assertEquals( 0, filter.getPoolSize() );
+        filter.destroy();
+        Assert.assertEquals( 0, filter.getThreadPool().getPoolSize() );
         filter = null;
     }
     
@@ -69,7 +69,7 @@
         };
         final int end = sessions.length - 1;
         final ThreadPoolFilter filter = this.filter;
-        filter.setKeepAliveTime( 3000 );
+        filter.getThreadPool().setKeepAliveTime( 3000 );
         
         for( int i = 0; i < 1000000 ; i++ )
         {
@@ -88,7 +88,7 @@
         
         Thread.sleep( 3500 );
         
-        Assert.assertEquals( 1, filter.getPoolSize() );
+        Assert.assertEquals( 1, filter.getThreadPool().getPoolSize() );
     }
     
     public void testShutdown() throws Exception

Propchange: directory/trunks/mina/java5/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jun  1 22:50:55 2006
@@ -0,0 +1,4 @@
+
+target
+.classpath
+.project

Copied: directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/thread/ExecutorThreadPool.java
(from r411015, directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/ExecutorThreadPool.java)
URL: http://svn.apache.org/viewvc/directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/thread/ExecutorThreadPool.java?p2=directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/thread/ExecutorThreadPool.java&p1=directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/ExecutorThreadPool.java&r1=411015&r2=411052&rev=411052&view=diff
==============================================================================
--- directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/ExecutorThreadPool.java
(original)
+++ directory/trunks/mina/java5/src/main/java/org/apache/mina/filter/thread/ExecutorThreadPool.java
Thu Jun  1 22:50:55 2006
@@ -16,12 +16,17 @@
  *   limitations under the License.
  *
  */
-package org.apache.mina.filter;
+package org.apache.mina.filter.thread;
 
 import java.util.concurrent.Executor;
 
 /**
- * ThreadPool implementation that hands excecution off to a Executor
+ * {@link ThreadPool} implementation that hands excecution off to an
+ * {@link Executor}.  This pool doesn't manage the life cycle of the
+ * underlying {@link Executor} at all.  {@link #isStarted()} will always
+ * return <tt>true</tt>.  Other properties won't be supported, either.
+ * Please get the underlying {@link Executor} by calling {@link #getExecutor()}
+ * to adjust implementation-specific parameters.
  *
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev: 400068 $, $Date: 2006-05-05 12:56:58Z $
@@ -30,10 +35,21 @@
 {
     private final Executor executor;
 
+    /**
+     * Creates a new instance with the specified <tt>executor</tt>.
+     */
     public ExecutorThreadPool( Executor executor )
     {
         this.executor = executor;
     }
+    
+    /**
+     * Returns the underlying executor this thread pool wraps.
+     */
+    public Executor getExecutor()
+    {
+        return executor;
+    }
 
     public void init()
     {
@@ -46,5 +62,42 @@
     public void submit( Runnable runnable )
     {
         executor.execute( runnable );
+    }
+
+    public boolean isStarted()
+    {
+        return true;
+    }
+
+    public String getThreadNamePrefix()
+    {
+        return null;
+    }
+
+    public void setThreadNamePrefix( String threadNamePrefix )
+    {
+    }
+
+    public int getPoolSize()
+    {
+        return -1;
+    }
+
+    public int getMaximumPoolSize()
+    {
+        return -1;
+    }
+
+    public int getKeepAliveTime()
+    {
+        return -1;
+    }
+
+    public void setMaximumPoolSize( int maximumPoolSize )
+    {
+    }
+
+    public void setKeepAliveTime( int keepAliveTime )
+    {
     }
 }



Mime
View raw message