servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1164060 - /servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
Date Thu, 01 Sep 2011 13:05:24 GMT
Author: jbonofre
Date: Thu Sep  1 13:05:24 2011
New Revision: 1164060

URL: http://svn.apache.org/viewvc?rev=1164060&view=rev
Log:
[SM-2118] Support optional start markup file to exactly know when SMX3 is fully started.

Modified:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?rev=1164060&r1=1164059&r2=1164060&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
(original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
Thu Sep  1 13:05:24 2011
@@ -17,6 +17,7 @@
 package org.apache.servicemix.jbi.container;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.EventListener;
@@ -122,6 +123,7 @@ public class JBIContainer extends BaseLi
     private String name = DEFAULT_NAME;
     private InitialContext namingContext;
     private MBeanServer mbeanServer;
+    private String completeStartMarkupFileName;
     private TransactionManager transactionManager;
     private String rootDir;
     private String generatedRootDirPrefix = "target/rootDirs/rootDir";
@@ -293,6 +295,24 @@ public class JBIContainer extends BaseLi
     }
 
     /**
+     * Gets name of file that is created when container finished starting.
+     *
+     * @return the name of the markup file in container root directory.
+     */
+    public String getCompleteStartMarkupFileName() {
+        return this.completeStartMarkupFileName;
+    }
+
+    /**
+     * Sets name of file that is created when container finishes starting.
+     *
+     * @param completeStartMarkupFileName name of the marker file in container root directory.
+     */
+    public void setCompleteStartMarkupFileName(String completeStartMarkupFileName) {
+        this.completeStartMarkupFileName = completeStartMarkupFileName;
+    }
+
+    /**
      * Get the ManagementContext
      *
      * @return the ManagementContext
@@ -673,8 +693,27 @@ public class JBIContainer extends BaseLi
             autoDeployService.start();
             adminCommandsService.start();
             super.start();
-            LOGGER.info("ServiceMix JBI Container ({})", getName());
+            this.notifyContainerStarted();
+        }
+    }
+
+    private void notifyContainerStarted() throws JBIException {
+        if (completeStartMarkupFileName != null) {
+            File startMarkupFile = new File(rootDir, completeStartMarkupFileName);
+            try {
+                if (!startMarkupFile.exists()) {
+                    File parent = startMarkupFile.getParentFile();
+                    if (parent != null && !parent.exists()) {
+                        parent.mkdirs();
+                    }
+                    startMarkupFile.createNewFile();
+                }
+                startMarkupFile.setLastModified(System.currentTimeMillis());
+            } catch (IOException ioException) {
+                throw new JBIException("Cannot create startup markup file " + startMarkupFile.getAbsolutePath(),
ioException);
+            }
         }
+        LOGGER.info("ServiceMix JBI Container (" + this.getName() + ") started");
     }
 
     /**



Mime
View raw message