1 24 25 package org.aspectj.compiler.crosscuts; 26 27 import org.aspectj.compiler.crosscuts.ast.*; 28 import org.aspectj.compiler.crosscuts.joinpoints.*; 29 30 import org.aspectj.compiler.base.ast.*; 31 import org.aspectj.compiler.base.*; 32 import org.aspectj.util.CollectionUtil; 33 34 import java.util.*; 35 36 42 public class AdviceWeaver extends WalkerPass { 43 44 public AdviceWeaver(JavaCompiler compiler) { 45 super(compiler); 46 } 47 48 public String getDisplayName() { 49 return "weaving advice"; 50 } 51 52 protected void postProcess(ASTObject object) { 53 if (object instanceof TypeDec) weaveInto((TypeDec)object); 54 } 55 56 public void weaveInto(TypeDec typeDec) { 57 getCompiler().showMessage(" weaving into " + typeDec.toShortString()); 58 applyAspectsOf(typeDec); 59 implementPlans(typeDec.joinPoints0); 60 implementPlans(typeDec.joinPoints1); 61 implementPlans(typeDec.joinPoints2, typeDec.getInitializerExecutionJoinPoints()); 62 implementPlans(typeDec.getInitializerExecutionJoinPoints()); 63 } 64 65 void applyAspectsOf(TypeDec typeDec) { 66 getWorld().runTypeDecPlanners(typeDec, TypeDecPlanner.BODY); 67 } 68 69 void implementPlans(Collection jps) { 70 implementPlans(jps, null); 71 } 72 73 void implementPlans(Collection jps, Collection skipSet) { 74 for (Iterator i = jps.iterator(); i.hasNext(); ) { 75 JoinPoint joinPoint = (JoinPoint)i.next(); 76 if (skipSet != null && skipSet.contains(joinPoint)) continue; 77 joinPoint.implementPlans(); 78 } 79 } 80 } 81 82 | Popular Tags |