View Javadoc

1   /*
2    * $Id: MuleContainerStartupSplashScreen.java 20754 2010-12-15 15:51:03Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.module.launcher;
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.i18n.CoreMessages;
17  import org.mule.util.SplashScreen;
18  import org.mule.util.StringUtils;
19  
20  import java.net.InetAddress;
21  import java.net.UnknownHostException;
22  import java.util.Collection;
23  import java.util.jar.Attributes;
24  import java.util.jar.Manifest;
25  
26  public class MuleContainerStartupSplashScreen extends SplashScreen
27  {
28      public void doBody()
29      {
30          String notset = CoreMessages.notSet().getMessage();
31  
32          // Mule Version, Timestamp, and Server ID
33          Manifest mf = MuleManifest.getManifest();
34          Attributes att = mf.getMainAttributes();
35          if (att.values().size() > 0)
36          {
37              doBody(StringUtils.defaultString(MuleManifest.getProductDescription(), notset));
38              doBody(String.format("%s Build: %s",
39                                   CoreMessages.version().getMessage(),
40                                   StringUtils.defaultString(MuleManifest.getBuildNumber(), notset)));
41  
42              doBody(StringUtils.defaultString(MuleManifest.getVendorName(), notset));
43              doBody(StringUtils.defaultString(MuleManifest.getProductMoreInfo(), notset));
44          }
45          else
46          {
47              doBody(CoreMessages.versionNotSet().getMessage());
48          }
49          doBody(" ");
50  
51          // TODO maybe be more precise and count from container bootstrap time?
52          doBody(CoreMessages.serverStartedAt(System.currentTimeMillis()).getMessage());
53  
54          doBody(String.format("JDK: %s (%s)",
55                               System.getProperty("java.version"),
56                               System.getProperty("java.vm.info")));
57  
58          String patch = System.getProperty("sun.os.patch.level", null);
59  
60          doBody(String.format("OS: %s%s (%s, %s)",
61                               System.getProperty("os.name"),
62                               (patch != null && !"unknown".equalsIgnoreCase(patch) ? " - " + patch : ""),
63                               System.getProperty("os.version"),
64                               System.getProperty("os.arch")));
65          try
66          {
67              InetAddress host = InetAddress.getLocalHost();
68              doBody(String.format("Host: %s (%s)", host.getHostName(), host.getHostAddress()));
69          }
70          catch (UnknownHostException e)
71          {
72              // ignore
73          }
74      }
75  
76      @Override
77      protected void doFooter(MuleContext context)
78      {
79          // Mule Agents
80          if (!body.isEmpty())
81          {
82              footer.add(" ");
83          }
84          //List agents
85          Collection<Agent> agents = context.getRegistry().lookupObjects(Agent.class);
86          if (agents.size() == 0)
87          {
88              footer.add(CoreMessages.agentsRunning().getMessage() + " "
89                      + CoreMessages.none().getMessage());
90          }
91          else
92          {
93              footer.add(CoreMessages.agentsRunning().getMessage());
94              for (Agent agent : agents)
95              {
96                  footer.add("  " + agent.getDescription());
97              }
98          }
99      }
100 }