01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /*
18: * Created on Oct 20, 2004
19: *
20: * TODO To change the template for this generated file go to
21: * Window - Preferences - Java - Code Generation - Code and Comments
22: */
23: package org.apache.jetspeed.cache.general;
24:
25: /**
26: * <p>
27: * InvocationCountingCache
28: * </p>
29: * <p>
30: *
31: * </p>
32: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
33: * @version $Id: InvocationCountingCache.java 516881 2007-03-11 10:34:21Z ate $
34: *
35: */
36: public class InvocationCountingCache extends SimpleHashMapCache {
37: int getCount, putCount, removeCount, successGetCount,
38: containsCount;
39:
40: public Object get(String key) {
41: getCount++;
42:
43: Object value = super .get(key);
44: if (value != null) {
45: successGetCount++;
46: }
47:
48: return value;
49: }
50:
51: public void put(String key, Object value) {
52: putCount++;
53: super .put(key, value);
54: }
55:
56: public Object remove(String key) {
57: removeCount++;
58: return super .remove(key);
59: }
60:
61: public boolean contains(String key) {
62: containsCount++;
63: return super.contains(key);
64: }
65: }
|