package aspects; class Stateful1 { hook Hook1 { Hook1(startmethod(..args1), runningmethod(..args2),stopmethod(..args3), context(..args)) { strict[execution(context)]: start>p1; p1: execution(startmethod) > p2; //p3: execution(stopmethod) > p1; p2: execution(runningmethod) > p2; } before p1(){ System.out.println("executing p1: "+thisJoinPoint.getName()+" "+thisJoinPoint.getClassName()); } before p2(){ System.out.println("executing p2: "+thisJoinPoint.getName()+" "+thisJoinPoint.getClassName()); } // before p3(){ // System.out.println("executing: "+thisJoinPoint.getName()+" "+thisJoinPoint.getClassName()); // } } hook Hook2 { Hook2(m1(..args1), m2(..args2)) { strict: start>p1; p1: execution(m1) > p2; p2: execution(m2) > p2; } before p1(){ System.out.println("executing p1: "+thisJoinPoint.getName()+" "+thisJoinPoint.getClassName()); } before p2(){ System.out.println("executing p2: "+thisJoinPoint.getName()+" "+thisJoinPoint.getClassName()); } } }