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 {
55 isInitialized = false;
56 initableBroker = null;
57 name = null;
58 serviceBroker = null;
59 }
60
61
62
63
64
65
66 public Configuration getConfiguration()
67 {
68 if (name == null)
69 {
70 return null;
71 }
72 else
73 {
74 if (configuration == null)
75 {
76 configuration = getServiceBroker().getConfiguration(name);
77 }
78 return configuration;
79 }
80 }
81
82 public void init(ServletConfig config)
83 throws InitializationException
84 {
85 setInit(true);
86 }
87
88 public void setInitableBroker(InitableBroker broker)
89 {
90 this.initableBroker = broker;
91 }
92
93 public InitableBroker getInitableBroker()
94 {
95 return initableBroker;
96 }
97
98 public void init(Object data)
99 throws InitializationException
100 {
101 init((ServletConfig) data);
102 }
103
104 public void init() throws InitializationException
105 {
106 setInit(true);
107 }
108
109 protected void setInit(boolean value)
110 {
111 isInitialized = value;
112 }
113
114 public boolean getInit()
115 {
116 return isInitialized;
117 }
118
119
120
121
122 public void shutdown()
123 {
124 setInit(false);
125 }
126
127 public Properties getProperties()
128 {
129 return ConfigurationConverter.getProperties(getConfiguration());
130 }
131
132 public void setName(String name)
133 {
134 this.name = name;
135 }
136
137 public String getName()
138 {
139 return name;
140 }
141
142 public ServiceBroker getServiceBroker()
143 {
144 return serviceBroker;
145 }
146
147 public void setServiceBroker(ServiceBroker broker)
148 {
149 this.serviceBroker = broker;
150 }
151 }