[jboss-cvs] JBossAS SVN: r75539 - 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
Wed Jul 9 06:26:20 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-07-09 06:26:20 -0400 (Wed, 09 Jul 2008)
New Revision: 75539

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithIntroduction.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerCache.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/GeneratedAOPProxyFactory.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyTestCase.java
Log:
[JBAOP-612] GeneratedAOPProxyFactory should return a proxy when interface introductions apply, regardless of whether any aspects apply

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerCache.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerCache.java	2008-07-09 10:24:51 UTC (rev 75538)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/ContainerCache.java	2008-07-09 10:26:20 UTC (rev 75539)
@@ -124,6 +124,11 @@
       }
       return classAdvisor.hasAspects();
    }
+   
+   public boolean hasIntroductionsForClassAdvisor()
+   {
+      return classAdvisor.getInterfaceIntroductions().size() > 0; 
+   }
 
    public boolean requiresInstanceAdvisor()
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/GeneratedAOPProxyFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/GeneratedAOPProxyFactory.java	2008-07-09 10:24:51 UTC (rev 75538)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/container/GeneratedAOPProxyFactory.java	2008-07-09 10:26:20 UTC (rev 75539)
@@ -110,7 +110,7 @@
 
             boolean hasMoreAdvicesOrIntroductionsForInstance = cache.hasMoreAdvicesOrIntroductionsForInstance();
             
-            if (!cache.hasAspects() && !hasMoreAdvicesOrIntroductionsForInstance)
+            if (!cache.hasAspects() && !cache.hasIntroductionsForClassAdvisor() && !hasMoreAdvicesOrIntroductionsForInstance)
             {
                return params.getTarget();
             }

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithIntroduction.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithIntroduction.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/POJOWithIntroduction.java	2008-07-09 10:26:20 UTC (rev 75539)
@@ -0,0 +1,32 @@
+/*
+* 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 POJOWithIntroduction
+{
+
+}

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	2008-07-09 10:24:51 UTC (rev 75538)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/proxy/ProxyTestCase.java	2008-07-09 10:26:20 UTC (rev 75539)
@@ -444,6 +444,29 @@
       }
    }
    
+   public void testProxyWithOnlyIntroductions() throws Exception
+   {
+      AspectManager manager = AspectManager.instance();
+      InterfaceIntroduction intro = new InterfaceIntroduction("intro", POJOWithIntroduction.class.getName(), new String[] {Serializable.class.getName()});
+      try
+      {
+         manager.addInterfaceIntroduction(intro);
+         
+         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+         params.setTarget(new POJOWithIntroduction());
+         
+         GeneratedAOPProxyFactory factory = new GeneratedAOPProxyFactory();
+         POJOWithIntroduction pojo = (POJOWithIntroduction)factory.createAdvisedProxy(params);
+         assertTrue(pojo instanceof AspectManaged);
+         
+         assertInstanceOf(pojo, Serializable.class);
+      }
+      finally
+      {
+         manager.removeInterfaceIntroduction(intro.getName());
+      }
+   }
+   
    private MetaData setupMetaData(Class<?> clazz, Annotation...annotations) 
    {
       MutableMetaDataRepository repository = new BasicMetaDataRepository();




More information about the jboss-cvs-commits mailing list