1 22 package org.jboss.aop.instrument; 23 24 import java.util.Iterator ; 25 26 import javassist.CannotCompileException; 27 import javassist.CtBehavior; 28 import javassist.CtClass; 29 import javassist.CtConstructor; 30 import javassist.CtMethod; 31 import javassist.Modifier; 32 import javassist.NotFoundException; 33 import javassist.expr.MethodCall; 34 import javassist.expr.NewExpr; 35 36 import org.jboss.aop.AspectManager; 37 import org.jboss.aop.ClassAdvisor; 38 import org.jboss.aop.instrument.CallerTransformer.ConByConDetail; 39 import org.jboss.aop.instrument.CallerTransformer.ConByMethodDetail; 40 import org.jboss.aop.instrument.CallerTransformer.ConstructorDetail; 41 import org.jboss.aop.instrument.CallerTransformer.MethodDetail; 42 import org.jboss.aop.pointcut.Pointcut; 43 44 50 public class NonOptimizedCallerTransformer extends CallerTransformer 51 { 52 public final static String PLACEHOLDER = "whatever"; 53 54 public NonOptimizedCallerTransformer(Instrumentor instrumentor, AspectManager manager) 55 { 56 super(instrumentor, manager, false, new ClassicCallerInfoAdder(instrumentor)); 57 } 58 59 protected CallerExprEditor callerExprEditorFactory(ClassAdvisor advisor, CtClass clazz) 60 { 61 return new NonOptimizedCallerExprEditor(advisor, clazz); 62 } 63 64 class NonOptimizedCallerExprEditor extends CallerExprEditor 65 { 66 67 public NonOptimizedCallerExprEditor(ClassAdvisor advisor, CtClass callingClass) 68 { 69 super(advisor, callingClass); 70 } 71 72 protected void setupConstructor(ConstructorDetail cd)throws NotFoundException, CannotCompileException 73 { 74 if (callerInfos.get(cd.callerInfoField) == null) 75 { 76 String invocationClassName = PLACEHOLDER; 77 78 callerInfos.put(cd.callerInfoField, invocationClassName); 79 callerInfoAdder.addMethodByConInfoField(callingClass, cd.callerInfoField, cd.callingIndex, cd.classname, cd.calledHash); 80 } 81 } 82 83 protected void setupMethod(MethodDetail md) throws NotFoundException, CannotCompileException 84 { 85 if (callerInfos.get(md.callerInfoField) == null) 86 { 87 String invocationClassName = PLACEHOLDER; 88 89 callerInfos.put(md.callerInfoField, invocationClassName); 90 callerInfoAdder.addMethodByMethodInfoField(callingClass, md.callerInfoField, md.callingHash, md.classname, md.calledHash); 91 } 92 } 93 94 protected void setupMethod(ConByMethodDetail cd) throws NotFoundException, CannotCompileException 95 { 96 if (callerInfos.get(cd.callerInfoField) == null) 97 { 98 String invocationClassName = PLACEHOLDER; 99 100 callerInfos.put(cd.callerInfoField, invocationClassName); 101 callerInfoAdder.addConByMethodInfoField(callingClass, cd.callerInfoField, cd.callingHash, cd.classname, cd.calledHash); 102 } 103 } 104 105 protected void setupConstructor(ConByConDetail cd)throws NotFoundException, CannotCompileException 106 { 107 if (callerInfos.get(cd.callerInfoField) == null) 108 { 109 String invocationClassName = PLACEHOLDER; 110 111 callerInfos.put(cd.callerInfoField, invocationClassName); 112 callerInfoAdder.addConByConInfoField(callingClass, cd.callerInfoField, cd.callingIndex, cd.classname, cd.calledHash); 113 } 114 } 115 116 117 118 } 119 120 } 121 | Popular Tags |