KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > jmx > browser > model > service > CacheServiceProvider


1 /*
2
3  * EJTools, the Enterprise Java Tools
4
5  *
6
7  * Distributable under LGPL license.
8
9  * See terms of license at www.gnu.org.
10
11  */

12
13 package org.ejtools.jmx.browser.model.service;
14
15
16
17 import java.beans.beancontext.BeanContextServices JavaDoc;
18
19 import java.util.Enumeration JavaDoc;
20
21 import java.util.Hashtable JavaDoc;
22
23 import java.util.Iterator JavaDoc;
24
25 import java.util.Vector JavaDoc;
26
27
28
29 import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider;
30
31
32
33 /**
34
35  * Description of the Class
36
37  *
38
39  * @author letiemble
40
41  * @created 13 décembre 2001
42
43  * @version $Revision: 1.6 $
44
45  * @todo Javadoc to complete
46
47  * @todo Service release to complete
48
49  */

50
51 public class CacheServiceProvider extends CustomBeanContextServiceProvider implements CacheService
52
53 {
54
55    /** Description of the Field */
56
57    protected Hashtable JavaDoc domains = new Hashtable JavaDoc();
58
59    /** Description of the Field */
60
61    protected Hashtable JavaDoc resources = new Hashtable JavaDoc();
62
63    /** Description of the Field */
64
65    protected CacheService service = null;
66
67
68
69
70
71    /** Constructor for the ConnectionServiceProvider object */
72
73    public CacheServiceProvider()
74
75    {
76
77       service = this;
78
79    }
80
81
82
83
84
85    /**
86
87     * Adds a feature to the Entity attribute of the CacheServiceProvider object
88
89     *
90
91     * @param type Description of the Parameter
92
93     * @param key Description of the Parameter
94
95     * @param value Description of the Parameter
96
97     */

98
99    public void add(int type, Object JavaDoc key, Object JavaDoc value)
100
101    {
102
103       this.getTable(type).put(key, value);
104
105 // logger.debug("Entity added " + type + ", " + key);
106

107    }
108
109
110
111
112
113    /** Description of the Method */
114
115    public void clear()
116
117    {
118
119       super.clear();
120
121       this.getTable(CacheService.DOMAIN_TYPE).clear();
122
123       this.getTable(CacheService.RESOURCE_TYPE).clear();
124
125    }
126
127
128
129
130
131    /**
132
133     * Description of the Method
134
135     *
136
137     * @param type Description of the Parameter
138
139     * @param key Description of the Parameter
140
141     * @return Description of the Return Value
142
143     */

144
145    public Object JavaDoc get(int type, Object JavaDoc key)
146
147    {
148
149       return this.getTable(type).get(key);
150
151    }
152
153
154
155
156
157    /**
158
159     * Getter for the currentServiceSelectors attribute
160
161     *
162
163     * @param bcs Description of the Parameter
164
165     * @param serviceClass Description of the Parameter
166
167     * @return The value
168
169     */

170
171    public Iterator JavaDoc getCurrentServiceSelectors(BeanContextServices JavaDoc bcs, java.lang.Class JavaDoc serviceClass)
172
173    {
174
175       return (new Vector JavaDoc()).iterator();
176
177    }
178
179
180
181
182
183    /**
184
185     * Getter for the service attribute
186
187     *
188
189     * @param bcs Description of the Parameter
190
191     * @param requestor Description of the Parameter
192
193     * @param serviceClass Description of the Parameter
194
195     * @param serviceSelector Description of the Parameter
196
197     * @return The value
198
199     */

200
201    public Object JavaDoc getService(BeanContextServices JavaDoc bcs, java.lang.Object JavaDoc requestor, java.lang.Class JavaDoc serviceClass, java.lang.Object JavaDoc serviceSelector)
202
203    {
204
205       return this.service;
206
207    }
208
209
210
211
212
213    /**
214
215     * Description of the Method
216
217     *
218
219     * @param type Description of the Parameter
220
221     * @return Description of the Return Value
222
223     */

224
225    public Enumeration JavaDoc keys(int type)
226
227    {
228
229       return this.getTable(type).keys();
230
231    }
232
233
234
235
236
237    /**
238
239     * Description of the Method
240
241     *
242
243     * @param bcs Description of the Parameter
244
245     * @param requestor Description of the Parameter
246
247     * @param service Description of the Parameter
248
249     */

250
251    public void releaseService(BeanContextServices JavaDoc bcs, java.lang.Object JavaDoc requestor, java.lang.Object JavaDoc service) { }
252
253
254
255
256
257    /**
258
259     * Description of the Method
260
261     *
262
263     * @param type Description of the Parameter
264
265     * @param key Description of the Parameter
266
267     */

268
269    public void remove(int type, Object JavaDoc key)
270
271    {
272
273       this.getTable(type).remove(key);
274
275 // logger.debug("Entity removed " + type + ", " + key);
276

277    }
278
279
280
281
282
283    /**
284
285     * @return The serviceClass value
286
287     */

288
289    protected Class JavaDoc[] getServiceClass()
290
291    {
292
293       return new Class JavaDoc[]{CacheService.class};
294
295    }
296
297
298
299
300
301    /**
302
303     * Gets the table attribute of the CacheServiceProvider object
304
305     *
306
307     * @param type Description of the Parameter
308
309     * @return The table value
310
311     */

312
313    protected Hashtable JavaDoc getTable(int type)
314
315    {
316
317       if (type == CacheService.DOMAIN_TYPE)
318
319       {
320
321          return this.domains;
322
323       }
324
325       return this.resources;
326
327    }
328
329 }
330
331
Popular Tags