1
2
3
4
5
6
7
8
9
10
11 package org.mule.util;
12
13 import org.mule.api.MuleContext;
14
15 import java.util.ArrayList;
16 import java.util.HashMap;
17 import java.util.List;
18 import java.util.Map;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23
24
25
26
27
28
29
30
31
32
33 public abstract class SplashScreen
34 {
35 protected List header = new ArrayList();
36 protected List body = new ArrayList();
37 protected List footer = new ArrayList();
38
39 private static Log logger = LogFactory.getLog(SplashScreen.class);
40
41 private static final Map instances = new HashMap();
42
43 public static synchronized SplashScreen getInstance(Class clazz)
44 {
45 SplashScreen splashScreen = (SplashScreen) instances.get(clazz);
46
47 if (splashScreen == null)
48 {
49 try
50 {
51 splashScreen = (SplashScreen) clazz.newInstance();
52 instances.put(clazz, splashScreen);
53 }
54 catch (Exception ignore)
55 {
56 logger.debug(ignore);
57 }
58 }
59
60 return splashScreen;
61 }
62
63
64
65
66
67
68
69 final public void setHeader(MuleContext context)
70 {
71 header.clear();
72 doHeader(context);
73 }
74
75 final public void addBody(String line)
76 {
77 doBody(line);
78 }
79
80 final public void setFooter(MuleContext context)
81 {
82 footer.clear();
83 doFooter(context);
84 }
85
86 protected void doHeader(MuleContext context)
87 {
88
89 }
90
91 protected void doBody(String line)
92 {
93 body.add(line);
94 }
95
96 protected void doFooter(MuleContext context)
97 {
98
99 }
100
101 public String toString()
102 {
103 List boilerPlate = new ArrayList(header);
104 boilerPlate.addAll(body);
105 boilerPlate.addAll(footer);
106 return StringMessageUtils.getBoilerPlate(boilerPlate, '*', 70);
107 }
108
109 protected SplashScreen()
110 {
111
112 }
113 }