1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.util; |
12 | |
|
13 | |
import org.mule.api.MuleContext; |
14 | |
import org.mule.api.agent.Agent; |
15 | |
import org.mule.config.MuleManifest; |
16 | |
import org.mule.config.StartupContext; |
17 | |
import org.mule.config.i18n.CoreMessages; |
18 | |
|
19 | |
import java.net.InetAddress; |
20 | |
import java.net.UnknownHostException; |
21 | |
import java.util.Collection; |
22 | |
import java.util.Iterator; |
23 | |
import java.util.Map; |
24 | |
import java.util.jar.Manifest; |
25 | |
|
26 | 0 | public class ServerStartupSplashScreen extends SplashScreen |
27 | |
{ |
28 | |
protected void doHeader(MuleContext context) |
29 | |
{ |
30 | 0 | String notset = CoreMessages.notSet().getMessage(); |
31 | |
|
32 | |
|
33 | 0 | Manifest mf = MuleManifest.getManifest(); |
34 | 0 | Map att = mf.getMainAttributes(); |
35 | 0 | if (att.values().size() > 0) |
36 | |
{ |
37 | 0 | header.add(StringUtils.defaultString(MuleManifest.getProductDescription(), notset)); |
38 | 0 | header.add(CoreMessages.version().getMessage() + " Build: " |
39 | |
+ StringUtils.defaultString(MuleManifest.getBuildNumber(), notset)); |
40 | |
|
41 | 0 | header.add(StringUtils.defaultString(MuleManifest.getVendorName(), notset)); |
42 | 0 | header.add(StringUtils.defaultString(MuleManifest.getProductMoreInfo(), notset)); |
43 | |
} |
44 | |
else |
45 | |
{ |
46 | 0 | header.add(CoreMessages.versionNotSet().getMessage()); |
47 | |
} |
48 | 0 | header.add(" "); |
49 | 0 | if (context.getStartDate() > 0) |
50 | |
{ |
51 | 0 | header.add(CoreMessages.serverStartedAt(context.getStartDate()).getMessage()); |
52 | |
} |
53 | 0 | header.add("Server ID: " + context.getConfiguration().getId()); |
54 | |
|
55 | |
|
56 | 0 | header.add("JDK: " + System.getProperty("java.version") + " (" |
57 | |
+ System.getProperty("java.vm.info") + ")"); |
58 | 0 | header.add("OS encoding: " + System.getProperty("file.encoding") |
59 | |
+ ", Mule encoding: " + context.getConfiguration().getDefaultEncoding()); |
60 | 0 | String patch = System.getProperty("sun.os.patch.level", null); |
61 | 0 | header.add("OS: " + System.getProperty("os.name") |
62 | |
+ (patch != null && !"unknown".equalsIgnoreCase(patch) ? " - " + patch : "") + " (" |
63 | |
+ System.getProperty("os.version") + ", " + System.getProperty("os.arch") + ")"); |
64 | |
try |
65 | |
{ |
66 | 0 | InetAddress host = InetAddress.getLocalHost(); |
67 | 0 | header.add("Host: " + host.getHostName() + " (" + host.getHostAddress() + ")"); |
68 | |
} |
69 | 0 | catch (UnknownHostException e) |
70 | |
{ |
71 | |
|
72 | 0 | } |
73 | |
|
74 | |
|
75 | 0 | final boolean productionMode = StartupContext.get().getStartupOptions().containsKey("production"); |
76 | 0 | header.add("Mode: " + (productionMode ? "Production" : "Development")); |
77 | |
|
78 | 0 | header.add(" "); |
79 | 0 | } |
80 | |
|
81 | |
protected void doFooter(MuleContext context) |
82 | |
{ |
83 | |
|
84 | 0 | if (!body.isEmpty()) |
85 | |
{ |
86 | 0 | footer.add(" "); |
87 | |
} |
88 | |
|
89 | 0 | Collection agents = context.getRegistry().lookupObjects(Agent.class); |
90 | 0 | if (agents.size() == 0) |
91 | |
{ |
92 | 0 | footer.add(CoreMessages.agentsRunning().getMessage() + " " |
93 | |
+ CoreMessages.none().getMessage()); |
94 | |
} |
95 | |
else |
96 | |
{ |
97 | 0 | footer.add(CoreMessages.agentsRunning().getMessage()); |
98 | |
Agent agent; |
99 | 0 | for (Iterator iterator = agents.iterator(); iterator.hasNext();) |
100 | |
{ |
101 | 0 | agent = (Agent) iterator.next(); |
102 | 0 | footer.add(" " + agent.getDescription()); |
103 | |
} |
104 | |
} |
105 | 0 | } |
106 | |
} |