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