View Javadoc

1   /*
2    * $Id: DeploymentStatusTracker.java 22567 2011-07-27 23:20:32Z julien.eluard $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.launcher;
12  
13  import java.util.Collections;
14  import java.util.Map;
15  import java.util.concurrent.ConcurrentHashMap;
16  
17  /**
18   * Keeps track of the deployment status of all applications in the Mule instance.
19   */
20  public class DeploymentStatusTracker extends AbstractDeploymentListener
21  {
22  
23      public static enum DeploymentState
24      {
25          // The deployment is in progress
26          DEPLOYING,
27          // The deployment was finished with a failure
28          FAILED,
29          // The deployment was successfully finished
30          DEPLOYED
31      }
32  
33      protected Map<String, DeploymentState> deploymentStates = new ConcurrentHashMap<String, DeploymentState>();
34  
35      public Map<String, DeploymentState> getDeploymentStates()
36      {
37          return Collections.unmodifiableMap(deploymentStates);
38      }
39  
40      public void onDeploymentStart(String appName)
41      {
42          deploymentStates.put(appName, DeploymentState.DEPLOYING);
43      }
44  
45      public void onDeploymentSuccess(String appName)
46      {
47          deploymentStates.put(appName, DeploymentState.DEPLOYED);
48      }
49  
50      public void onDeploymentFailure(String appName, Throwable failureCause)
51      {
52          deploymentStates.put(appName, DeploymentState.FAILED);
53      }
54  
55  }