1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.ehcache.statistics;
18
19 /***
20 * Just another statistics class extending from {@link LiveCacheStatisticsImpl}
21 * Only for testing as a {@link CacheUsageListener}. The following methods will
22 * not work for this class (as it depends on an internal cache) and will throw
23 * an NPE :
24 * - getCacheName()
25 * - getInMemorySize()
26 * - getOnDiskSize()
27 * - getSize()
28 *
29 * @author Abhishek Sanoujam
30 */
31 public class AnotherStatistics extends LiveCacheStatisticsImpl implements
32 CacheUsageListener {
33
34 /***
35 * Default constructor. Passes null in the super(Ehcache) constructor.
36 */
37 public AnotherStatistics() {
38 super(null);
39 }
40
41 /***
42 * {@inheritDoc}
43 *
44 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheElementEvicted()
45 */
46 public void notifyCacheElementEvicted() {
47 super.notifyElementEvicted(null, null);
48 }
49
50 /***
51 * {@inheritDoc}
52 *
53 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheElementExpired()
54 */
55 public void notifyCacheElementExpired() {
56 super.notifyElementExpired(null, null);
57 }
58
59 /***
60 * {@inheritDoc}
61 *
62 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheElementPut()
63 */
64 public void notifyCacheElementPut() {
65 super.notifyElementPut(null, null);
66 }
67
68 /***
69 * {@inheritDoc}
70 *
71 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheElementRemoved()
72 */
73 public void notifyCacheElementRemoved() {
74 super.notifyElementRemoved(null, null);
75 }
76
77 /***
78 * {@inheritDoc}
79 *
80 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheElementUpdated()
81 */
82 public void notifyCacheElementUpdated() {
83 super.notifyElementUpdated(null, null);
84 }
85
86 /***
87 * {@inheritDoc}
88 *
89 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheHitInMemory()
90 */
91 public void notifyCacheHitInMemory() {
92 super.cacheHitInMemory();
93 }
94
95 /***
96 * {@inheritDoc}
97 *
98 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheHitOffHeap()
99 */
100 public void notifyCacheHitOffHeap() {
101 super.cacheHitOffHeap();
102 }
103
104 /***
105 * {@inheritDoc}
106 *
107 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheHitOnDisk()
108 */
109 public void notifyCacheHitOnDisk() {
110 super.cacheHitOnDisk();
111 }
112
113 /***
114 * {@inheritDoc}
115 *
116 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheMissedWithExpired()
117 */
118 public void notifyCacheMissedWithExpired() {
119 super.cacheMissExpired();
120 }
121
122 /***
123 * {@inheritDoc}
124 *
125 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheMissedWithNotFound()
126 */
127 public void notifyCacheMissedWithNotFound() {
128 super.cacheMissNotFound();
129 }
130
131 /***
132 * {@inheritDoc}
133 *
134 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheMissInMemory()
135 */
136 public void notifyCacheMissInMemory() {
137 super.cacheMissInMemory();
138 }
139
140 /***
141 * {@inheritDoc}
142 *
143 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheMissOffHeap()
144 */
145 public void notifyCacheMissOffHeap() {
146 super.cacheMissOffHeap();
147 }
148
149 /***
150 * {@inheritDoc}
151 *
152 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyCacheMissOnDisk()
153 */
154 public void notifyCacheMissOnDisk() {
155 super.cacheMissOnDisk();
156 }
157
158 /***
159 * {@inheritDoc}
160 *
161 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyRemoveAll()
162 */
163 public void notifyRemoveAll() {
164 super.notifyRemoveAll(null);
165 }
166
167 /***
168 * {@inheritDoc}
169 *
170 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyStatisticsAccuracyChanged(int)
171 */
172 public void notifyStatisticsAccuracyChanged(int statisticsAccuracy) {
173 super.setStatisticsAccuracy(statisticsAccuracy);
174 }
175
176 /***
177 * {@inheritDoc}
178 *
179 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyStatisticsCleared()
180 */
181 public void notifyStatisticsCleared() {
182 super.clearStatistics();
183 }
184
185 /***
186 * {@inheritDoc}
187 *
188 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyStatisticsEnabledChanged(boolean)
189 */
190 public void notifyStatisticsEnabledChanged(boolean enableStatistics) {
191 super.setStatisticsEnabled(enableStatistics);
192 }
193
194 /***
195 * {@inheritDoc}
196 *
197 * @see net.sf.ehcache.statistics.CacheUsageListener#notifyTimeTakenForGet(long)
198 */
199 public void notifyTimeTakenForGet(long millis) {
200 super.addGetTimeMillis(millis);
201 }
202
203 /***
204 * {@inheritDoc}
205 */
206 public void notifyCacheSearch(long executeTime) {
207 throw new AssertionError();
208 }
209
210 /***
211 * {@inheritDoc}
212 */
213 public void notifyXaCommit() {
214 super.xaCommit();
215 }
216
217 /***
218 * {@inheritDoc}
219 */
220 public void notifyXaRollback() {
221 super.xaRollback();
222 }
223 }