01: package org.shiftone.cache.decorator.stat;
02:
03: import org.shiftone.cache.Cache;
04: import org.shiftone.cache.util.AbstractDecoratorCacheFactory;
05:
06: /**
07: * @version $Revision: 1.7 $
08: * @author <a href="mailto:jeff@shiftone.org">Jeff Drost</a>
09: */
10: public class StatCacheFactory extends AbstractDecoratorCacheFactory {
11:
12: private ShutdownHook shutdownHook = null;
13:
14: private synchronized ShutdownHook getShutdownHook() {
15:
16: if (shutdownHook == null) {
17: shutdownHook = new ShutdownHook();
18:
19: shutdownHook.setTitle(getDelegate().toString());
20: }
21:
22: return shutdownHook;
23: }
24:
25: protected Cache wrapDelegate(String cacheName, Cache delegateCache) {
26:
27: StatCache statCache = new StatCache(cacheName, delegateCache);
28:
29: getShutdownHook().addStatCache(statCache);
30:
31: return statCache;
32: }
33:
34: public void setMaxCaches(int maxCaches) {
35: shutdownHook.setMaxCaches(maxCaches);
36: }
37:
38: public String toString() {
39: return "StatCacheFactory->" + getDelegate();
40: }
41: }
|