1 package org.apache.commons.jcs.engine.control;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.jcs.auxiliary.AuxiliaryCache;
23 import org.apache.commons.jcs.engine.CompositeCacheAttributes;
24 import org.apache.commons.jcs.engine.ElementAttributes;
25 import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
26 import org.apache.commons.jcs.engine.behavior.IShutdownObserver;
27
28 import java.util.Properties;
29
30
31 public class MockCompositeCacheManager
32 implements ICompositeCacheManager
33 {
34
35 private CompositeCache<?, ?> cache;
36
37
38 private Properties configurationProperties;
39
40
41
42
43
44 @Override
45 @SuppressWarnings("unchecked")
46 public <K, V> CompositeCache<K, V> getCache( String cacheName )
47 {
48 if ( cache == null )
49 {
50
51 CompositeCache<K, V> newCache =
52 new CompositeCache<K, V>( new CompositeCacheAttributes(), new ElementAttributes() );
53 this.setCache( newCache );
54 }
55
56 return (CompositeCache<K, V>)cache;
57 }
58
59 @Override
60 public <K, V> AuxiliaryCache<K, V> getAuxiliaryCache(String auxName, String cacheName)
61 {
62 return null;
63 }
64
65
66
67
68 public void setCache( CompositeCache<?, ?> cache )
69 {
70 this.cache = cache;
71 }
72
73
74
75
76 public CompositeCache<?, ?> getCache()
77 {
78 return cache;
79 }
80
81
82
83
84
85
86 public void setConfigurationProperties( Properties props )
87 {
88 this.configurationProperties = props;
89 }
90
91
92
93
94
95
96 @Override
97 public Properties getConfigurationProperties()
98 {
99 return configurationProperties;
100 }
101
102
103 @Override
104 public String getStats()
105 {
106 return "Mock";
107 }
108
109
110
111
112 @Override
113 public void registerShutdownObserver(IShutdownObserver observer)
114 {
115
116 }
117
118
119
120
121 @Override
122 public void deregisterShutdownObserver(IShutdownObserver observer)
123 {
124
125 }
126 }