KickJava   Java API By Example, From Geeks To Geeks.

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


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

7 package org.ejtools.management.browser.model.service;
8
9 import java.beans.beancontext.BeanContextServices JavaDoc;
10 import java.util.Enumeration JavaDoc;
11 import java.util.Hashtable JavaDoc;
12 import java.util.Iterator JavaDoc;
13 import java.util.Vector JavaDoc;
14
15 import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider;
16
17 /**
18  * Description of the Class
19  *
20  * @author Laurent Etiemble
21  * @version $Revision: 1.6 $
22  * @todo Javadoc to complete
23  * @todo Service release to complete
24  */

25 public class CacheServiceProvider extends CustomBeanContextServiceProvider implements CacheService
26 {
27    /** Description of the Field */
28    protected Hashtable JavaDoc domains = new Hashtable JavaDoc();
29    /** Description of the Field */
30    protected Hashtable JavaDoc resources = new Hashtable JavaDoc();
31    /** Description of the Field */
32    protected CacheService service = null;
33
34
35    /** Constructor for the ConnectionServiceProvider object */
36    public CacheServiceProvider()
37    {
38       service = this;
39    }
40
41
42    /**
43     * Adds a feature to the Entity attribute of the CacheServiceProvider object
44     *
45     * @param type Description of the Parameter
46     * @param key Description of the Parameter
47     * @param value Description of the Parameter
48     */

49    public void add(int type, Object JavaDoc key, Object JavaDoc value)
50    {
51       this.getTable(type).put(key, value);
52 // logger.debug("Entity added " + type + ", " + key);
53
}
54
55
56    /** Description of the Method */
57    public void clear()
58    {
59       super.clear();
60       this.getTable(CacheService.DOMAIN_TYPE).clear();
61       this.getTable(CacheService.RESOURCE_TYPE).clear();
62    }
63
64
65    /**
66     * Description of the Method
67     *
68     * @param type Description of the Parameter
69     * @param key Description of the Parameter
70     * @return Description of the Return Value
71     */

72    public Object JavaDoc get(int type, Object JavaDoc key)
73    {
74       return this.getTable(type).get(key);
75    }
76
77
78    /**
79     * Getter for the currentServiceSelectors attribute
80     *
81     * @param bcs Description of the Parameter
82     * @param serviceClass Description of the Parameter
83     * @return The value
84     */

85    public Iterator JavaDoc getCurrentServiceSelectors(BeanContextServices JavaDoc bcs, java.lang.Class JavaDoc serviceClass)
86    {
87       return (new Vector JavaDoc()).iterator();
88    }
89
90
91    /**
92     * Getter for the service attribute
93     *
94     * @param bcs Description of the Parameter
95     * @param requestor Description of the Parameter
96     * @param serviceClass Description of the Parameter
97     * @param serviceSelector Description of the Parameter
98     * @return The value
99     */

100    public Object JavaDoc getService(BeanContextServices JavaDoc bcs, java.lang.Object JavaDoc requestor, java.lang.Class JavaDoc serviceClass, java.lang.Object JavaDoc serviceSelector)
101    {
102       return this.service;
103    }
104
105
106    /**
107     * Description of the Method
108     *
109     * @param type Description of the Parameter
110     * @return Description of the Return Value
111     */

112    public Enumeration JavaDoc keys(int type)
113    {
114       return this.getTable(type).keys();
115    }
116
117
118    /**
119     * Description of the Method
120     *
121     * @param bcs Description of the Parameter
122     * @param requestor Description of the Parameter
123     * @param service Description of the Parameter
124     */

125    public void releaseService(BeanContextServices JavaDoc bcs, java.lang.Object JavaDoc requestor, java.lang.Object JavaDoc service) { }
126
127
128    /**
129     * Description of the Method
130     *
131     * @param type Description of the Parameter
132     * @param key Description of the Parameter
133     */

134    public void remove(int type, Object JavaDoc key)
135    {
136       this.getTable(type).remove(key);
137 // logger.debug("Entity removed " + type + ", " + key);
138
}
139
140
141    /**
142     * @return The serviceClass value
143     */

144    protected Class JavaDoc[] getServiceClass()
145    {
146       return new Class JavaDoc[]{CacheService.class};
147    }
148
149
150    /**
151     * Gets the table attribute of the CacheServiceProvider object
152     *
153     * @param type Description of the Parameter
154     * @return The table value
155     * @paramtype Description of the Parameter
156     * @paramtype Description of the Parameter
157     * @paramtype Description of the Parameter
158     */

159    protected Hashtable JavaDoc getTable(int type)
160    {
161       if (type == CacheService.DOMAIN_TYPE)
162       {
163          return this.domains;
164       }
165       return this.resources;
166    }
167 }
168
Popular Tags