1 22 package org.jboss.aop; 23 24 import java.lang.reflect.Method ; 25 26 import org.jboss.aop.advice.Interceptor; 27 import org.jboss.aop.joinpoint.Joinpoint; 28 import org.jboss.aop.joinpoint.MethodCalledByMethodJoinpoint; 29 import org.jboss.aop.util.MethodHashing; 30 31 36 public class MethodByMethodInfo extends CallerMethodInfo 37 { 38 private final long callingMethodHash; 39 private final Method callingMethod; 40 41 public MethodByMethodInfo(Advisor advisor, Class calledClass, Method m, long callingMethodHash, long calledMethodHash, Interceptor[] in) 42 { 43 super(advisor, calledClass, m, calledMethodHash, in, advisor.getClazz()); 44 try 45 { 46 this.callingMethodHash = callingMethodHash; 47 callingMethod = MethodHashing.findMethodByHash(getCallingClass(), callingMethodHash); 48 } 49 catch (Exception e) 50 { 51 throw new RuntimeException (e); 52 } 53 } 54 55 58 private MethodByMethodInfo(MethodByMethodInfo other) 59 { 60 super(other); 61 this.callingMethodHash = other.callingMethodHash; 62 this.callingMethod = other.callingMethod; 63 } 64 65 protected Joinpoint internalGetJoinpoint() 66 { 67 return new MethodCalledByMethodJoinpoint(callingMethod, getMethod()); 68 } 69 70 public JoinPointInfo copy() 71 { 72 return new MethodByMethodInfo(this); 73 } 74 75 public String toString() 76 { 77 StringBuffer sb = new StringBuffer ("Method called by Method"); 78 sb.append("["); 79 sb.append("calling=" + callingMethod); 80 sb.append(",called=" + getMethod()); 81 sb.append("]"); 82 return sb.toString(); 83 } 84 85 public long getCallingMethodHash() 86 { 87 return callingMethodHash; 88 } 89 90 public Method getCallingMethod() 91 { 92 return callingMethod; 93 } 94 } 95 | Popular Tags |