1 | |
package org.apache.turbine.services; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
import java.rmi.RemoteException; |
25 | |
import java.rmi.server.UnicastRemoteObject; |
26 | |
import java.util.Properties; |
27 | |
import javax.servlet.ServletConfig; |
28 | |
|
29 | |
import org.apache.commons.configuration.Configuration; |
30 | |
import org.apache.commons.configuration.ConfigurationConverter; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class BaseUnicastRemoteService extends UnicastRemoteObject |
39 | |
implements Service |
40 | |
{ |
41 | |
|
42 | |
|
43 | |
|
44 | |
private static final long serialVersionUID = -7775459623190960297L; |
45 | |
|
46 | |
protected Configuration configuration; |
47 | |
private boolean isInitialized; |
48 | |
private InitableBroker initableBroker; |
49 | |
private String name; |
50 | |
private ServiceBroker serviceBroker; |
51 | |
|
52 | |
public BaseUnicastRemoteService() |
53 | |
throws RemoteException |
54 | 0 | { |
55 | 0 | isInitialized = false; |
56 | 0 | initableBroker = null; |
57 | 0 | name = null; |
58 | 0 | serviceBroker = null; |
59 | 0 | } |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public Configuration getConfiguration() |
67 | |
{ |
68 | 0 | if (name == null) |
69 | |
{ |
70 | 0 | return null; |
71 | |
} |
72 | |
else |
73 | |
{ |
74 | 0 | if (configuration == null) |
75 | |
{ |
76 | 0 | configuration = getServiceBroker().getConfiguration(name); |
77 | |
} |
78 | 0 | return configuration; |
79 | |
} |
80 | |
} |
81 | |
|
82 | |
public void init(ServletConfig config) |
83 | |
throws InitializationException |
84 | |
{ |
85 | 0 | setInit(true); |
86 | 0 | } |
87 | |
|
88 | |
public void setInitableBroker(InitableBroker broker) |
89 | |
{ |
90 | 0 | this.initableBroker = broker; |
91 | 0 | } |
92 | |
|
93 | |
public InitableBroker getInitableBroker() |
94 | |
{ |
95 | 0 | return initableBroker; |
96 | |
} |
97 | |
|
98 | |
public void init(Object data) |
99 | |
throws InitializationException |
100 | |
{ |
101 | 0 | init((ServletConfig) data); |
102 | 0 | } |
103 | |
|
104 | |
public void init() throws InitializationException |
105 | |
{ |
106 | 0 | setInit(true); |
107 | 0 | } |
108 | |
|
109 | |
protected void setInit(boolean value) |
110 | |
{ |
111 | 0 | isInitialized = value; |
112 | 0 | } |
113 | |
|
114 | |
public boolean getInit() |
115 | |
{ |
116 | 0 | return isInitialized; |
117 | |
} |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public void shutdown() |
123 | |
{ |
124 | 0 | setInit(false); |
125 | 0 | } |
126 | |
|
127 | |
public Properties getProperties() |
128 | |
{ |
129 | 0 | return ConfigurationConverter.getProperties(getConfiguration()); |
130 | |
} |
131 | |
|
132 | |
public void setName(String name) |
133 | |
{ |
134 | 0 | this.name = name; |
135 | 0 | } |
136 | |
|
137 | |
public String getName() |
138 | |
{ |
139 | 0 | return name; |
140 | |
} |
141 | |
|
142 | |
public ServiceBroker getServiceBroker() |
143 | |
{ |
144 | 0 | return serviceBroker; |
145 | |
} |
146 | |
|
147 | |
public void setServiceBroker(ServiceBroker broker) |
148 | |
{ |
149 | 0 | this.serviceBroker = broker; |
150 | 0 | } |
151 | |
} |