You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ba...@apache.org on 2006/12/13 16:00:45 UTC

svn commit: r486679 - /webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java

Author: barrettj
Date: Wed Dec 13 07:00:44 2006
New Revision: 486679

URL: http://svn.apache.org/viewvc?view=rev&rev=486679
Log:
Async response executor threads should be daemons to they don't prevent the JVM from exiting normally when the client thread finishes.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=486679&r1=486678&r2=486679
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Wed Dec 13 07:00:44 2006
@@ -26,6 +26,7 @@
 import java.util.Map;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
@@ -308,7 +309,7 @@
     
     //TODO: Need to make the default number of threads configurable
     private Executor getDefaultExecutor(){
-        return Executors.newFixedThreadPool(20);
+        return Executors.newFixedThreadPool(20, new JAXWSThreadFactory());
     }
 
     private <T> JAXWSClientContext<T> createClientContext(EndpointDescription epDesc, Class<T> clazz, Mode mode){
@@ -362,4 +363,23 @@
     			clazz == Source.class || 
     			clazz == SOAPMessage.class);
     }
+}
+/**
+ * Factory to create threads in the ThreadPool Executor.  We provide a factory so 
+ * the threads can be set as daemon threads so that they do not prevent the JVM from 
+ * exiting normally when the main client thread is finished.
+ *
+ */
+class JAXWSThreadFactory implements ThreadFactory {
+    private static int groupNumber = 0;
+    private int threadNumber = 0;
+    // We put the threads into a unique thread group only for ease of identifying them
+    private ThreadGroup threadGroup = new ThreadGroup("JAX-WS Default Executor Group " + groupNumber++);
+    public Thread newThread(Runnable r) {
+        threadNumber++;
+        Thread returnThread = new Thread(threadGroup, r);
+        returnThread.setDaemon(true);
+        return returnThread;
+    }
+    
 }



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