You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/12/10 14:50:06 UTC

svn commit: r725284 - in /servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework: DeploymentService.java ServiceAssemblyLifeCycle.java

Author: gnodet
Date: Wed Dec 10 05:50:05 2008
New Revision: 725284

URL: http://svn.apache.org/viewvc?rev=725284&view=rev
Log:
SM-1607: JBI container should be able to initialize all SAs first and then start them

Modified:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java?rev=725284&r1=725283&r2=725284&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java (original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/DeploymentService.java Wed Dec 10 05:50:05 2008
@@ -94,14 +94,26 @@
     public void start() throws javax.jbi.JBIException {
         super.start();
         String[] sas = registry.getDeployedServiceAssemblies();
+        // This loop will initialize all SAs
+        container.getBroker().suspend();
+        for (int j = 0; j < sas.length; j++) {
+            try {
+                ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(sas[j]);
+                sa.init();
+            } catch (Exception e) {
+                LOG.error("Unable to initialize state for service assembly " + sas[j], e);
+            }
+        }
+        // This loop will restore SAs
         for (int i = 0; i < sas.length; i++) {
             try {
                 ServiceAssemblyLifeCycle sa = registry.getServiceAssembly(sas[i]);
-                sa.restore();
+                sa.restore(false); // Do not force init SUs 
             } catch (Exception e) {
                 LOG.error("Unable to restore state for service assembly " + sas[i], e);
             }
         }
+        container.getBroker().resume();
     }
     
     /**

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java?rev=725284&r1=725283&r2=725284&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java (original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ServiceAssemblyLifeCycle.java Wed Dec 10 05:50:05 2008
@@ -98,6 +98,28 @@
     }
 
     /**
+     * Initialize all SUs in Service Assembly.
+     *
+     * @return Result/Status of this operation
+     * @throws Exception
+     */
+    public synchronized String init() throws Exception {
+        LOG.info("Initializing service assembly: " + getName());
+        // Init service units
+        List<Element> componentFailures = new ArrayList<Element>();
+        for (int i = 0; i < sus.length; i++) {
+            if (!sus[i].isStarted()) { 
+                sus[i].init();
+            }
+        } 
+        if (componentFailures.size() == 0) {
+            return ManagementSupport.createSuccessMessage("init");
+        } else {
+            throw ManagementSupport.failure("init", componentFailures);
+        }
+    }
+
+    /**
      * Start a Service Assembly and put it in the STARTED state.
      *
      * @return Result/Status of this operation.
@@ -319,17 +341,26 @@
         }
         return null;
     }
-    
+   
     /**
      * Restore this service assembly to its state at shutdown.
      * @throws Exception
      */
     public synchronized void restore() throws Exception {
+        restore(true);
+    }
+ 
+    /**
+     * Restore this service assembly to its state at shutdown.
+     * @param forceInit
+     * @throws Exception
+     */
+    public synchronized void restore(boolean forceInit) throws Exception {
         String state = getRunningStateFromStore();
         if (STARTED.equals(state)) {
             start(false);
         } else {
-            stop(false, true);
+            stop(false, forceInit);
             if (SHUTDOWN.equals(state)) {
                 shutDown(false);
             }