001: /**
002: * Copyright (C) 2001-2005 France Telecom R&D
003: */package org.objectweb.speedo.jmx.mbeans;
004:
005: import org.objectweb.perseus.cache.api.CacheAttributeController;
006: import org.objectweb.perseus.cache.api.CacheException;
007: import org.objectweb.perseus.cache.api.CacheManager;
008: import org.objectweb.perseus.cache.api.UnbindManager;
009: import org.objectweb.speedo.mapper.api.JormFactory;
010: import org.objectweb.speedo.pm.api.POManagerFactoryItf;
011: import org.objectweb.speedo.pm.jdo.api.JDOPOManagerFactoryItf;
012:
013: import java.util.Collection;
014:
015: /**
016: *
017: *
018: * @author chassase
019: */
020: public class Cache implements CacheMBean {
021:
022: JDOPOManagerFactoryItf pmf;
023: JormFactory jf;
024: CacheAttributeController ca;
025: UnbindManager um;
026: CacheManager cm;
027:
028: public Cache(CacheAttributeController ca, UnbindManager um,
029: CacheManager cm, JDOPOManagerFactoryItf pmf, JormFactory jf) {
030: this .ca = ca;
031: this .um = um;
032: this .cm = cm;
033: this .pmf = pmf;
034: this .jf = jf;
035: }
036:
037: public String getCache_AutoCleanSize() {
038: return ca.getAutoCleanSize();
039: }
040:
041: public String getCache_AutoCleanThreshold() {
042: return ca.getAutoCleanThreshold();
043: }
044:
045: public Collection getCache_ObjectIdentifiers() {
046: return ca.getCurrentEntryIdentifiers();
047: }
048:
049: public int getCache_CurrentSize() {
050: return ca.getCurrentSize();
051: }
052:
053: public int getCache_MaxObjects() {
054: return ca.getMaxObjects();
055: }
056:
057: public void setCache_AutoCleanSize(String size) {
058: ca.setAutoCleanSize(size);
059: }
060:
061: public void setCache_AutoCleanThreshold(String size) {
062: ca.setAutoCleanThreshold(size);
063: }
064:
065: public void setCache_MaxObjects(int size)
066: throws IllegalArgumentException, CacheException {
067: ca.setMaxObjects(size);
068: }
069:
070: public void evictAll(String classname, boolean subclass) {
071: ClassLoader cl = jf.getClassLoader(classname);
072: if (cl != null) {
073: try {
074: pmf.getDataStoreCache().evictAll(
075: cl.loadClass(classname), subclass);
076: } catch (ClassNotFoundException e) {
077: }
078: }
079: }
080:
081: public void evictAll() {
082: pmf.getDataStoreCache().evictAll();
083: }
084:
085: public void pinAll(String classname, boolean subclass) {
086: ClassLoader cl = jf.getClassLoader(classname);
087: if (cl != null) {
088: try {
089: pmf.getDataStoreCache().pinAll(cl.loadClass(classname),
090: subclass);
091: } catch (ClassNotFoundException e) {
092: }
093: }
094: }
095:
096: public void unpinAll(String classname, boolean subclass) {
097: ClassLoader cl = jf.getClassLoader(classname);
098: if (cl != null) {
099: try {
100: pmf.getDataStoreCache().unpinAll(
101: cl.loadClass(classname), subclass);
102: } catch (ClassNotFoundException e) {
103: }
104: }
105: }
106: }
|