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