servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r594553 - in /incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix: Main.java jbi/container/SpringJBIContainer.java
Date Tue, 13 Nov 2007 14:39:06 GMT
Author: gertv
Date: Tue Nov 13 06:39:05 2007
New Revision: 594553

URL: http://svn.apache.org/viewvc?rev=594553&view=rev
Log:
SM-1132: Adding a shutdown handler to SpringJBIContainer

Modified:
    incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
    incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java

Modified: incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java?rev=594553&r1=594552&r2=594553&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
(original)
+++ incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/Main.java
Tue Nov 13 06:39:05 2007
@@ -48,7 +48,7 @@
             System.out.println("Starting Apache ServiceMix ESB" + version);
             System.out.println();
 
-            ApplicationContext context = null;
+            final ApplicationContext context;
             if (args.length <= 0) {
                 System.out.println("Loading Apache ServiceMix from servicemix.xml on the
CLASSPATH");
                 context = new ClassPathXmlApplicationContext("servicemix.xml");
@@ -67,16 +67,18 @@
                 context = new FileSystemXmlApplicationContext(file, processors);
             }
             SpringJBIContainer container = (SpringJBIContainer) context.getBean("jbi");
-            Object lock = new Object();
-            container.setShutdownLock(lock);
-
-            // lets wait until we're killed.
-            synchronized (lock) {
-                lock.wait();
-            }
-            if (context instanceof DisposableBean) {
-                ((DisposableBean) context).destroy();
-            }
+            container.onShutDown(new Runnable() {
+                public void run() {
+                    if (context instanceof DisposableBean) {
+                        try {
+                            ((DisposableBean) context).destroy();
+                        } catch (Exception e) {
+                            System.out.println("Caught: " + e);
+                            e.printStackTrace();
+                        }
+                    }
+                }
+            });
         } catch (Exception e) {
             System.out.println("Caught: " + e);
             e.printStackTrace();

Modified: incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java?rev=594553&r1=594552&r2=594553&view=diff
==============================================================================
--- incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
(original)
+++ incubator/servicemix/branches/servicemix-3.2/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
Tue Nov 13 06:39:05 2007
@@ -58,7 +58,7 @@
     private ApplicationContext applicationContext;
     private String[] deployArchives;
     private DeploySupport[] deployments;
-    private Object shutdownLock;
+    private Runnable onShutDown;
     private Map components;
     private Map endpoints;
 
@@ -304,19 +304,22 @@
     }
 
     public void shutDown() throws JBIException {
-        if (shutdownLock != null) {
-            synchronized (shutdownLock) {
-                shutdownLock.notify();
-            }
+        if (onShutDown != null) {
+            onShutDown.run();
+        } else {
+            //no shutdown handler has been set
+            //shutting down the container ourselves
+            super.shutDown();
         }
     }
 
     /**
-     * @param lock
-     * @org.apache.xbean.Property hidden="true"
+     * Set a {@link Runnable} which can handle the shutdown of the container
+     * 
+     * @param runnable the shutdown handler
      */
-    public void setShutdownLock(Object lock) {
-        this.shutdownLock = lock;
+    public void onShutDown(Runnable runnable) {
+        this.onShutDown = runnable;
     }
 
     /**
@@ -340,5 +343,5 @@
     public void setEndpoints(Map endpoints) {
         this.endpoints = endpoints;
     }
-
+    
 }



Mime
View raw message