1 12 13 package org.ejtools.jmx.browser.model.service; 14 15 16 17 import java.beans.beancontext.BeanContextServices ; 18 19 import java.util.Enumeration ; 20 21 import java.util.Hashtable ; 22 23 import java.util.Iterator ; 24 25 import java.util.Vector ; 26 27 28 29 import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; 30 31 32 33 50 51 public class CacheServiceProvider extends CustomBeanContextServiceProvider implements CacheService 52 53 { 54 55 56 57 protected Hashtable domains = new Hashtable (); 58 59 60 61 protected Hashtable resources = new Hashtable (); 62 63 64 65 protected CacheService service = null; 66 67 68 69 70 71 72 73 public CacheServiceProvider() 74 75 { 76 77 service = this; 78 79 } 80 81 82 83 84 85 98 99 public void add(int type, Object key, Object value) 100 101 { 102 103 this.getTable(type).put(key, value); 104 105 107 } 108 109 110 111 112 113 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 144 145 public Object get(int type, Object key) 146 147 { 148 149 return this.getTable(type).get(key); 150 151 } 152 153 154 155 156 157 170 171 public Iterator getCurrentServiceSelectors(BeanContextServices bcs, java.lang.Class serviceClass) 172 173 { 174 175 return (new Vector ()).iterator(); 176 177 } 178 179 180 181 182 183 200 201 public Object getService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector) 202 203 { 204 205 return this.service; 206 207 } 208 209 210 211 212 213 224 225 public Enumeration keys(int type) 226 227 { 228 229 return this.getTable(type).keys(); 230 231 } 232 233 234 235 236 237 250 251 public void releaseService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Object service) { } 252 253 254 255 256 257 268 269 public void remove(int type, Object key) 270 271 { 272 273 this.getTable(type).remove(key); 274 275 277 } 278 279 280 281 282 283 288 289 protected Class [] getServiceClass() 290 291 { 292 293 return new Class []{CacheService.class}; 294 295 } 296 297 298 299 300 301 312 313 protected Hashtable 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 |