1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.module.launcher; |
8 | |
|
9 | |
import java.util.Map; |
10 | |
|
11 | |
import org.apache.commons.logging.Log; |
12 | |
import org.apache.commons.logging.LogFactory; |
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
public class StartupSummaryDeploymentListener implements DeploymentService.StartupListener |
18 | |
{ |
19 | 0 | protected transient final Log logger = LogFactory.getLog(getClass()); |
20 | |
|
21 | |
protected DeploymentStatusTracker tracker; |
22 | |
|
23 | |
public StartupSummaryDeploymentListener(DeploymentStatusTracker tracker) |
24 | 0 | { |
25 | 0 | this.tracker = tracker; |
26 | 0 | } |
27 | |
|
28 | |
public void onAfterStartup() |
29 | |
{ |
30 | 0 | if (!logger.isInfoEnabled()) |
31 | |
{ |
32 | 0 | return; |
33 | |
} |
34 | |
|
35 | 0 | Map<String, DeploymentStatusTracker.DeploymentState> applicationStates = tracker.getDeploymentStates(); |
36 | |
|
37 | 0 | if (applicationStates.isEmpty()) |
38 | |
{ |
39 | 0 | return; |
40 | |
} |
41 | |
|
42 | 0 | SimpleLoggingTable applicationTable = new SimpleLoggingTable(); |
43 | 0 | applicationTable.addColumn("APPLICATION", 45); |
44 | 0 | applicationTable.addColumn("STATUS", 18); |
45 | |
|
46 | 0 | for (String app : applicationStates.keySet()) |
47 | |
{ |
48 | 0 | String[] data = new String[] {app, applicationStates.get(app).toString()}; |
49 | 0 | applicationTable.addDataRow(data); |
50 | 0 | } |
51 | |
|
52 | 0 | String message = String.format("%n%n%s", applicationTable); |
53 | |
|
54 | 0 | logger.info(message); |
55 | 0 | } |
56 | |
} |