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 | 2 | protected List header = new ArrayList(); |
36 | 2 | protected List body = new ArrayList(); |
37 | 2 | protected List footer = new ArrayList(); |
38 | |
|
39 | 2 | private static Log logger = LogFactory.getLog(SplashScreen.class); |
40 | |
|
41 | 2 | private static final Map instances = new HashMap(); |
42 | |
|
43 | |
public static synchronized SplashScreen getInstance(Class clazz) |
44 | |
{ |
45 | 2 | SplashScreen splashScreen = (SplashScreen) instances.get(clazz); |
46 | |
|
47 | 2 | if (splashScreen == null) |
48 | |
{ |
49 | |
try |
50 | |
{ |
51 | 2 | splashScreen = (SplashScreen) clazz.newInstance(); |
52 | 2 | instances.put(clazz, splashScreen); |
53 | |
} |
54 | 0 | catch (Exception ignore) |
55 | |
{ |
56 | 0 | logger.debug(ignore); |
57 | 2 | } |
58 | |
} |
59 | |
|
60 | 2 | return splashScreen; |
61 | |
} |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
final public void setHeader(MuleContext context) |
70 | |
{ |
71 | 0 | header.clear(); |
72 | 0 | doHeader(context); |
73 | 0 | } |
74 | |
|
75 | |
final public void addBody(String line) |
76 | |
{ |
77 | 0 | doBody(line); |
78 | 0 | } |
79 | |
|
80 | |
final public void setFooter(MuleContext context) |
81 | |
{ |
82 | 0 | footer.clear(); |
83 | 0 | doFooter(context); |
84 | 0 | } |
85 | |
|
86 | |
protected void doHeader(MuleContext context) |
87 | |
{ |
88 | |
|
89 | 0 | } |
90 | |
|
91 | |
protected void doBody(String line) |
92 | |
{ |
93 | 0 | body.add(line); |
94 | 0 | } |
95 | |
|
96 | |
protected void doFooter(MuleContext context) |
97 | |
{ |
98 | |
|
99 | 0 | } |
100 | |
|
101 | |
public String toString() |
102 | |
{ |
103 | 6 | List boilerPlate = new ArrayList(header); |
104 | 6 | boilerPlate.addAll(body); |
105 | 6 | boilerPlate.addAll(footer); |
106 | 6 | return StringMessageUtils.getBoilerPlate(boilerPlate, '*', 70); |
107 | |
} |
108 | |
|
109 | |
protected SplashScreen() |
110 | 2 | { |
111 | |
|
112 | 2 | } |
113 | |
} |