From: Kabir K. <kk...@jb...> - 2006-07-07 14:32:53
|
User: kkhan Date: 06/07/07 10:14:26 Modified: src/main/org/jboss/aop/advice GeneratedAdvisorInterceptor.java Log: [JBAOP-272] If user tries to dynamically invoke upon a method and that has Before/After/Throwing advices we can not generate an interceptor for that. Create a "null" interceptor and log a warning. Revision Changes Path 1.2 +44 -2 jboss-aop/src/main/org/jboss/aop/advice/GeneratedAdvisorInterceptor.java (In the diff below, changes in quantity of whitespace are not shown.) Index: GeneratedAdvisorInterceptor.java =================================================================== RCS file: /cvsroot/jboss/jboss-aop/src/main/org/jboss/aop/advice/GeneratedAdvisorInterceptor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- GeneratedAdvisorInterceptor.java 7 Jul 2006 13:50:39 -0000 1.1 +++ GeneratedAdvisorInterceptor.java 7 Jul 2006 14:14:26 -0000 1.2 @@ -60,7 +60,7 @@ * Old skool class advisors do not use this class * * @author <a href="kab...@jb...">Kabir Khan</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class GeneratedAdvisorInterceptor implements Interceptor { @@ -424,10 +424,17 @@ { if (lazyInterceptor == null) { + if (factory instanceof GeneratedOnly) + { + lazyInterceptor = new GeneratedOnlyInterceptor(factory.getName(), (GeneratedOnly)factory); + } + else + { lazyInterceptor = create(invocation.getAdvisor(), getJoinpoint(invocation)); } } } + } return lazyInterceptor.invoke(invocation); } @@ -469,4 +476,39 @@ throw new RuntimeException("Invocation type not handled " + invocation); } + private class GeneratedOnlyInterceptor implements Interceptor + { + String name; + String type; + + GeneratedOnlyInterceptor(String name, GeneratedOnly factory) + { + this.name = name; + + if (factory instanceof BeforeFactory) + { + type = "before"; + } + else if (factory instanceof AfterFactory) + { + type = "after"; + } + else if (factory instanceof ThrowingFactory) + { + type = "throwing"; + } + System.out.println("[warn] " + type + " interceptor:s'" + name + "' is ignored for dynamic invocation. Adding null GeneratedOnlyInterceptor in its place"); + } + + public String getName() + { + return name; + } + + public Object invoke(Invocation invocation) throws Throwable + { + return invocation.invokeNext(); + } + + } } |