[jboss-svn-commits] JBL Code SVN: r35395 - labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Oct 3 23:23:17 EDT 2010


Author: tcunning
Date: 2010-10-03 23:23:17 -0400 (Sun, 03 Oct 2010)
New Revision: 35395

Modified:
   labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java
   labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeploymentMBean.java
Log:
JBESB-3491
Reintroduce the deployment state into AS5.


Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java	2010-10-04 03:14:21 UTC (rev 35394)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeployment.java	2010-10-04 03:23:17 UTC (rev 35395)
@@ -94,6 +94,8 @@
 {
     private Logger log = Logger.getLogger(EsbDeployment.class);
     
+    private int state = CREATED;
+
     private String jbossEsbXml;
     private String deploymentName;
     private List<ContractReferencePublisher> publishers;
@@ -112,7 +114,7 @@
     private DeployerClient mainDeployer;
     private File esbWarFiles;
     private File esbArchive;
-    
+        
     public EsbDeployment(final EsbMetaData esbMetaData, final String mbeanName, final VFSDeploymentUnit deploymentUnit, final File esbWarFiles) throws Exception
     {
         this.deploymentName = esbMetaData.getArchiveName();
@@ -176,6 +178,8 @@
 
     public void create() throws Exception
     {
+    	state = CREATING;
+    	
         // Redo initialization as the properties could have changed
         this.jbossEsbXml = JBossDeployerUtil.readEsbConfig(esbMetaData.getFile().openStream());
         esbMetaData.setModel(JBossDeployerUtil.getJbossEsbModel(jbossEsbXml));
@@ -191,8 +195,8 @@
             try
             {
                 vfsDeployment = createVFSDeployment(subDeployment);
+                mainDeployer.deploy(vfsDeployment);
                 log.info("Deploying '" + vfsDeployment.getName() + "'");
-                mainDeployer.deploy(vfsDeployment);
                 this.setPublishers(builder.getPublishers());
                 this.setServlets(builder.getServlets());
                 this.deployment = vfsDeployment;
@@ -211,55 +215,91 @@
                 throw new ConfigurationException("Error deploying '" + vfsDeployment.getName() + "'.", throwable);
             }
         }
-
+        this.state = CREATED;
     }
 
     public void start() throws Exception
     {    
-        if (controller == null)
-        {
-        	log.info("Starting ESB Deployment '" + deploymentName + "'");
-            controller = Configuration.create(jbossEsbXml, new ObjectName(mbeanName), publishers, servlets);
-            controller.start();
-        }
+    	if ((state == STARTING) || (state == STARTED))
+    		return;
+    	state = STARTING;
+
+    	try {
+	        if (controller == null)
+	        {
+	        	log.info("Starting ESB Deployment '" + deploymentName + "'");
+	            controller = Configuration.create(jbossEsbXml, new ObjectName(mbeanName), publishers, servlets);
+	            controller.start();
+	        }
+	        state = STARTED;
+    	} catch (Exception e) {
+    		state = FAILED;
+    		throw e;
+    	}
     }
 
 	public boolean isStarted() {
 		return (controller != null);
 	}
 
+	public String getStateString() {
+		return states[state];
+	}
+	
+	public int getState() {
+		return state;
+	}
+	
     public void stop() throws Exception
     {        
-        if (controller != null)
-        {
-        	log.info("Stopping '" + deploymentName + "'");
-	        ServicePublisher.removeServicePublishers(controller);
-	        controller.stop();
-	        controller = null;
-        }
+    	if (state != STARTED)
+    		return;
+    	
+    	state = STOPPING;
+    	try {
+	        if (controller != null)
+	        {
+	        	log.info("Stopping '" + deploymentName + "'");
+		        ServicePublisher.removeServicePublishers(controller);
+		        controller.stop();
+		        controller = null;
+		        state = STOPPED;
+	        }
+    	} catch (Exception e) {
+    		throw e;
+    	}
     }
 
     public void destroy() throws Exception
     {
+    	if (state == DESTROYED)
+    		return;
+    	
         log.info("Destroying '" + deploymentName + "'");
+        state = DESTROYING;
         
-        if (deployment != null)
-        {
-            log.info("Undeploying '" + deployment.getSimpleName() + "'");
-            mainDeployer.undeploy(deployment);
-            VirtualFile deploymentFile = deployment.getRoot();
-            if(deploymentFile.exists())
-            {
-                log.info("Deleting '" + deployment.getSimpleName() + "'");
-                if(!deploymentFile.delete())
-                {
-                    log.debug("Failed to delete sub deployment '" + deployment.getName() + "'.");
-                }
-            }
+        try {
+	        if (deployment != null)
+	        {
+	            log.info("Undeploying '" + deployment.getSimpleName() + "'");
+	            mainDeployer.undeploy(deployment);
+	            VirtualFile deploymentFile = deployment.getRoot();
+	            if(deploymentFile.exists())
+	            {
+	                log.info("Deleting '" + deployment.getSimpleName() + "'");
+	                if(!deploymentFile.delete())
+	                {
+	                    log.debug("Failed to delete sub deployment '" + deployment.getName() + "'.");
+	                }
+	            }
+	        }
+	
+	        LifecycleResourceManager.getSingleton().disassociateDeployment(deploymentName);
+	        LifecycleResourceManager.getSingleton().destroyResources();
+	        state = DESTROYED;
+        } catch (Exception e) {
+        	throw e;
         }
-
-        LifecycleResourceManager.getSingleton().disassociateDeployment(deploymentName);
-        LifecycleResourceManager.getSingleton().destroyResources();
     }
     
     private VFSDeployment createVFSDeployment(File war) throws IOException

Modified: labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeploymentMBean.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeploymentMBean.java	2010-10-04 03:14:21 UTC (rev 35394)
+++ labs/jbossesb/branches/JBESB_4_9_CP/product/rosetta/src/org/jboss/soa/esb/listeners/deployers/mc/EsbDeploymentMBean.java	2010-10-04 03:23:17 UTC (rev 35395)
@@ -61,4 +61,39 @@
      * @return String   The jboss-esb.xml files content as html.
      */
     String getJbossEsbXmlAsHtml();
+    
+	String getStateString();
+	
+	int getState();
+
+    public static final String[] states = {
+        "Stopped", "Stopping", "Starting", "Started", "Failed",
+        "Destroying", "Destroyed", "Creating", "Created", 
+        "Initializing", "Initialized", "Unregistered"
+     };
+
+     /** stop has completed */
+     public static final int STOPPED  = 0;
+     /** stop has been invoked */
+     public static final int STOPPING = 1;
+     /** start has been invoked */
+     public static final int STARTING = 2;
+     /** start has completed */
+     public static final int STARTED  = 3;
+     /** There has been an error during some operation */
+     public static final int FAILED  = 4;
+     /** destroy has been invoked */ 
+     public static final int DESTROYING = 5;
+     /** destroy has completed */
+     public static final int DESTROYED = 6;
+     /** create has been invoked */
+     public static final int CREATING = 7;
+     /** create has completed */
+     public static final int CREATED = 8;
+     /** initialize has been invoked */
+     public static final int INITIALIZING = 9;
+     /** initialize has completed */
+     public static final int INITIALIZED = 10;
+     /** not yet created */
+     public static final int UNREGISTERED = 11;
 }



More information about the jboss-svn-commits mailing list