Coverage Report - org.mule.util.ServerStartupSplashScreen
 
Classes in this File Line Coverage Branch Coverage Complexity
ServerStartupSplashScreen
0%
0/33
0%
0/14
0
 
 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.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  0
 public class ServerStartupSplashScreen extends SplashScreen
 21  
 {
 22  
     @Override
 23  
     protected void doHeader(MuleContext context)
 24  
     {
 25  0
         String notset = CoreMessages.notSet().getMessage();
 26  
 
 27  
         // Mule Version, Timestamp, and Server ID
 28  0
         Manifest mf = MuleManifest.getManifest();
 29  0
         Attributes att = mf.getMainAttributes();
 30  0
         if (att.values().size() > 0)
 31  
         {
 32  0
             header.add(StringUtils.defaultString(MuleManifest.getProductDescription(), notset));
 33  0
             header.add(CoreMessages.version().getMessage() + " Build: "
 34  
                     + StringUtils.defaultString(MuleManifest.getBuildNumber(), notset));
 35  
 
 36  0
             header.add(StringUtils.defaultString(MuleManifest.getVendorName(), notset));
 37  0
             header.add(StringUtils.defaultString(MuleManifest.getProductMoreInfo(), notset));
 38  
         }
 39  
         else
 40  
         {
 41  0
             header.add(CoreMessages.versionNotSet().getMessage());
 42  
         }
 43  0
         header.add(" ");
 44  0
         if (context.getStartDate() > 0)
 45  
         {
 46  0
             header.add(CoreMessages.serverStartedAt(context.getStartDate()).getMessage());
 47  
         }
 48  0
         header.add("Server ID: " + context.getConfiguration().getId());
 49  
 
 50  
         // JDK, Encoding, OS, and Host
 51  0
         header.add("JDK: " + System.getProperty("java.version") + " ("
 52  
             + System.getProperty("java.vm.info") + ")");
 53  0
         header.add("OS encoding: " + System.getProperty("file.encoding")
 54  
                 + ", Mule encoding: " + context.getConfiguration().getDefaultEncoding());
 55  0
         String patch = System.getProperty("sun.os.patch.level", null);
 56  0
         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  0
             InetAddress host = InetAddress.getLocalHost();
 62  0
             header.add("Host: " + host.getHostName() + " (" + host.getHostAddress() + ")");
 63  
         }
 64  0
         catch (UnknownHostException e)
 65  
         {
 66  
             // ignore
 67  0
         }
 68  
 
 69  
         // Dev/Production mode
 70  
         // TODO for now now used, potentially a 'production' mode can disable direcotry (non-api) hot-deployment for tight app control
 71  
         //final boolean productionMode = StartupContext.get().getStartupOptions().containsKey("production");
 72  
         //header.add("Mode: " + (productionMode ? "Production" : "Development"));
 73  
 
 74  0
         header.add(" ");
 75  0
     }
 76  
 
 77  
     @Override
 78  
     protected void doFooter(MuleContext context)
 79  
     {
 80  
         // Mule Agents
 81  0
         if (!body.isEmpty())
 82  
         {
 83  0
             footer.add(" ");
 84  
         }
 85  
         //List agents
 86  0
         Collection<Agent> agents = context.getRegistry().lookupObjects(Agent.class);
 87  0
         if (agents.size() == 0)
 88  
         {
 89  0
             footer.add(CoreMessages.agentsRunning().getMessage() + " "
 90  
                     + CoreMessages.none().getMessage());
 91  
         }
 92  
         else
 93  
         {
 94  0
             footer.add(CoreMessages.agentsRunning().getMessage());
 95  0
             for (Agent agent : agents)
 96  
             {
 97  0
                 footer.add("  " + agent.getDescription());
 98  
             }
 99  
         }
 100  0
     }
 101  
 }