1
2
3 package org.virtualmock.aspect.aspectwerkz;
4
5 import org.codehaus.aspectwerkz.joinpoint.MethodJoinPoint;
6 import org.codehaus.aspectwerkz.joinpoint.control.DefaultJoinPointController;
7 import org.virtualmock.aspect.AspectUtils;
8
9
10 /***
11 * A custom AspectWerkz JoinPointController which will exclude joinpoints which
12 * are dynamically defined at runtime.
13 *
14 * @author Chad Woolley
15 * @version $Revision: 1.9 $
16 */
17 public class DynamicExcludeJoinPointController
18 extends DefaultJoinPointController {
19 private static AspectwerkzAspectUtils aspectwerkzAspectUtils =
20 new AspectwerkzAspectUtils(new AspectUtils());
21
22 /***
23 * The overridden proceed method for the JoinPointController.
24 *
25 * @param methodJoinPoint the MethodJoinPoint
26 *
27 * @return the value which is returned from the proceed() method on thte
28 * superclass DefaultJoinPointController
29 *
30 * @throws Throwable any throwable which occurs during invocation of the
31 * original method
32 */
33 public Object proceed(final MethodJoinPoint methodJoinPoint)
34 throws Throwable {
35 Class targetClass = methodJoinPoint.getTargetClass();
36
37
38
39 if (aspectwerkzAspectUtils.isJoinPointExcluded(targetClass)) {
40
41 return methodJoinPoint.invokeOriginalMethod();
42 }
43
44 return super.proceed(methodJoinPoint);
45 }
46 }