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.util;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.agent.Agent;
11  import org.mule.config.i18n.CoreMessages;
12  
13  import java.util.Collection;
14  import java.util.StringTokenizer;
15  
16  public class ApplicationStartupSplashScreen extends SplashScreen
17  {
18      @Override
19      protected void doHeader(MuleContext context)
20      {
21          header.add("Application: " + context.getConfiguration().getId());
22          header.add(String.format("OS encoding: %s, Mule encoding: %s",
23                                   System.getProperty("file.encoding"),
24                                   context.getConfiguration().getDefaultEncoding()));
25          header.add(" ");
26      }
27  
28      @Override
29      protected void doFooter(MuleContext context)
30      {
31          // Mule Agents
32          if (!body.isEmpty())
33          {
34              footer.add(" ");
35          }
36          //List agents
37          Collection<Agent> agents = context.getRegistry().lookupObjects(Agent.class);
38          if (agents.size() == 0)
39          {
40              footer.add(CoreMessages.agentsRunning().getMessage() + " "
41                      + CoreMessages.none().getMessage());
42          }
43          else
44          {
45              footer.add(CoreMessages.agentsRunning().getMessage());
46              for (Agent agent : agents)
47              {
48                  String description = agent.getDescription();
49                  if (description.startsWith("'''"))
50                  {
51                      description = description.substring("'''".length());
52                      // handle multiline descriptions better
53                      for (StringTokenizer st = new StringTokenizer(description, String.format("%n")); st.hasMoreTokens();)
54                      {
55                          footer.add("  " + st.nextToken());
56                      }
57                  }
58                  else
59                  {
60                      footer.add("  " + description);
61                  }
62              }
63          }
64      }
65  }