1 8 package test.rtti; 9 10 import org.codehaus.aspectwerkz.joinpoint.JoinPoint; 11 import org.codehaus.aspectwerkz.joinpoint.MethodRtti; 12 import org.codehaus.aspectwerkz.joinpoint.Rtti; 13 14 17 public class RttiTarget { 18 19 public static StringBuffer LOG = new StringBuffer (); 20 21 private static int COUNT = 0; 22 23 private static boolean NESTED = false; 24 25 private final int m_id = ++COUNT; 26 27 public void doSomething(int i) { 28 LOG.append(toString()).append(".").append(i).append(" "); 29 if (!NESTED) { 30 NESTED = true; 31 RttiTarget nested = new RttiTarget(); 32 nested.doSomething(i + 1); 33 } 34 } 35 36 public String toString() { 37 return "Target-" + m_id; 38 } 39 40 43 public static class TestAspect { 44 45 48 public static RttiTarget ASPECT_Rtti_TARGET_EXECUTING_INSTANCE; 49 50 55 57 63 public Object around(JoinPoint jp) throws Throwable { 64 Object target = jp.getTarget(); 65 int arg0 = ((Integer ) (((MethodRtti) jp.getRtti()).getParameterValues()[0])).intValue(); 66 LOG.append("+").append(target.toString()).append(".").append(arg0).append(" "); 67 68 Object ret = jp.proceed(); 69 70 Object targetAfter = jp.getTarget(); 71 int arg0After = ((Integer ) (((MethodRtti) jp.getRtti()).getParameterValues()[0])).intValue(); 72 LOG.append("-").append(targetAfter.toString()).append(".").append(arg0After).append(" "); 73 74 return ret; 75 } 76 } 77 78 } 79 80 | Popular Tags |