View Javadoc

1   /*
2    * $Id$
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.util;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.agent.Agent;
15  import org.mule.config.i18n.CoreMessages;
16  
17  import java.util.Collection;
18  import java.util.Iterator;
19  
20  public class ApplicationStartupSplashScreen extends SplashScreen
21  {
22      protected void doHeader(MuleContext context)
23      {
24          header.add("Application: " + context.getConfiguration().getId());
25          header.add(String.format("OS encoding: %s, Mule encoding: %s",
26                                   System.getProperty("file.encoding"),
27                                   context.getConfiguration().getDefaultEncoding()));
28          header.add(" ");
29      }
30     
31      protected void doFooter(MuleContext context)
32      {
33          // Mule Agents
34          if (!body.isEmpty())
35          {
36              footer.add(" ");
37          }
38          //List agents
39          Collection agents = context.getRegistry().lookupObjects(Agent.class);
40          if (agents.size() == 0)
41          {
42              footer.add(CoreMessages.agentsRunning().getMessage() + " "
43                      + CoreMessages.none().getMessage());
44          }
45          else
46          {
47              footer.add(CoreMessages.agentsRunning().getMessage());
48              Agent agent;
49              for (Iterator iterator = agents.iterator(); iterator.hasNext();)
50              {
51                  agent = (Agent) iterator.next();
52                  footer.add("  " + agent.getDescription());
53              }
54          }
55      }    
56  }