Coverage Report - org.mule.util.SplashScreen
 
Classes in this File Line Coverage Branch Coverage Complexity
SplashScreen
0%
0/22
N/A
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  
 
 11  
 import java.util.ArrayList;
 12  
 import java.util.List;
 13  
 
 14  
 /**
 15  
  * Implements singleton pattern to allow different splash-screen implementations
 16  
  * following the concept of header, body, and footer. Header and footer are
 17  
  * reserved internally to Mule but body can be used to customize splash-screen
 18  
  * output. External code can e.g. hook into the start-up splash-screen as follows:
 19  
  * <pre><code>
 20  
  *   SplashScreen splashScreen = SplashScreen.getInstance(ServerStartupSplashScreen.class);
 21  
  *   splashScreen.addBody("Some extra text");
 22  
  * </code></pre>
 23  
  */
 24  
 public abstract class SplashScreen
 25  
 {
 26  0
     protected List<String> header = new ArrayList<String>();
 27  0
     protected List<String> body = new ArrayList<String>();
 28  0
     protected List<String> footer = new ArrayList<String>();
 29  
     
 30  
     /**
 31  
      * Setting the header clears body and footer assuming a new
 32  
      * splash-screen is built.
 33  
      * 
 34  
      */
 35  
     final public void setHeader(MuleContext context)
 36  
     {
 37  0
         header.clear();
 38  0
         doHeader(context);
 39  0
     }
 40  
     
 41  
     final public void addBody(String line)
 42  
     {
 43  0
         doBody(line);
 44  0
     }
 45  
     
 46  
     final public void setFooter(MuleContext context)
 47  
     {
 48  0
         footer.clear();
 49  0
         doFooter(context);
 50  0
     }
 51  
 
 52  
     public static String miniSplash(final String message)
 53  
     {
 54  
         // middle dot char
 55  0
         return StringMessageUtils.getBoilerPlate(message, '+', 60);
 56  
     }
 57  
 
 58  
     protected void doHeader(MuleContext context)
 59  
     {
 60  
         // default reserved for mule core info
 61  0
     }   
 62  
     
 63  
     protected void doBody(String line)
 64  
     {
 65  0
         body.add(line);
 66  0
     }
 67  
 
 68  
     protected void doFooter(MuleContext context)
 69  
     {
 70  
         // default reserved for mule core info
 71  0
     }    
 72  
     
 73  
     public String toString()
 74  
     {
 75  0
         List<String> boilerPlate = new ArrayList<String>(header);
 76  0
         boilerPlate.addAll(body);
 77  0
         boilerPlate.addAll(footer);
 78  0
         return StringMessageUtils.getBoilerPlate(boilerPlate, '*', 70);
 79  
     }
 80  
     
 81  
     protected SplashScreen()
 82  0
     {
 83  
         // make sure no one else creates an instance
 84  0
     }
 85  
 }