1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.ehcache.management;
18
19 import net.sf.ehcache.CacheException;
20
21 import javax.management.ObjectName;
22 import javax.management.MalformedObjectNameException;
23 import java.io.Serializable;
24
25
26
27
28
29
30
31
32
33 public class CacheConfiguration implements CacheConfigurationMBean, Serializable {
34
35 private static final long serialVersionUID = -8944774509593267228L;
36
37 private net.sf.ehcache.config.CacheConfiguration cacheConfiguration;
38
39 private ObjectName objectName;
40
41
42
43
44
45
46 public CacheConfiguration(net.sf.ehcache.Ehcache cache) {
47 cacheConfiguration = cache.getCacheConfiguration();
48 objectName = createObjectName(cache.getCacheManager().toString(), cache.getName());
49 }
50
51
52
53
54 static ObjectName createObjectName(String cacheManagerName, String cacheName) {
55 ObjectName objectName;
56 try {
57 objectName = new ObjectName("net.sf.ehcache:type=CacheConfiguration,CacheManager="
58 + cacheManagerName + ",name=" + cacheName);
59 } catch (MalformedObjectNameException e) {
60 throw new CacheException(e);
61 }
62 return objectName;
63 }
64
65
66
67
68
69 public String getName() {
70 return cacheConfiguration.getName();
71 }
72
73
74
75
76
77 public int getMaxElementsInMemory() {
78 return cacheConfiguration.getMaxElementsInMemory();
79 }
80
81
82
83
84 public int getMaxElementsOnDisk() {
85 return cacheConfiguration.getMaxElementsOnDisk();
86 }
87
88
89
90
91
92 public String getMemoryStoreEvictionPolicy() {
93 return cacheConfiguration.getMemoryStoreEvictionPolicy().toString();
94 }
95
96
97
98
99 public boolean isEternal() {
100 return cacheConfiguration.isEternal();
101 }
102
103
104
105
106 public long getTimeToIdleSeconds() {
107 return cacheConfiguration.getTimeToIdleSeconds();
108 }
109
110
111
112
113 public long getTimeToLiveSeconds() {
114 return cacheConfiguration.getTimeToLiveSeconds();
115 }
116
117
118
119
120 public boolean isOverflowToDisk() {
121 return cacheConfiguration.isOverflowToDisk();
122 }
123
124
125
126
127 public boolean isDiskPersistent() {
128 return cacheConfiguration.isDiskPersistent();
129 }
130
131
132
133
134 public int getDiskSpoolBufferSizeMB() {
135 return cacheConfiguration.getDiskSpoolBufferSizeMB();
136 }
137
138
139
140
141 public long getDiskExpiryThreadIntervalSeconds() {
142 return cacheConfiguration.getDiskExpiryThreadIntervalSeconds();
143 }
144
145
146
147
148
149 ObjectName getObjectName() {
150 return objectName;
151 }
152 }