You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by bo...@apache.org on 2008/05/10 17:13:41 UTC

svn commit: r655102 - in /ode/branches/APACHE_ODE_1.1: axis2/src/main/java/org/apache/ode/axis2/ODEServer.java bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java

Author: boisvert
Date: Sat May 10 08:13:40 2008
New Revision: 655102

URL: http://svn.apache.org/viewvc?rev=655102&view=rev
Log:
ODE-279: Ode doesn't shutdown properly under Tomcat

Modified:
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
    ode/branches/APACHE_ODE_1.1/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=655102&r1=655101&r2=655102&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Sat May 10 08:13:40 2008
@@ -67,6 +67,7 @@
 import java.util.StringTokenizer;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 /**
  * Server class called by our Axis hooks to handle all ODE lifecycle management.
@@ -285,6 +286,15 @@
                 _txMgr = null;
             }
 
+            if (_connector != null) {
+                try {
+                    __log.debug("shutdown BpelConnector");
+                    _connector.shutdown();
+                } catch (Throwable t) {
+                    __log.error("Unable to cleanup temp files.", t);
+                }
+            }
+            
             try {
                 __log.debug("cleaning up temporary files.");
                 TempFileManager.cleanup();
@@ -292,6 +302,7 @@
                 __log.error("Unable to cleanup temp files.", t);
             }
 
+
             __log.info(__msgs.msgOdeShutdownCompleted());
         } finally {
             Thread.currentThread().setContextClassLoader(old);
@@ -450,10 +461,20 @@
         if (__log.isDebugEnabled()) {
             __log.debug("ODE initializing");
         }
+        ThreadFactory threadFactory = new ThreadFactory() {
+            int threadNumber = 0;
+            public Thread newThread(Runnable r) {
+                threadNumber += 1;
+                Thread t = new Thread(r, "ODEServer-"+threadNumber);
+                t.setDaemon(true);
+                return t;
+            }
+        };
+
         if (_odeConfig.getThreadPoolMaxSize() == 0)
-            _executorService = Executors.newCachedThreadPool();
+            _executorService = Executors.newCachedThreadPool(threadFactory);
         else
-            _executorService = Executors.newFixedThreadPool(_odeConfig.getThreadPoolMaxSize());
+            _executorService = Executors.newFixedThreadPool(_odeConfig.getThreadPoolMaxSize(), threadFactory);
 
         _server = new BpelServerImpl();
         _scheduler = createScheduler();

Modified: ode/branches/APACHE_ODE_1.1/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java?rev=655102&r1=655101&r2=655102&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java (original)
+++ ode/branches/APACHE_ODE_1.1/bpel-store/src/main/java/org/apache/ode/store/ProcessStoreImpl.java Sat May 10 08:13:40 2008
@@ -49,6 +49,7 @@
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
@@ -97,7 +98,7 @@
      * to get confused ii) we're already serializing all the operations with a read/write lock. iii) we don't care about
      * performance, these are infrequent operations.
      */
-    private ExecutorService _executor = Executors.newSingleThreadExecutor();
+    private ExecutorService _executor = Executors.newSingleThreadExecutor(new SimpleThreadFactory());
 
     /**
      * In-memory DataSource, or <code>null</code> if we are using a real DS. We need this to shutdown the DB.
@@ -764,4 +765,14 @@
         }
         return old;
     }
+
+    private class SimpleThreadFactory implements ThreadFactory {
+        int threadNumber = 0;
+        public Thread newThread(Runnable r) {
+            threadNumber += 1;
+            Thread t = new Thread(r, "ProcessStoreImpl-"+threadNumber);
+            t.setDaemon(true);
+            return t;
+        }
+    }
 }