1 16 17 package org.springframework.aop.framework; 18 19 import java.io.Serializable ; 20 import java.lang.reflect.Method ; 21 import java.util.HashMap ; 22 23 28 public class MethodCounter implements Serializable { 29 30 31 private HashMap map = new HashMap (); 32 33 private int allCount; 34 35 protected void count(Method m) { 36 count(m.getName()); 37 } 38 39 protected void count(String methodName) { 40 Integer I = (Integer ) map.get(methodName); 41 I = (I != null) ? new Integer (I.intValue() + 1) : new Integer (1); 42 map.put(methodName, I); 43 ++allCount; 44 } 45 46 public int getCalls(String methodName) { 47 Integer I = (Integer ) map.get(methodName); 48 return (I != null) ? I.intValue() : 0; 49 } 50 51 public int getCalls() { 52 return allCount; 53 } 54 55 60 public boolean equals(Object other) { 61 if (other == null || other.getClass() != this.getClass()) { 62 return false; 63 } 64 MethodCounter mc2 = (MethodCounter) other; 65 return true; 66 } 67 68 } 69 | Popular Tags |