[jboss-cvs] JBossAS SVN: r60662 - in projects/aop/trunk/aop/src: test/org/jboss/test/aop/proxy and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Feb 19 05:38:50 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-19 05:38:50 -0500 (Mon, 19 Feb 2007)
New Revision: 60662

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithFinalMethods.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/EchoInterceptor.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyTestCase.java
Log:
[JBAOP-361] AOPContainerProxy failed on final methods

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java	2007-02-19 09:41:19 UTC (rev 60661)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerProxyFactory.java	2007-02-19 10:38:50 UTC (rev 60662)
@@ -609,7 +609,7 @@
       {
          Map.Entry entry = (Map.Entry) it.next();
          CtMethod m = (CtMethod) entry.getValue();
-         if (!Modifier.isPublic(m.getModifiers()) || Modifier.isStatic(m.getModifiers())) continue;
+         if (!Modifier.isPublic(m.getModifiers()) || Modifier.isStatic(m.getModifiers()) || Modifier.isFinal(m.getModifiers())) continue;
 
          Long hash = (Long) entry.getKey();
          if (addedMethods.contains(hash)) continue;

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/EchoInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/EchoInterceptor.java	2007-02-19 09:41:19 UTC (rev 60661)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/EchoInterceptor.java	2007-02-19 10:38:50 UTC (rev 60662)
@@ -38,6 +38,8 @@
    /** The serialVersionUID */
    private static final long serialVersionUID = 1L;
 
+   static boolean intercepted;
+   
    public String getName()
    {
       return "EchoInterceptor";
@@ -45,6 +47,7 @@
 
    public Object invoke(Invocation invocation) throws Throwable
    {
+      intercepted = true;
       MethodInvocation mi = (MethodInvocation) invocation;
       System.out.println(mi.getMethod().getName());
       return "echoed";

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithFinalMethods.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithFinalMethods.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithFinalMethods.java	2007-02-19 10:38:50 UTC (rev 60662)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.proxy;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJOWithFinalMethods
+{
+   public void method()
+   {
+      
+   }
+   
+   public final void finalMethod()
+   {
+      
+   }
+}

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyTestCase.java	2007-02-19 09:41:19 UTC (rev 60661)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyTestCase.java	2007-02-19 10:38:50 UTC (rev 60662)
@@ -213,4 +213,39 @@
       assertEquals("echoed", mi.intercepted("error"));
 
    }
+   
+   public void testContainerProxyWithFinalMethods() throws Exception
+   {
+      InstanceDomain domain = new InstanceDomain(AspectManager.instance(), "test", false);
+      AspectDefinition def = new AspectDefinition("aspect", Scope.PER_VM, new GenericAspectFactory(EchoInterceptor.class.getName(), null));
+      domain.addAspectDefinition(def);
+      AdviceFactory advice = new AdviceFactory(def, "invoke");
+      domain.addInterceptorFactory(advice.getName(), advice);
+      {
+      PointcutExpression pointcut = new PointcutExpression("pointcut", "execution(* " + POJOWithFinalMethods.class.getName() + "->*(..))");
+      domain.addPointcut(pointcut);
+      InterceptorFactory[] interceptors = {advice};
+      AdviceBinding binding = new AdviceBinding("pojo-binding", pointcut, null, null, interceptors);
+      domain.addBinding(binding);
+      }
+
+      Class proxyClass = ContainerProxyFactory.getProxyClass(POJOWithFinalMethods.class, domain);
+      ClassProxyContainer container = new ClassProxyContainer("test", domain);
+      domain.setAdvisor(container);
+      container.setClass(proxyClass);
+      container.initializeClassContainer();
+      POJOWithFinalMethods proxy = (POJOWithFinalMethods) proxyClass.newInstance();
+      AspectManaged cp = (AspectManaged)proxy;
+      cp.setAdvisor(container);
+      Delegate delegate = (Delegate)cp;
+      delegate.setDelegate(new POJOWithFinalMethods());
+      
+      EchoInterceptor.intercepted = false;
+      proxy.method();
+      assertTrue(EchoInterceptor.intercepted);
+      
+      EchoInterceptor.intercepted = false;
+      proxy.finalMethod();
+      assertFalse(EchoInterceptor.intercepted);
+   }
 }




More information about the jboss-cvs-commits mailing list