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 | |
|
28 | |
import org.apache.commons.configuration.Configuration; |
29 | |
import org.apache.commons.configuration.ConfigurationConverter; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public class BaseUnicastRemoteService extends UnicastRemoteObject |
38 | |
implements Service |
39 | |
{ |
40 | |
|
41 | |
|
42 | |
|
43 | |
private static final long serialVersionUID = -7775459623190960297L; |
44 | |
|
45 | |
protected Configuration configuration; |
46 | |
private boolean isInitialized; |
47 | |
private InitableBroker initableBroker; |
48 | |
private String name; |
49 | |
private ServiceBroker serviceBroker; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
public BaseUnicastRemoteService() |
56 | |
throws RemoteException |
57 | 0 | { |
58 | 0 | isInitialized = false; |
59 | 0 | initableBroker = null; |
60 | 0 | name = null; |
61 | 0 | serviceBroker = null; |
62 | 0 | } |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
@Override |
70 | |
public Configuration getConfiguration() |
71 | |
{ |
72 | 0 | if (name == null) |
73 | |
{ |
74 | 0 | return null; |
75 | |
} |
76 | |
else |
77 | |
{ |
78 | 0 | if (configuration == null) |
79 | |
{ |
80 | 0 | configuration = getServiceBroker().getConfiguration(name); |
81 | |
} |
82 | 0 | return configuration; |
83 | |
} |
84 | |
} |
85 | |
|
86 | |
@Override |
87 | |
public void setInitableBroker(InitableBroker broker) |
88 | |
{ |
89 | 0 | this.initableBroker = broker; |
90 | 0 | } |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
public InitableBroker getInitableBroker() |
97 | |
{ |
98 | 0 | return initableBroker; |
99 | |
} |
100 | |
|
101 | |
@Override |
102 | |
public void init(Object data) |
103 | |
throws InitializationException |
104 | |
{ |
105 | 0 | init(); |
106 | 0 | } |
107 | |
|
108 | |
@Override |
109 | |
public void init() throws InitializationException |
110 | |
{ |
111 | 0 | setInit(true); |
112 | 0 | } |
113 | |
|
114 | |
protected void setInit(boolean value) |
115 | |
{ |
116 | 0 | isInitialized = value; |
117 | 0 | } |
118 | |
|
119 | |
@Override |
120 | |
public boolean getInit() |
121 | |
{ |
122 | 0 | return isInitialized; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
@Override |
129 | |
public void shutdown() |
130 | |
{ |
131 | 0 | setInit(false); |
132 | 0 | } |
133 | |
|
134 | |
@Override |
135 | |
public Properties getProperties() |
136 | |
{ |
137 | 0 | return ConfigurationConverter.getProperties(getConfiguration()); |
138 | |
} |
139 | |
|
140 | |
@Override |
141 | |
public void setName(String name) |
142 | |
{ |
143 | 0 | this.name = name; |
144 | 0 | } |
145 | |
|
146 | |
@Override |
147 | |
public String getName() |
148 | |
{ |
149 | 0 | return name; |
150 | |
} |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
public ServiceBroker getServiceBroker() |
157 | |
{ |
158 | 0 | return serviceBroker; |
159 | |
} |
160 | |
|
161 | |
@Override |
162 | |
public void setServiceBroker(ServiceBroker broker) |
163 | |
{ |
164 | 0 | this.serviceBroker = broker; |
165 | 0 | } |
166 | |
} |