KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > jmx > mbeans > Cache


1 /**
2  * Copyright (C) 2001-2005 France Telecom R&D
3  */

4 package org.objectweb.speedo.jmx.mbeans;
5
6 import org.objectweb.perseus.cache.api.CacheAttributeController;
7 import org.objectweb.perseus.cache.api.CacheException;
8 import org.objectweb.perseus.cache.api.CacheManager;
9 import org.objectweb.perseus.cache.api.UnbindManager;
10 import org.objectweb.speedo.mapper.api.JormFactory;
11 import org.objectweb.speedo.pm.api.ProxyManagerFactory;
12
13 import java.util.Collection JavaDoc;
14
15 /**
16  *
17  *
18  * @author chassase
19  */

20 public class Cache implements CacheMBean {
21
22     ProxyManagerFactory pmf;
23     JormFactory jf;
24     CacheAttributeController ca;
25     UnbindManager um;
26     CacheManager cm;
27     
28     
29     public Cache(CacheAttributeController ca,
30             UnbindManager um,
31             CacheManager cm,
32             ProxyManagerFactory pmf,
33             JormFactory jf) {
34         this.ca = ca;
35         this.um = um;
36         this.cm = cm;
37         this.pmf = pmf;
38         this.jf = jf;
39     }
40     public String JavaDoc getCache_AutoCleanSize() {
41         return ca.getAutoCleanSize();
42     }
43     public String JavaDoc getCache_AutoCleanThreshold() {
44         return ca.getAutoCleanThreshold();
45     }
46     public Collection JavaDoc getCache_ObjectIdentifiers() {
47         return ca.getCurrentEntryIdentifiers();
48     }
49     public int getCache_CurrentSize() {
50         return ca.getCurrentSize();
51     }
52     public int getCache_MaxObjects() {
53         return ca.getMaxObjects();
54     }
55     public void setCache_AutoCleanSize(String JavaDoc size) {
56         ca.setAutoCleanSize(size);
57     }
58     public void setCache_AutoCleanThreshold(String JavaDoc size) {
59         ca.setAutoCleanThreshold(size);
60     }
61     public void setCache_MaxObjects(int size) throws IllegalArgumentException JavaDoc,
62             CacheException {
63         ca.setMaxObjects(size);
64     }
65
66     public void evictAll(String JavaDoc classname, boolean subclass) {
67         ClassLoader JavaDoc cl = jf.getClassLoader(classname);
68         if (cl != null) {
69             try {
70                 pmf.getDataStoreCache().evictAll(cl.loadClass(classname), subclass);
71             } catch (ClassNotFoundException JavaDoc e) {
72             }
73         }
74     }
75     
76     public void evictAll() {
77         pmf.getDataStoreCache().evictAll();
78     }
79
80     public void pinAll(String JavaDoc classname, boolean subclass) {
81         ClassLoader JavaDoc cl = jf.getClassLoader(classname);
82         if (cl != null) {
83             try {
84                 pmf.getDataStoreCache().pinAll(cl.loadClass(classname), subclass);
85             } catch (ClassNotFoundException JavaDoc e) {
86             }
87         }
88     }
89     
90     public void unpinAll(String JavaDoc classname, boolean subclass) {
91         ClassLoader JavaDoc cl = jf.getClassLoader(classname);
92         if (cl != null) {
93             try {
94                 pmf.getDataStoreCache().unpinAll(cl.loadClass(classname), subclass);
95             } catch (ClassNotFoundException JavaDoc e) {
96             }
97         }
98     }
99 }
100
Popular Tags