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 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  import org.mule.util.SplashScreen;
14  import org.mule.util.StringUtils;
15  
16  import java.net.InetAddress;
17  import java.net.UnknownHostException;
18  import java.util.Collection;
19  import java.util.jar.Attributes;
20  import java.util.jar.Manifest;
21  
22  public class MuleContainerStartupSplashScreen extends SplashScreen
23  {
24      public void doBody()
25      {
26          String notset = CoreMessages.notSet().getMessage();
27  
28          // Mule Version, Timestamp, and Server ID
29          Manifest mf = MuleManifest.getManifest();
30          Attributes att = mf.getMainAttributes();
31          if (att.values().size() > 0)
32          {
33              doBody(StringUtils.defaultString(MuleManifest.getProductDescription(), notset));
34              doBody(String.format("%s Build: %s",
35                                   CoreMessages.version().getMessage(),
36                                   StringUtils.defaultString(MuleManifest.getBuildNumber(), notset)));
37  
38              doBody(StringUtils.defaultString(MuleManifest.getVendorName(), notset));
39              doBody(StringUtils.defaultString(MuleManifest.getProductMoreInfo(), notset));
40          }
41          else
42          {
43              doBody(CoreMessages.versionNotSet().getMessage());
44          }
45          doBody(" ");
46  
47          // TODO maybe be more precise and count from container bootstrap time?
48          doBody(CoreMessages.serverStartedAt(System.currentTimeMillis()).getMessage());
49  
50          doBody(String.format("JDK: %s (%s)",
51                               System.getProperty("java.version"),
52                               System.getProperty("java.vm.info")));
53  
54          String patch = System.getProperty("sun.os.patch.level", null);
55  
56          doBody(String.format("OS: %s%s (%s, %s)",
57                               System.getProperty("os.name"),
58                               (patch != null && !"unknown".equalsIgnoreCase(patch) ? " - " + patch : ""),
59                               System.getProperty("os.version"),
60                               System.getProperty("os.arch")));
61          try
62          {
63              InetAddress host = InetAddress.getLocalHost();
64              doBody(String.format("Host: %s (%s)", host.getHostName(), host.getHostAddress()));
65          }
66          catch (UnknownHostException e)
67          {
68              // ignore
69          }
70      }
71  
72      @Override
73      protected void doFooter(MuleContext context)
74      {
75          // Mule Agents
76          if (!body.isEmpty())
77          {
78              footer.add(" ");
79          }
80          //List agents
81          Collection<Agent> agents = context.getRegistry().lookupObjects(Agent.class);
82          if (agents.size() == 0)
83          {
84              footer.add(CoreMessages.agentsRunning().getMessage() + " "
85                      + CoreMessages.none().getMessage());
86          }
87          else
88          {
89              footer.add(CoreMessages.agentsRunning().getMessage());
90              for (Agent agent : agents)
91              {
92                  footer.add("  " + agent.getDescription());
93              }
94          }
95      }
96  }