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