Update of /var/cvs/src/org/mmbase/cache In directory james.mmbase.org:/tmp/cvs-serv19180
Modified Files: CacheManager.java CacheManagerMBean.java Log Message: Implemented a few other MBean operation which may come in handy See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/cache Index: CacheManager.java =================================================================== RCS file: /var/cvs/src/org/mmbase/cache/CacheManager.java,v retrieving revision 1.42 retrieving revision 1.43 diff -u -b -r1.42 -r1.43 --- CacheManager.java 14 Nov 2008 16:09:24 -0000 1.42 +++ CacheManager.java 14 Nov 2008 16:21:47 -0000 1.43 @@ -32,7 +32,7 @@ * static any more. * * @since MMBase-1.8 - * @version $Id: CacheManager.java,v 1.42 2008/11/14 16:09:24 michiel Exp $ + * @version $Id: CacheManager.java,v 1.43 2008/11/14 16:21:47 michiel Exp $ */ public class CacheManager implements CacheManagerMBean { @@ -415,6 +415,58 @@ if (buf.length() == 0) buf.append("The regular expression '" + pattern + "' matched no cache at all"); return buf.toString(); } + /** + * @since MMBase-1.9.1 + */ + public String enable(String pattern) { + if (pattern == null) pattern = ".*"; + StringBuilder buf = new StringBuilder(); + Pattern p = Pattern.compile(pattern); + for (Map.Entry<String, Cache<?, ?>> entry : caches.entrySet()) { + if (p.matcher(entry.getKey()).matches()) { + Cache c = entry.getValue(); + if(c.isActive()) { + buf.append("Already active " + c + "\n"); + } else { + c.setActive(true); + buf.append("Making active " + c + "\n"); + } + + } + } + if (buf.length() == 0) buf.append("The regular expression '" + pattern + "' matched no cache at all"); + return buf.toString(); + } + /** + * @since MMBase-1.9.1 + */ + public String disable(String pattern) { + if (pattern == null) pattern = ".*"; + StringBuilder buf = new StringBuilder(); + Pattern p = Pattern.compile(pattern); + for (Map.Entry<String, Cache<?, ?>> entry : caches.entrySet()) { + if (p.matcher(entry.getKey()).matches()) { + Cache c = entry.getValue(); + if(c.isActive()) { + c.setActive(false); + buf.append("Making inactive " + c + "\n"); + } else { + buf.append("Already inactive " + c + "\n"); + } + + } + } + if (buf.length() == 0) buf.append("The regular expression '" + pattern + "' matched no cache at all"); + return buf.toString(); + } + /** + * @since MMBase-1.9.1 + */ + public String readConfiguration() { + configWatcher.onChange("caches.xml"); + return "Read " + ResourceLoader.getConfigurationRoot().getResource("caches.xml"); + } + public static class Bean<K, V> implements Comparable<Bean<?, ?>> { /* private final Cache<K, V> cache; // this line prevents building in Java 1.5.0_07 probably because of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4916620 */ Index: CacheManagerMBean.java =================================================================== RCS file: /var/cvs/src/org/mmbase/cache/CacheManagerMBean.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- CacheManagerMBean.java 14 Nov 2008 16:09:24 -0000 1.1 +++ CacheManagerMBean.java 14 Nov 2008 16:21:47 -0000 1.2 @@ -15,10 +15,13 @@ /** * See http://java.sun.com/docs/books/tutorial/jmx/mbeans/standard.html * @author Michiel Meeuwissen - * @version $Id: CacheManagerMBean.java,v 1.1 2008/11/14 16:09:24 michiel Exp $ + * @version $Id: CacheManagerMBean.java,v 1.2 2008/11/14 16:21:47 michiel Exp $ * @since MMBase-1.9.1 */ public interface CacheManagerMBean { String clear(String regex); + String disable(String regex); + String enable(String regex); + String readConfiguration(); } _______________________________________________ Cvs mailing list Cvs@lists.mmbase.org http://lists.mmbase.org/mailman/listinfo/cvs