1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.commons.jcs3.jcache.jmx;
20
21 import javax.cache.Cache;
22 import javax.cache.configuration.CompleteConfiguration;
23 import javax.cache.configuration.Configuration;
24 import javax.cache.management.CacheMXBean;
25
26 public class JCSCacheMXBean<K, V> implements CacheMXBean
27 {
28 private final Cache<K, V> delegate;
29
30 public JCSCacheMXBean(final Cache<K, V> delegate)
31 {
32 this.delegate = delegate;
33 }
34
35 private Configuration<K, V> config()
36 {
37 return delegate.getConfiguration(Configuration.class);
38 }
39
40 private CompleteConfiguration<K, V> completeConfig()
41 {
42 return delegate.getConfiguration(CompleteConfiguration.class);
43 }
44
45 @Override
46 public String getKeyType()
47 {
48 return config().getKeyType().getName();
49 }
50
51 @Override
52 public String getValueType()
53 {
54 return config().getValueType().getName();
55 }
56
57 @Override
58 public boolean isReadThrough()
59 {
60 try
61 {
62 return completeConfig().isReadThrough();
63 }
64 catch (final Exception e)
65 {
66 return false;
67 }
68 }
69
70 @Override
71 public boolean isWriteThrough()
72 {
73 try
74 {
75 return completeConfig().isWriteThrough();
76 }
77 catch (final Exception e)
78 {
79 return false;
80 }
81 }
82
83 @Override
84 public boolean isStoreByValue()
85 {
86 return config().isStoreByValue();
87 }
88
89 @Override
90 public boolean isStatisticsEnabled()
91 {
92 try
93 {
94 return completeConfig().isStatisticsEnabled();
95 }
96 catch (final Exception e)
97 {
98 return false;
99 }
100 }
101
102 @Override
103 public boolean isManagementEnabled()
104 {
105 try
106 {
107 return completeConfig().isManagementEnabled();
108 }
109 catch (final Exception e)
110 {
111 return false;
112 }
113 }
114 }