cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r567014 - in /cocoon/trunk/core/cocoon-thread: cocoon-thread-api/src/main/java/org/apache/cocoon/components/thread/ cocoon-thread-impl/ cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/ cocoon-thread-impl/src/main/resour...
Date Fri, 17 Aug 2007 11:03:55 GMT
Author: cziegeler
Date: Fri Aug 17 04:03:48 2007
New Revision: 567014

URL: http://svn.apache.org/viewvc?view=rev&rev=567014
Log:
Make the thread module independent from spring and clean up code formatting.

Removed:
    cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/resources/META-INF/cocoon/properties/
Modified:
    cocoon/trunk/core/cocoon-thread/cocoon-thread-api/src/main/java/org/apache/cocoon/components/thread/ThreadPool.java
    cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/pom.xml
    cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
    cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultThreadPool.java
    cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/resources/META-INF/cocoon/spring/cocoon-thread-impl.xml
    cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/test/java/org/apache/cocoon/components/thread/DefaultThreadPoolTestCase.java

Modified: cocoon/trunk/core/cocoon-thread/cocoon-thread-api/src/main/java/org/apache/cocoon/components/thread/ThreadPool.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-thread/cocoon-thread-api/src/main/java/org/apache/cocoon/components/thread/ThreadPool.java?view=diff&rev=567014&r1=567013&r2=567014
==============================================================================
--- cocoon/trunk/core/cocoon-thread/cocoon-thread-api/src/main/java/org/apache/cocoon/components/thread/ThreadPool.java
(original)
+++ cocoon/trunk/core/cocoon-thread/cocoon-thread-api/src/main/java/org/apache/cocoon/components/thread/ThreadPool.java
Fri Aug 17 04:03:48 2007
@@ -19,7 +19,7 @@
 /**
  * The ThreadPool interface gives access to methods needed to inspect and use of
  * a pool of threads
- * 
+ *
  * @version $Id$
  */
 public interface ThreadPool {
@@ -28,34 +28,34 @@
     // --------------------------------------------------------
 
     /** The default queue size */
-    public static int DEFAULT_QUEUE_SIZE = -1;
+    int DEFAULT_QUEUE_SIZE = -1;
 
     /** The default maximum pool size */
-    public static int DEFAULT_MAX_POOL_SIZE = 5;
+    int DEFAULT_MAX_POOL_SIZE = 5;
 
     /** The default minimum pool size */
-    public static int DEFAULT_MIN_POOL_SIZE = 5;
+    int DEFAULT_MIN_POOL_SIZE = 5;
 
     /** The default thread priority */
-    public static String DEFAULT_THREAD_PRIORITY = "NORM";
+    String DEFAULT_THREAD_PRIORITY = "NORM";
 
     /** The default daemon mode */
-    public static boolean DEFAULT_DAEMON_MODE = false;
+    boolean DEFAULT_DAEMON_MODE = false;
 
     /** The default keep alive time */
-    public static long DEFAULT_KEEP_ALIVE_TIME = 60000L;
+    long DEFAULT_KEEP_ALIVE_TIME = 60000L;
 
     /** The default way to shutdown gracefully */
-    public static boolean DEFAULT_SHUTDOWN_GRACEFUL = false;
+    boolean DEFAULT_SHUTDOWN_GRACEFUL = false;
 
     /** The default shutdown waittime time */
-    public static int DEFAULT_SHUTDOWN_WAIT_TIME = -1;
+    int DEFAULT_SHUTDOWN_WAIT_TIME = -1;
 
     /** The default shutdown waittime time */
-    public static String DEFAULT_THREADPOOL_NAME = "default";
+    String DEFAULT_THREADPOOL_NAME = "default";
 
     /** The default shutdown waittime time */
-    public static String DEFAULT_BLOCK_POLICY = "RUN";
+    String DEFAULT_BLOCK_POLICY = "RUN";
 
     /** ThreadPool block policy ABORT */
     String POLICY_ABORT = "ABORT";
@@ -79,195 +79,195 @@
     // ----------------------------------------------------------------
 
     /**
-         * Gets the block policy
-         * 
-         * @return Returns the blockPolicy.
-         */
-    public String getBlockPolicy();
-
-    /**
-         * Gets the maximum queue size
-         * 
-         * @return maximum size of the queue (0 if isQueued() == false)
-         */
-    public int getMaxQueueSize();
-
-    /**
-         * Gets the name of the thread pool
-         * 
-         * @return name of the thread pool
-         */
-    public String getName();
-
-    /**
-         * Gets the priority used to create Threads
-         * 
-         * @return {@link Thread#MIN_PRIORITY}, {@link Thread#NORM_PRIORITY},
-         *         or {@link Thread#MAX_PRIORITY}
-         */
-    public int getPriority();
-
-    /**
-         * Gets the queue size of the thread pool
-         * 
-         * @return current size of the queue (0 if isQueued() == false)
-         */
-    public int getQueueSize();
-
-    /**
-         * Whether this DefaultThreadPool has a queue
-         * 
-         * @return Returns the m_isQueued.
-         */
-    public boolean isQueued();
-
-    /**
-         * Execute a command
-         * 
-         * @param command
-         *                The {@link Runnable} to execute
-         * 
-         * @throws InterruptedException
-         *                 In case of interruption
-         */
-    public void execute(Runnable command) throws InterruptedException;
-
-    /**
-         * Set the blocking policy
-         * 
-         * @param blockPolicy
-         *                The blocking policy value
-         */
+     * Gets the block policy
+     *
+     * @return Returns the blockPolicy.
+     */
+    String getBlockPolicy();
+
+    /**
+     * Gets the maximum queue size
+     *
+     * @return maximum size of the queue (0 if isQueued() == false)
+     */
+    int getMaxQueueSize();
+
+    /**
+     * Gets the name of the thread pool
+     *
+     * @return name of the thread pool
+     */
+    String getName();
+
+    /**
+     * Gets the priority used to create Threads
+     *
+     * @return {@link Thread#MIN_PRIORITY}, {@link Thread#NORM_PRIORITY},
+     *         or {@link Thread#MAX_PRIORITY}
+     */
+    int getPriority();
+
+    /**
+     * Gets the queue size of the thread pool
+     *
+     * @return current size of the queue (0 if isQueued() == false)
+     */
+    int getQueueSize();
+
+    /**
+     * Whether this DefaultThreadPool has a queue
+     *
+     * @return Returns the m_isQueued.
+     */
+    boolean isQueued();
+
+    /**
+     * Execute a command
+     *
+     * @param command
+     *                The {@link Runnable} to execute
+     *
+     * @throws InterruptedException
+     *                 In case of interruption
+     */
+    void execute(Runnable command) throws InterruptedException;
+
+    /**
+     * Set the blocking policy
+     *
+     * @param blockPolicy
+     *                The blocking policy value
+     */
     void setBlockPolicy(String blockPolicy);
 
     /**
-         * DOCUMENT ME!
-         * 
-         * @param name
-         *                The name to set.
-         */
+     * DOCUMENT ME!
+     *
+     * @param name
+     *                The name to set.
+     */
     void setName(String name);
 
     /**
-         * Sets the shutdownGraceful (true if graceful)
-         * 
-         * @param shutdownGraceful
-         *                The shutdownGraceful to set.
-         */
+     * Sets the shutdownGraceful (true if graceful)
+     *
+     * @param shutdownGraceful
+     *                The shutdownGraceful to set.
+     */
     void setShutdownGraceful(boolean shutdownGraceful);
 
     /**
-         * Returns true if shutdown is graceful
-         * 
-         * @return Returns the shutdownGraceful.
-         */
-    public boolean isShutdownGraceful();
+     * Returns true if shutdown is graceful
+     *
+     * @return Returns the shutdownGraceful.
+     */
+    boolean isShutdownGraceful();
 
     /**
-         * Sets the shutdownWaitTime in milliseconds
-         * 
-         * @param shutdownWaitTimeMs
-         *                The shutdownWaitTimeMs to set.
-         */
+     * Sets the shutdownWaitTime in milliseconds
+     *
+     * @param shutdownWaitTimeMs
+     *                The shutdownWaitTimeMs to set.
+     */
     void setShutdownWaitTimeMs(int shutdownWaitTimeMs);
 
     /**
-         * Gets the shutdownWaitTime in milliseconds
-         * 
-         * @return Returns the shutdownWaitTimeMs.
-         */
-    public int getShutdownWaitTimeMs();
-
-    /**
-         * Gets the keepAliveTime in milliseconds
-         * 
-         * @return the keepAliveTime
-         */
-    public long getKeepAliveTime();
-
-    /**
-         * Sets the keepAliveTime in milliseconds
-         * 
-         * @param keepAliveTime
-         *                the keepAliveTime to set
-         */
-    public void setKeepAliveTime(long keepAliveTime);
-
-    /**
-         * Gets the maximum pool size
-         * 
-         * @return the maxPoolSize
-         */
-    public int getMaxPoolSize();
-
-    /**
-         * Sets the maximum pool size
-         * 
-         * @param maxPoolSize
-         *                the maxPoolSize to set
-         */
-    public void setMaxPoolSize(int maxPoolSize);
-
-    /**
-         * Gets the minimum pool size
-         * 
-         * @return the minPoolSize
-         */
-    public int getMinPoolSize();
-
-    /**
-         * Sets the minimum pool size
-         * 
-         * @param minPoolSize
-         *                the minPoolSize to set
-         */
-    public void setMinPoolSize(int minPoolSize);
-
-    /**
-         * Sets the priority of this thread pool: {@link Thread#MIN_PRIORITY},
-         * {@link Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY}
-         * 
-         * @param priority
-         *                the priority to set
-         */
-    public void setPriority(int priority);
-
-    /**
-         * Sets the queue size of the thread pool
-         * 
-         * @param queueSize
-         *                the queueSize to set
-         */
-    public void setQueueSize(int queueSize);
-
-    /**
-         * Terminates all threads possibly awaiting processing all elements
-         * currently in queue.
-         */
+     * Gets the shutdownWaitTime in milliseconds
+     *
+     * @return Returns the shutdownWaitTimeMs.
+     */
+    int getShutdownWaitTimeMs();
+
+    /**
+     * Gets the keepAliveTime in milliseconds
+     *
+     * @return the keepAliveTime
+     */
+    long getKeepAliveTime();
+
+    /**
+     * Sets the keepAliveTime in milliseconds
+     *
+     * @param keepAliveTime
+     *                the keepAliveTime to set
+     */
+    void setKeepAliveTime(long keepAliveTime);
+
+    /**
+     * Gets the maximum pool size
+     *
+     * @return the maxPoolSize
+     */
+    int getMaxPoolSize();
+
+    /**
+     * Sets the maximum pool size
+     *
+     * @param maxPoolSize
+     *                the maxPoolSize to set
+     */
+    void setMaxPoolSize(int maxPoolSize);
+
+    /**
+     * Gets the minimum pool size
+     *
+     * @return the minPoolSize
+     */
+    int getMinPoolSize();
+
+    /**
+     * Sets the minimum pool size
+     *
+     * @param minPoolSize
+     *                the minPoolSize to set
+     */
+    void setMinPoolSize(int minPoolSize);
+
+    /**
+     * Sets the priority of this thread pool: {@link Thread#MIN_PRIORITY},
+     * {@link Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY}
+     *
+     * @param priority
+     *                the priority to set
+     */
+    void setPriority(int priority);
+
+    /**
+     * Sets the queue size of the thread pool
+     *
+     * @param queueSize
+     *                the queueSize to set
+     */
+    void setQueueSize(int queueSize);
+
+    /**
+     * Terminates all threads possibly awaiting processing all elements
+     * currently in queue.
+     */
     void shutdown();
 
     /**
-         * Returns true if thread runs as daemon
-         * 
-         * @return the daemon
-         */
-    public boolean isDaemon();
-
-    /**
-         * Set to true if thread shall run as daemon
-         * 
-         * @param daemon
-         *                the daemon to set
-         */
-    public void setDaemon(boolean daemon);
-
-    /**
-         * Returns true if a shutDown method has succeeded in terminating all
-         * threads
-         * 
-         * @return Whether a shutDown method has succeeded in terminating all
-         *         threads
-         */
-    public boolean isTerminatedAfterShutdown();
+     * Returns true if thread runs as daemon
+     *
+     * @return the daemon
+     */
+    boolean isDaemon();
+
+    /**
+     * Set to true if thread shall run as daemon
+     *
+     * @param daemon
+     *                the daemon to set
+     */
+    void setDaemon(boolean daemon);
+
+    /**
+     * Returns true if a shutDown method has succeeded in terminating all
+     * threads
+     *
+     * @return Whether a shutDown method has succeeded in terminating all
+     *         threads
+     */
+    boolean isTerminatedAfterShutdown();
 
 }

Modified: cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/pom.xml?view=diff&rev=567014&r1=567013&r2=567014
==============================================================================
--- cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/pom.xml (original)
+++ cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/pom.xml Fri Aug 17 04:03:48 2007
@@ -71,11 +71,6 @@
         </exclusion>
       </exclusions>
     </dependency>
-    <!-- Spring framework -->
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-beans</artifactId>
-    </dependency>   
     <!--  test dependencies  -->
     <dependency>
       <groupId>org.springframework</groupId>

Modified: cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java?view=diff&rev=567014&r1=567013&r2=567014
==============================================================================
--- cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
(original)
+++ cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
Fri Aug 17 04:03:48 2007
@@ -24,28 +24,27 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.InitializingBean;
 
 /**
  * The DefaultRunnableManager implements the {@link RunnableManager} interface
  * and is responsible to create {@link ThreadPool}s and run {@link Runnable}s
  * in them as background commands.
- * 
+ *
  * <p>
  * The configuration of the <code>DefaultRunnableManager</code>:
- * 
+ *
  * <pre>
  *     &lt;property name=&quot;workerThreadPools&quot;&gt;
  *       &lt;configurator:bean-map type=&quot;org.apache.cocoon.components.thread.ThreadPool&quot;
strip-prefix=&quot;true&quot;/&gt;
  *     &lt;/property&gt;
  * </pre>
- * 
+ *
  * </p>
- * 
+ *
  * @version $Id: DefaultRunnableManager.java 498489 2007-01-21 23:19:09Z
  *          jjohnston $
  */
-public class DefaultRunnableManager implements InitializingBean, RunnableManager, Runnable
{
+public class DefaultRunnableManager implements RunnableManager, Runnable {
 
     // ~ Static fields/initializers
     // ---------------------------------------------
@@ -85,7 +84,7 @@
     /**
      * Initialize
      */
-    public void afterPropertiesSet() throws Exception {
+    public void init() throws Exception {
         if (workerThreadPools != null) {
             final Iterator iter = workerThreadPools.keySet().iterator();
             while (iter.hasNext()) {
@@ -113,7 +112,7 @@
 
     /**
      * Create a shared ThreadPool
-     * 
+     *
      * @param name
      *            The name of the thread pool
      * @param queueSize
@@ -138,7 +137,7 @@
      * @param shutdownWaitTime
      *            After what time a normal shutdown should take into account if
      *            a graceful shutdown has not come to an end
-     * 
+     *
      * @throws IllegalArgumentException
      *             If the pool already exists
      */
@@ -166,7 +165,7 @@
 
     /**
      * Create a private ThreadPool
-     * 
+     *
      * @param queueSize
      *            The size of the queue
      * @param maxPoolSize
@@ -189,7 +188,7 @@
      * @param shutdownWaitTime
      *            After what time a normal shutdown should take into account if
      *            a graceful shutdown has not come to an end
-     * 
+     *
      * @return A newly created <code>ThreadPool</code>
      */
     public ThreadPool createPool(final int queueSize, final int maxPoolSize, final int minPoolSize,
final int priority,
@@ -246,7 +245,7 @@
 
     /**
      * Run a {@link Runnable} in the background using a {@link ThreadPool}
-     * 
+     *
      * @param threadPoolName
      *            The thread pool name to be used
      * @param command
@@ -255,7 +254,7 @@
      *            the delay befor first run
      * @param interval
      *            The interval for repeated runs
-     * 
+     *
      * @throws IllegalArgumentException
      *             DOCUMENT ME!
      */
@@ -288,7 +287,7 @@
 
     /**
      * Run a {@link Runnable} in the background using a {@link ThreadPool}
-     * 
+     *
      * @param command
      *            The {@link Runnable} to execute
      * @param delay
@@ -302,7 +301,7 @@
 
     /**
      * Run a {@link Runnable} in the background using a {@link ThreadPool}
-     * 
+     *
      * @param command
      *            The {@link Runnable} to execute
      * @param delay
@@ -314,7 +313,7 @@
 
     /**
      * Run a {@link Runnable} in the background using a {@link ThreadPool}
-     * 
+     *
      * @param command
      *            The {@link Runnable} to execute
      */
@@ -324,7 +323,7 @@
 
     /**
      * Run a {@link Runnable} in the background using a {@link ThreadPool}
-     * 
+     *
      * @param threadPoolName
      *            The thread pool name to be used
      * @param command
@@ -338,7 +337,7 @@
 
     /**
      * Run a {@link Runnable} in the background using a {@link ThreadPool}
-     * 
+     *
      * @param threadPoolName
      *            The thread pool name to be used
      * @param command
@@ -350,7 +349,7 @@
 
     /**
      * Remove a <code>Runnable</code> from the command stack
-     * 
+     *
      * @param command
      *            The <code>Runnable</code> to be removed
      */
@@ -422,7 +421,7 @@
 
     /**
      * Start the managing thread
-     * 
+     *
      * @throws Exception
      *             DOCUMENT ME!
      */
@@ -448,10 +447,10 @@
 
     /**
      * DOCUMENT ME!
-     * 
+     *
      * @param priority
      *            The priority to set as string value.
-     * 
+     *
      * @return The priority as int value.
      */
     private int convertPriority(final String priority) {
@@ -473,7 +472,7 @@
 
     /**
      * The $classType$ class ...
-     * 
+     *
      * @version $Id: DefaultRunnableManager.java 498489 2007-01-21 23:19:09Z
      *          jjohnston $
      */
@@ -504,7 +503,7 @@
 
         /**
          * Creates a new ExecutionInfo object.
-         * 
+         *
          * @param pool
          *            DOCUMENT ME!
          * @param command
@@ -537,10 +536,10 @@
 
         /**
          * DOCUMENT ME!
-         * 
+         *
          * @param other
          *            DOCUMENT ME!
-         * 
+         *
          * @return DOCUMENT ME!
          */
         public int compareTo(final Object other) {

Modified: cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultThreadPool.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultThreadPool.java?view=diff&rev=567014&r1=567013&r2=567014
==============================================================================
--- cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultThreadPool.java
(original)
+++ cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/java/org/apache/cocoon/components/thread/DefaultThreadPool.java
Fri Aug 17 04:03:48 2007
@@ -18,7 +18,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.springframework.beans.factory.InitializingBean;
 
 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
 
@@ -26,7 +25,7 @@
  * The DefaultThreadPool class implements the {@link ThreadPool} interface.
  * Instances of this class are made by the {@link RunnableManager} passing a
  * threadpool into the <code>init</code> method.
- * 
+ *
  * <pre>
  *   &lt;!--+
  *       | More indepth information can be found at
@@ -36,7 +35,7 @@
  *   &lt;!-- required name of the pool --&gt;
  *   &lt;property name=&quot;name&quot; value=&quot;default&quot; /&gt;
  *   &lt;!--+
- *       | optional priority all threads of the pool will have (the ThreadFactory will be

+ *       | optional priority all threads of the pool will have (the ThreadFactory will be
  *       | set to this priority).The possible values  are:
  *       |    MIN:  corresponds to Thread#MIN_PRIORITY
  *       |    NORM: corresponds to Thread#NORM_PRIORITY (default)
@@ -47,7 +46,7 @@
  *       | whether newly created Threads should run in daemon mode or not. Default to false.
  *       +--&gt;
  *   &lt;property name=&quot;daemon&quot; value=&quot;false&quot; /&gt;
- *   &lt;!--+ 
+ *   &lt;!--+
  *       | optional size of a queue to hold Runnables if the pool is full. Possible values
are:
  *      |    less than 0:    unbounded (default)
  *       |    equal to 0:     no queue at all
@@ -72,7 +71,7 @@
  *       +--&gt;
  *   &lt;property name=&quot;keepAliveTime&quot; value=&quot;60000&quot;
/&gt;
  *   &lt;!--+
- *       | The policy to be used if all resources (thread in the pool and 
+ *       | The policy to be used if all resources (thread in the pool and
  *       | slots in the queue) are exhausted.
  *       | Possible values are:
  *       |    ABORT:         Throw a RuntimeException
@@ -82,19 +81,19 @@
  *       |                   This policy helps guard against lockup.
  *       |    WAIT:          Wait until a thread becomes available. This policy should, in
  *       |                   general, not be used if the minimum number of threads is zero,
- *       |                   in which case a thread may never become available. 
+ *       |                   in which case a thread may never become available.
  *       +--&gt;
  *   &lt;property name=&quot;blockPolicy&quot; value=&quot;ABORT&quot;
/&gt;
  *   &lt;!--+
- *       | Terminate thread pool after processing all Runnables currently in queue. Any 
- *       | Runnable entered after this point will be discarded. A shut down pool cannot 
- *       | be restarted. This also means that a pool will need keep-alive-time-ms to 
- *       | terminate. The default value not to shutdown graceful. 
+ *       | Terminate thread pool after processing all Runnables currently in queue. Any
+ *       | Runnable entered after this point will be discarded. A shut down pool cannot
+ *       | be restarted. This also means that a pool will need keep-alive-time-ms to
+ *       | terminate. The default value not to shutdown graceful.
  *       +--&gt;
  *   &lt;property name=&quot;shutdownGraceful&quot; value=&quot;false&quot;
/&gt;
  *   &lt;!--+
  *       | The time in ms to wait before issuing an immediate shutdown after a graceful shutdown
- *       | has been requested. 
+ *       | has been requested.
  *       +--&gt;
  *   &lt;property name=&quot;shutdownWaitTimeMs&quot; value=&quot;-1&quot;
/&gt;
  *   &lt;!--+
@@ -103,11 +102,12 @@
  *       +--&gt;
  *   &lt;property name=&quot;factory&quot; ref=&quot;defaultThreadFactory&quot;/&gt;
  * </pre>
- * 
+ *
  * @version $Id$
  */
-public class DefaultThreadPool extends PooledExecutor implements
-	InitializingBean, ThreadPool {
+public class DefaultThreadPool
+    extends PooledExecutor
+    implements ThreadPool {
 
     // ~ Static fields/initializers
     // ---------------------------------------------
@@ -164,65 +164,65 @@
     // -----------------------------------------------------------
 
     /**
-         * Create a new pool.
-         * 
-         * @param channel
-         *                DOCUMENT ME!
-         */
+     * Create a new pool.
+     *
+     * @param channel
+     *                DOCUMENT ME!
+     */
     private DefaultThreadPool(final ChannelWrapper channel) {
-	super(channel);
-	channelWrapper = channel;
+   	    super(channel);
+	    channelWrapper = channel;
     }
 
     /**
-         * Create a new pool.
-         */
+     * Create a new pool.
+     */
     DefaultThreadPool() {
-	this(new ChannelWrapper());
+  	    this(new ChannelWrapper());
     }
 
     // ~ Methods
     // ----------------------------------------------------------------
 
     /** Initialize the bean after properties set */
-    public void afterPropertiesSet() throws IllegalArgumentException {
-	if (logger.isInfoEnabled()) {
-	    logger.info("ThreadPool [" + name + "] initializing ...");
-	}
-
-	initFactory();
-	super.setThreadFactory(factory);
-	initMinPoolSize();
-	initPriority();
-	initDaemon();
-	initQueueSize();
-	initMaxPoolSize();
-	initKeepAliveTime();
-
-	if (logger.isInfoEnabled()) {
-	    logger.info(this.toString());
-	    logger.info("ThreadPool [" + name + "] initialized");
-	}
+    public void init() throws IllegalArgumentException {
+        if (logger.isInfoEnabled()) {
+            logger.info("ThreadPool [" + name + "] initializing ...");
+        }
+
+	    initFactory();
+	    this.setThreadFactory(factory);
+        initMinPoolSize();
+        initPriority();
+        initDaemon();
+        initQueueSize();
+        initMaxPoolSize();
+        initKeepAliveTime();
+
+        if (logger.isInfoEnabled()) {
+            logger.info(this.toString());
+            logger.info("ThreadPool [" + name + "] initialized");
+        }
     }
 
     /**
-         * Get the block policy
-         * 
-         * @return Returns the blockPolicy.
-         */
+     * Get the block policy
+     *
+     * @return Returns the blockPolicy.
+     */
     public String getBlockPolicy() {
-	return blockPolicy;
+        return blockPolicy;
     }
 
     /**
-         * DOCUMENT ME!
-         * 
-         * @return maximum size of the queue (0 if isQueued() == false)
-         * 
-         * @see org.apache.cocoon.components.thread.ThreadPool#getQueueSize()
-         */
+     * DOCUMENT ME!
+     *
+     * @return maximum size of the queue (0 if isQueued() == false)
+     *
+     * @see org.apache.cocoon.components.thread.ThreadPool#getQueueSize()
+     */
     public int getMaxQueueSize() {
-	return ((queueSize < 0) ? Integer.MAX_VALUE : queueSize);
+        return ((queueSize < 0) ? Integer.MAX_VALUE : queueSize);
     }
 
     /**
@@ -234,7 +234,7 @@
 
     /**
          * Get hte priority used to create Threads
-         * 
+         *
          * @return {@link Thread#MIN_PRIORITY}, {@link Thread#NORM_PRIORITY},
          *         or {@link Thread#MAX_PRIORITY}
          */
@@ -244,9 +244,9 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @return current size of the queue (0 if isQueued() == false)
-         * 
+         *
          * @see org.apache.cocoon.components.thread.ThreadPool#getQueueSize()
          */
     public int getQueueSize() {
@@ -255,9 +255,9 @@
 
     /**
          * Whether this DefaultThreadPool has a queue
-         * 
+         *
          * @return Returns the m_isQueued.
-         * 
+         *
          * @see org.apache.cocoon.components.thread.ThreadPool#isQueued()
          */
     public boolean isQueued() {
@@ -266,10 +266,10 @@
 
     /**
          * Execute a command
-         * 
+         *
          * @param command
          *                The {@link Runnable} to execute
-         * 
+         *
          * @throws InterruptedException
          *                 In case of interruption
          */
@@ -311,7 +311,7 @@
 
     /**
          * Set the blocking policy
-         * 
+         *
          * @param blockPolicy
          *                The blocking policy value
          */
@@ -345,7 +345,7 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @param name
          *                The name to set.
          */
@@ -355,7 +355,7 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @param shutdownGraceful
          *                The shutdownGraceful to set.
          */
@@ -365,7 +365,7 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @return Returns the shutdownGraceful.
          */
     public boolean isShutdownGraceful() {
@@ -374,7 +374,7 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @param shutdownWaitTimeMs
          *                The shutdownWaitTimeMs to set.
          */
@@ -384,7 +384,7 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @return Returns the shutdownWaitTimeMs.
          */
     public int getShutdownWaitTimeMs() {
@@ -461,7 +461,7 @@
 
     /**
          * Sets the queue size of the thread pool
-         * 
+         *
          * @param queueSize
          *                the queueSize to set
          */
@@ -471,7 +471,7 @@
 
     /**
          * Returns true if thread runs as daemon
-         * 
+         *
          * @return the daemon
          */
     public boolean isDaemon() {
@@ -480,7 +480,7 @@
 
     /**
          * Set to true if thread shall run as daemon
-         * 
+         *
          * @param daemon
          *                the daemon to set
          */
@@ -523,10 +523,10 @@
 
     /**
          * DOCUMENT ME!
-         * 
+         *
          * @param priority
          *                The priority to set as string value.
-         * 
+         *
          * @return The priority as int value.
          */
     private int convertPriority(final String priority) {

Modified: cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/resources/META-INF/cocoon/spring/cocoon-thread-impl.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/resources/META-INF/cocoon/spring/cocoon-thread-impl.xml?view=diff&rev=567014&r1=567013&r2=567014
==============================================================================
--- cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/resources/META-INF/cocoon/spring/cocoon-thread-impl.xml
(original)
+++ cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/main/resources/META-INF/cocoon/spring/cocoon-thread-impl.xml
Fri Aug 17 04:03:48 2007
@@ -32,7 +32,7 @@
       +-->
   <bean name="org.apache.cocoon.components.thread.RunnableManager"
         class="org.apache.cocoon.components.thread.DefaultRunnableManager"
-        scope="singleton" destroy-method="destroy">
+        scope="singleton" init-method="init" destroy-method="destroy">
     <!--+
         | This is the default configuration of the runnable-manager. More
         | indepth information can be found at
@@ -50,7 +50,9 @@
       | This is the default thread pool. It's use fits best for short
       | running background tasks.
       +-->
-  <bean name="org.apache.cocoon.components.thread.ThreadPool/default" class="org.apache.cocoon.components.thread.DefaultThreadPool"
scope="singleton">
+  <bean name="org.apache.cocoon.components.thread.ThreadPool/default"
+        class="org.apache.cocoon.components.thread.DefaultThreadPool"
+        init-method="init" scope="singleton">
     <!--+
         | More indepth information can be found at
         | http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html
@@ -131,7 +133,9 @@
       | This thread pool should be used for daemons (permanently running
       | threads).
       +-->
-  <bean name="org.apache.cocoon.components.thread.ThreadPool/daemon" class="org.apache.cocoon.components.thread.DefaultThreadPool"
scope="singleton">
+  <bean name="org.apache.cocoon.components.thread.ThreadPool/daemon"
+        class="org.apache.cocoon.components.thread.DefaultThreadPool"
+        init-method="init" scope="singleton">
     <property name="name" value="daemon"/>
     <property name="poolPriority" value="NORM"/>
     <property name="daemon" value="true"/>

Modified: cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/test/java/org/apache/cocoon/components/thread/DefaultThreadPoolTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/test/java/org/apache/cocoon/components/thread/DefaultThreadPoolTestCase.java?view=diff&rev=567014&r1=567013&r2=567014
==============================================================================
--- cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/test/java/org/apache/cocoon/components/thread/DefaultThreadPoolTestCase.java
(original)
+++ cocoon/trunk/core/cocoon-thread/cocoon-thread-impl/src/test/java/org/apache/cocoon/components/thread/DefaultThreadPoolTestCase.java
Fri Aug 17 04:03:48 2007
@@ -22,120 +22,120 @@
 
 /**
  * The $classType$ class ...
- * 
+ *
  * @version $Id: DefaultThreadPoolTestCase.java 494399 2007-01-09 13:10:08Z
  *          cziegeler $
  */
 public class DefaultThreadPoolTestCase extends AbstractTestCase {
 
     /**
-         * DOCUMENT ME!
-         */
+     * DOCUMENT ME!
+     */
     public final void testDefaultThreadPool() {
-	final DefaultThreadPool pool = new DefaultThreadPool();
-	pool.setName("mypool");
+        final DefaultThreadPool pool = new DefaultThreadPool();
+        pool.setName("mypool");
 
-	// We cannot mock the DefaultThreadFactory as the underlying
-	// PooledExecutor of the DefaultThreadPool will again wrapp it into a
-	// PooledExecutor.Worker instance that does some bookeeping.
-	// Using a easymocked DefaultThreadFactory will prevent the
-	// PooledExecutor from shutting down and thus hangs forever.
-	final ThreadFactory threadFactory = new DefaultThreadFactory();
-	pool.setThreadFactory(threadFactory);
-	pool.setPriority(Thread.MAX_PRIORITY);
-	pool.setQueueSize(230);
-	pool.setMaxPoolSize(15);
-	pool.setMinPoolSize(9);
-	pool.setKeepAliveTime(11000L);
-	pool.setBlockPolicy("ABORT");
-	pool.setShutdownGraceful(false);
-	pool.setShutdownWaitTimeMs(12345);
-	pool.afterPropertiesSet();
-
-	assertEquals("block-policy", "ABORT", pool.getBlockPolicy());
-	assertEquals("keep-alive-time-ms", 11000L, pool.getKeepAliveTime());
-	assertEquals("max-queueu-size", 230, pool.getMaxQueueSize());
-	assertEquals("max-pool-size", 15, pool.getMaxPoolSize());
-	assertEquals("min-pool-size", 9, pool.getMinPoolSize());
-	assertEquals("name", "mypool", pool.getName());
-	assertEquals("priority", Thread.MAX_PRIORITY, pool.getPriority());
-	assertEquals("queue-size", 0, pool.getQueueSize());
-	assertEquals("isQueued", true, pool.isQueued());
-	assertEquals("isTerminatedAfterShutdown", false, pool
-		.isTerminatedAfterShutdown());
-	verify();
+        // We cannot mock the DefaultThreadFactory as the underlying
+        // PooledExecutor of the DefaultThreadPool will again wrapp it into a
+        // PooledExecutor.Worker instance that does some bookeeping.
+        // Using a easymocked DefaultThreadFactory will prevent the
+        // PooledExecutor from shutting down and thus hangs forever.
+        final ThreadFactory threadFactory = new DefaultThreadFactory();
+        pool.setThreadFactory(threadFactory);
+        pool.setPriority(Thread.MAX_PRIORITY);
+        pool.setQueueSize(230);
+        pool.setMaxPoolSize(15);
+        pool.setMinPoolSize(9);
+        pool.setKeepAliveTime(11000L);
+        pool.setBlockPolicy("ABORT");
+        pool.setShutdownGraceful(false);
+        pool.setShutdownWaitTimeMs(12345);
+        pool.init();
+
+        assertEquals("block-policy", "ABORT", pool.getBlockPolicy());
+        assertEquals("keep-alive-time-ms", 11000L, pool.getKeepAliveTime());
+        assertEquals("max-queueu-size", 230, pool.getMaxQueueSize());
+        assertEquals("max-pool-size", 15, pool.getMaxPoolSize());
+        assertEquals("min-pool-size", 9, pool.getMinPoolSize());
+        assertEquals("name", "mypool", pool.getName());
+        assertEquals("priority", Thread.MAX_PRIORITY, pool.getPriority());
+        assertEquals("queue-size", 0, pool.getQueueSize());
+        assertEquals("isQueued", true, pool.isQueued());
+        assertEquals("isTerminatedAfterShutdown", false, pool
+        	.isTerminatedAfterShutdown());
+        verify();
     }
 
-    /*
-         * Class under test for void execute(Runnable)
-         */
+    /**
+     * Class under test for void execute(Runnable)
+     */
     public final void testExecuteRunnable() throws InterruptedException {
-	final MockControl runnableControl = createStrictControl(Runnable.class);
-	final Runnable runnable = (Runnable) runnableControl.getMock();
-	runnable.run();
-	runnableControl.replay();
-
-	final DefaultThreadPool pool = new DefaultThreadPool();
-	pool.setName("mypool");
-	// We cannot mock the DefaultThreadFactory as the underlying
-	// PooledExecutor of the DefaultThreadPool will again wrapp it into a
-	// PooledExecutor.Worker instance that does some bookeeping.
-	// Using a easymocked DefaultThreadFactory will prevent the
-	// PooledExecutor from shutting down and thus hangs forever.
-	pool.setThreadFactory(new DefaultThreadFactory());
-	pool.setQueueSize(230);
-	pool.setMaxPoolSize(15);
-	pool.setMinPoolSize(9);
-	pool.setKeepAliveTime(100);
-	pool.setBlockPolicy("ABORT");
-	pool.setShutdownGraceful(false);
-	pool.setShutdownWaitTimeMs(1234);
-	pool.afterPropertiesSet();
-	pool.execute(runnable);
-	Thread.yield();
-	Thread.sleep(100);
-	pool.shutdown();
-	verify();
+        final MockControl runnableControl = createStrictControl(Runnable.class);
+        final Runnable runnable = (Runnable) runnableControl.getMock();
+        runnable.run();
+        runnableControl.replay();
+
+        final DefaultThreadPool pool = new DefaultThreadPool();
+        pool.setName("mypool");
+        // We cannot mock the DefaultThreadFactory as the underlying
+        // PooledExecutor of the DefaultThreadPool will again wrapp it into a
+        // PooledExecutor.Worker instance that does some bookeeping.
+        // Using a easymocked DefaultThreadFactory will prevent the
+        // PooledExecutor from shutting down and thus hangs forever.
+        pool.setThreadFactory(new DefaultThreadFactory());
+        pool.setQueueSize(230);
+        pool.setMaxPoolSize(15);
+        pool.setMinPoolSize(9);
+        pool.setKeepAliveTime(100);
+        pool.setBlockPolicy("ABORT");
+        pool.setShutdownGraceful(false);
+        pool.setShutdownWaitTimeMs(1234);
+        pool.init();
+        pool.execute(runnable);
+        Thread.yield();
+        Thread.sleep(100);
+        pool.shutdown();
+        verify();
     }
 
     /**
-         * DOCUMENT ME!
-         * 
-         * @throws InterruptedException
-         *                 DOCUMENT ME!
-         */
+     * DOCUMENT ME!
+     *
+     * @throws InterruptedException
+     *                 DOCUMENT ME!
+     */
     public final void testShutdown() throws InterruptedException {
-	final Runnable runnable = new Runnable() {
-	    public void run() {
-		final Log logger = LogFactory
-			.getLog(DefaultThreadPoolTestCase.this.getClass());
-		logger.info("runnable runs");
-		try {
-		    Thread.sleep(1000);
-		} catch (final InterruptedException ie) {
-		    logger.info("runnable has been interrupted ");
-		}
-		logger.info("runnable terminated");
-	    }
-	};
-
-	final DefaultThreadPool pool = new DefaultThreadPool();
-	pool.setName("mypool");
-	pool.setThreadFactory(new DefaultThreadFactory());
-	pool.setQueueSize(0);
-	pool.setMaxPoolSize(15);
-	pool.setMinPoolSize(9);
-	pool.setKeepAliveTime(1000);
-	pool.setBlockPolicy("ABORT");
-	pool.setShutdownGraceful(true);
-	pool.setShutdownWaitTimeMs(100);
-	pool.afterPropertiesSet();
-	pool.execute(runnable);
-	pool.execute(runnable);
-	Thread.yield();
-	Thread.sleep(200);
-	pool.shutdown();
-	Thread.sleep(200);
-	verify();
+        final Runnable runnable = new Runnable() {
+            public void run() {
+        	final Log logger = LogFactory
+        		.getLog(DefaultThreadPoolTestCase.this.getClass());
+        	logger.info("runnable runs");
+        	try {
+        	    Thread.sleep(1000);
+        	} catch (final InterruptedException ie) {
+        	    logger.info("runnable has been interrupted ");
+        	}
+        	logger.info("runnable terminated");
+            }
+        };
+
+        final DefaultThreadPool pool = new DefaultThreadPool();
+        pool.setName("mypool");
+        pool.setThreadFactory(new DefaultThreadFactory());
+        pool.setQueueSize(0);
+        pool.setMaxPoolSize(15);
+        pool.setMinPoolSize(9);
+        pool.setKeepAliveTime(1000);
+        pool.setBlockPolicy("ABORT");
+        pool.setShutdownGraceful(true);
+        pool.setShutdownWaitTimeMs(100);
+        pool.init();
+        pool.execute(runnable);
+        pool.execute(runnable);
+        Thread.yield();
+        Thread.sleep(200);
+        pool.shutdown();
+        Thread.sleep(200);
+        verify();
     }
 }



Mime
View raw message