1 8 package test.aspect; 9 10 import test.StaticMethodAdviceTest; 11 import org.codehaus.aspectwerkz.definition.Pointcut; 12 import org.codehaus.aspectwerkz.definition.Pointcut; 13 import org.codehaus.aspectwerkz.joinpoint.JoinPoint; 14 import org.codehaus.aspectwerkz.joinpoint.MethodRtti; 15 import org.codehaus.aspectwerkz.joinpoint.Rtti; 16 17 21 public class StaticMethodTestAspect { 22 24 27 Pointcut static_pc1; 28 29 32 Pointcut static_pc2; 33 34 37 Pointcut static_pc4; 38 39 42 Pointcut static_pc5; 43 44 47 Pointcut static_pc6; 48 49 52 Pointcut static_pc7; 53 54 57 Pointcut static_pc8; 58 59 62 Pointcut static_pc9; 63 64 67 Pointcut static_pc10; 68 69 72 Pointcut static_pc11; 73 74 77 Pointcut static_pc12; 78 79 82 Pointcut static_pc13; 83 84 86 89 public void before(final JoinPoint joinPoint) throws Throwable { 90 } 91 92 95 public void afterFinally(final JoinPoint joinPoint) throws Throwable { 96 } 97 98 101 public Object advice1(final JoinPoint joinPoint) throws Throwable { 102 return joinPoint.proceed(); 103 } 104 105 108 public Object advice2(final JoinPoint joinPoint) throws Throwable { 109 StaticMethodAdviceTest.log("before1 "); 110 final Object result = joinPoint.proceed(); 111 StaticMethodAdviceTest.log("after1 "); 112 return result; 113 } 114 115 118 public Object advice3(final JoinPoint joinPoint) throws Throwable { 119 StaticMethodAdviceTest.log("before2 "); 120 final Object result = joinPoint.proceed(); 121 StaticMethodAdviceTest.log("after2 "); 122 return result; 123 } 124 125 128 public Object advice4(final JoinPoint joinPoint) throws Throwable { 129 final Object result = joinPoint.proceed(); 130 MethodRtti mrtti = (MethodRtti) joinPoint.getRtti(); 131 String metadata = joinPoint.getCalleeClass().getName() 132 + mrtti.getMethod().getName() 133 + mrtti.getParameterValues()[0] 134 + mrtti.getParameterTypes()[0].getName() 135 + mrtti.getReturnType().getName() 136 + mrtti.getReturnValue(); 137 return metadata; 138 } 139 140 143 public Object advice5(final JoinPoint joinPoint) throws Throwable { 144 StaticMethodAdviceTest.log("before "); 145 final Object result = joinPoint.proceed(); 146 StaticMethodAdviceTest.log("after "); 147 return result; 148 } 149 150 153 public Object advice7(final JoinPoint joinPoint) throws Throwable { 154 return null; 155 } 156 } | Popular Tags |