axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r360455 - in /webservices/axis2/trunk/java: etc/ modules/adb/ modules/addressing/ modules/codegen/ modules/core/ modules/core/src/org/apache/axis2/util/threadpool/ modules/integration/ modules/saaj/ modules/samples/ modules/security/
Date Sat, 31 Dec 2005 22:34:36 GMT
Author: dims
Date: Sat Dec 31 14:34:28 2005
New Revision: 360455

URL: http://svn.apache.org/viewcvs?rev=360455&view=rev
Log:
trying to fix issues in "[Axis2] Threading Issues" (http://marc.theaimsgroup.com/?l=axis-dev&m=113567205521113&w=2)
thread

by using the threadpool in backport-util-concurrent(http://www.mathcs.emory.edu/dcl/util/backport-util-concurrent/)


Removed:
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/threadpool/ThreadWorker.java
Modified:
    webservices/axis2/trunk/java/etc/project.properties
    webservices/axis2/trunk/java/modules/adb/project.xml
    webservices/axis2/trunk/java/modules/addressing/project.xml
    webservices/axis2/trunk/java/modules/codegen/project.xml
    webservices/axis2/trunk/java/modules/core/project.xml
    webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/threadpool/ThreadPool.java
    webservices/axis2/trunk/java/modules/integration/project.xml
    webservices/axis2/trunk/java/modules/saaj/project.xml
    webservices/axis2/trunk/java/modules/samples/project.xml
    webservices/axis2/trunk/java/modules/security/project.xml

Modified: webservices/axis2/trunk/java/etc/project.properties
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/etc/project.properties?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/etc/project.properties (original)
+++ webservices/axis2/trunk/java/etc/project.properties Sat Dec 31 14:34:28 2005
@@ -73,6 +73,7 @@
 # -------------------------------------------------------------------
 ant.version=1.6.5
 axis.wsdl4j.version=1.2
+backport_util_concurrent.version=2.0_01_pd
 bcprov.version=jdk13-128
 commons.codec.version=1.3
 commons.discovery.version=0.2

Modified: webservices/axis2/trunk/java/modules/adb/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/project.xml (original)
+++ webservices/axis2/trunk/java/modules/adb/project.xml Sat Dec 31 14:34:28 2005
@@ -133,6 +133,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
          <dependency>
             <groupId>annogen</groupId>
             <artifactId>annogen</artifactId>

Modified: webservices/axis2/trunk/java/modules/addressing/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/addressing/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/addressing/project.xml (original)
+++ webservices/axis2/trunk/java/modules/addressing/project.xml Sat Dec 31 14:34:28 2005
@@ -112,6 +112,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
         <!--for java2wsdl generation we use JAM , so there should be a dependency on the
annogen jar or-->
         <!--XML Beans-->
         <dependency>

Modified: webservices/axis2/trunk/java/modules/codegen/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/project.xml (original)
+++ webservices/axis2/trunk/java/modules/codegen/project.xml Sat Dec 31 14:34:28 2005
@@ -152,6 +152,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
 	<dependency>
             <groupId>ws-commons</groupId>
             <artifactId>ws-policy</artifactId>

Modified: webservices/axis2/trunk/java/modules/core/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/project.xml (original)
+++ webservices/axis2/trunk/java/modules/core/project.xml Sat Dec 31 14:34:28 2005
@@ -147,6 +147,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
         <!--for java2wsdl generation we use JAM , so there should be a dependency on the
annogen jar or-->
         <!--XML Beans-->
          <dependency>

Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/threadpool/ThreadPool.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/threadpool/ThreadPool.java?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/threadpool/ThreadPool.java
(original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/threadpool/ThreadPool.java
Sat Dec 31 14:34:28 2005
@@ -27,6 +27,11 @@
 import java.util.Iterator;
 import java.util.List;
 
+import edu.emory.mathcs.backport.java.util.concurrent.Executor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.SynchronousQueue;
+
 /**
  * This the thread pool for axis2. This class will be used a singleton
  * across axis2 engine. <code>ThreadPool</code> is accepts <code>AxisWorkers</code>
which has
@@ -38,28 +43,25 @@
     protected static long SLEEP_INTERVAL = 1000;
     private static int MAX_THREAD_COUNT = 10;
     private static boolean shutDown;
-    private static List tasks;
-    private static List threads;
-
+    protected ThreadPoolExecutor executor;
+    
     public ThreadPool() {
-        threads = new ArrayList();
-        tasks = Collections.synchronizedList(new ArrayList());
+        setExecutor(createDefaultExecutor("Axis2 Task", Thread.NORM_PRIORITY, true));
+    }
 
-        for (int i = 0; i < MAX_THREAD_COUNT; i++) {
-            ThreadWorker threadWorker = new ThreadWorker();
+    public Executor getExecutor() {
+        return executor;
+    }
 
-            threadWorker.setPool(this);
-            threads.add(threadWorker);
-            threadWorker.start();
-        }
+    public void setExecutor(ThreadPoolExecutor executor) {
+        this.executor = executor;
     }
 
     public void execute(Runnable worker) {
         if (shutDown) {
             throw new RuntimeException(Messages.getMessage("threadpoolshutdown"));
         }
-
-        tasks.add(worker);
+        executor.execute(worker);
     }
 
     /**
@@ -69,14 +71,7 @@
         if (log.isDebugEnabled()) {
             log.debug("forceShutDown called. Thread workers will be stopped");
         }
-
-        Iterator ite = threads.iterator();
-
-        while (ite.hasNext()) {
-            ThreadWorker worker = (ThreadWorker) ite.next();
-
-            worker.setStop(true);
-        }
+        executor.shutdownNow();
     }
 
     /**
@@ -91,26 +86,19 @@
             shutDown = true;
         }
 
-        while (!tasks.isEmpty()) {
-            try {
-                Thread.sleep(SLEEP_INTERVAL);
-            } catch (InterruptedException e) {
-                throw new AxisFault(Messages.getMessage("errorWhileSafeShutDown"));
-            }
-        }
-
-        forceShutDown();
+        executor.shutdown();
     }
 
-    public synchronized Runnable getWorker() {
-        if (!tasks.isEmpty()) {
-            Runnable worker = (Runnable) tasks.get(0);
-
-            tasks.remove(worker);
-
-            return worker;
-        } else {
-            return null;
-        }
+    protected ThreadPoolExecutor createDefaultExecutor(final String name, final int priority,
final boolean daemon) {
+        ThreadPoolExecutor rc = new ThreadPoolExecutor(5, Integer.MAX_VALUE, 10, TimeUnit.SECONDS,
new SynchronousQueue(), new edu.emory.mathcs.backport.java.util.concurrent.ThreadFactory()
{
+            public Thread newThread(Runnable runnable) {
+                Thread thread = new Thread(runnable, name);
+                thread.setDaemon(daemon);
+                thread.setPriority(priority);
+                return thread;
+            }
+        });
+        rc.allowCoreThreadTimeOut(true);
+        return rc;
     }
 }

Modified: webservices/axis2/trunk/java/modules/integration/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/project.xml (original)
+++ webservices/axis2/trunk/java/modules/integration/project.xml Sat Dec 31 14:34:28 2005
@@ -280,6 +280,14 @@
             <version>${XmlSchema.version}</version>
         </dependency>
         <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
             <groupId>ws-commons</groupId>
             <artifactId>ws-policy</artifactId>
             <version>${ws_policy.version}</version>

Modified: webservices/axis2/trunk/java/modules/saaj/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/saaj/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/saaj/project.xml (original)
+++ webservices/axis2/trunk/java/modules/saaj/project.xml Sat Dec 31 14:34:28 2005
@@ -155,6 +155,14 @@
             </properties>
         </dependency>
         <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
+        <dependency>
             <groupId>log4j</groupId>
             <artifactId>log4j</artifactId>
             <version>${log4j.version}</version>

Modified: webservices/axis2/trunk/java/modules/samples/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/samples/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/samples/project.xml (original)
+++ webservices/axis2/trunk/java/modules/samples/project.xml Sat Dec 31 14:34:28 2005
@@ -203,6 +203,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
          <!--for java2wsdl generation we use JAM , so there should be a dependency on
the annogen jar or-->
         <!--XML Beans-->
          <dependency>

Modified: webservices/axis2/trunk/java/modules/security/project.xml
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/project.xml?rev=360455&r1=360454&r2=360455&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/project.xml (original)
+++ webservices/axis2/trunk/java/modules/security/project.xml Sat Dec 31 14:34:28 2005
@@ -187,6 +187,14 @@
                 <module>true</module>
             </properties>
         </dependency>
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent.version}</version>
+            <properties>
+                <module>true</module>
+            </properties>
+        </dependency>
          <dependency>
             <groupId>ws-commons</groupId>
             <artifactId>XmlSchema</artifactId>



Mime
View raw message