[jboss-cvs] JBossAS SVN: r88788 - in projects/microcontainer/trunk: aop-mc-int/src/main/java/org/jboss/aop/microcontainer and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 13 04:52:04 EDT 2009


Author: alesj
Date: 2009-05-13 04:52:04 -0400 (Wed, 13 May 2009)
New Revision: 88788

Added:
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/DisableAOPHelper.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.xml
Modified:
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
   projects/microcontainer/trunk/pom.xml
Log:
[JBMICROCONT-428]; add @DisableAOP
Update VFS.

Added: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/annotations/DisableAOP.java	2009-05-13 08:52:04 UTC (rev 88788)
@@ -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.aop.microcontainer.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Disable AOP check per class or instance.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+public @interface DisableAOP 
+{
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java	2009-05-13 08:34:06 UTC (rev 88787)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPConstructorJoinpoint.java	2009-05-13 08:52:04 UTC (rev 88788)
@@ -53,6 +53,7 @@
  *       there is no need for the proxy advisor.
  *
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision$
  */
 public class AOPConstructorJoinpoint extends BasicConstructorJoinPoint
@@ -89,6 +90,11 @@
    @SuppressWarnings("deprecation")
    public Object dispatch() throws Throwable
    {
+      if (DisableAOPHelper.isAOPDisabled(metaData))
+      {
+         return super.dispatch();
+      }
+      
       Class<?> clazz = constructorInfo.getDeclaringClass().getType();
       AspectManager manager = AspectManagerFactory.getAspectManager(metaData);
       boolean hasInstanceMetaData = rootHasSubInstanceMetaData(metaData);

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java	2009-05-13 08:34:06 UTC (rev 88787)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java	2009-05-13 08:52:04 UTC (rev 88788)
@@ -67,6 +67,7 @@
  *
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision$
  */
 public class AOPDependencyBuilder extends AbstractDependencyBuilder
@@ -79,6 +80,11 @@
    @Override
    public List<DependencyBuilderListItem> getDependencies(BeanInfo beanInfo, MetaData metaData)
    {
+      if (DisableAOPHelper.isAOPDisabled(metaData))
+      {
+         return super.getDependencies(beanInfo, metaData);
+      }
+      
       AspectManager manager = AspectManagerFactory.getAspectManager(metaData);
       try
       {

Added: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/DisableAOPHelper.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/DisableAOPHelper.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/integration/DisableAOPHelper.java	2009-05-13 08:52:04 UTC (rev 88788)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.aop.microcontainer.integration;
+
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.aop.microcontainer.annotations.DisableAOP;
+
+/**
+ * Diable AOP helper.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public final class DisableAOPHelper
+{
+   /**
+    * Is AOP disabled for this metadata instance.
+    *
+    * @param metaData the metadata instance
+    * @return true if AOP is disabled, false otherwise
+    */
+   public static boolean isAOPDisabled(MetaData metaData)
+   {
+      return metaData != null && metaData.isAnnotationPresent(DisableAOP.class);
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.java	2009-05-13 08:52:04 UTC (rev 88788)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.microcontainer.beans.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.aop.proxy.container.AspectManaged;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.POJO;
+
+
+/**
+ * AspectWithDependencyTurnedOffAopTestCase
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectWithDependencyTurnedOffAopTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(AspectWithDependencyTurnedOffAopTestCase.class);
+   }
+
+   public AspectWithDependencyTurnedOffAopTestCase(String test)
+   {
+      super(test);
+   }
+
+   @Override
+   protected void afterSetUp() throws Exception
+   {
+      // do nothing, so we ignore validate
+   }
+
+   public void testBeanWithDependency() throws Exception
+   {
+      try
+      {
+         getControllerContext("Intercepted");
+         fail("'Intercepted' should not have been installed");
+      }
+      catch (Exception expected)
+      {
+      }
+      ControllerContext ctxIntercepted = getControllerContext("Intercepted", null);
+      ControllerContext ctxNotIntercepted = getControllerContext("NotIntercepted");
+      assertNotNull(ctxIntercepted);
+      assertNotNull(ctxNotIntercepted);
+
+      Set<DependencyItem> interceptedDependencies = new HashSet<DependencyItem>(ctxIntercepted.getDependencyInfo().getIDependOn(null));
+      Set<DependencyItem> notInterceptedDependencies = new HashSet<DependencyItem>(ctxNotIntercepted.getDependencyInfo().getIDependOn(null));
+      assertTrue(interceptedDependencies.size() > notInterceptedDependencies.size());
+
+      POJO pojoNotIntercepted = (POJO)getBean("NotIntercepted");
+      assertFalse(pojoNotIntercepted instanceof AspectManaged);
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/AspectWithDependencyTurnedOffAopTestCase.xml	2009-05-13 08:52:04 UTC (rev 88788)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop xmlns="urn:jboss:aop-beans:1.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <aspect class="org.jboss.test.microcontainer.beans.TestAspectWithDependency">
+      <property name="dependency"><inject bean="Dependency"/></property>
+   </aspect>
+
+   <bind pointcut="execution(* org.jboss.test.microcontainer.beans.POJO->*(..))">
+      <advice aspect="org.jboss.test.microcontainer.beans.TestAspectWithDependency" name="advice"/>
+   </bind>
+
+   <bean name="Intercepted" class="org.jboss.test.microcontainer.beans.POJO"/>
+   
+   <bean name="NotIntercepted" class="org.jboss.test.microcontainer.beans.POJO">
+      <annotation>@org.jboss.aop.microcontainer.annotations.DisableAOP</annotation>
+   </bean>
+   
+</aop>

Modified: projects/microcontainer/trunk/pom.xml
===================================================================
--- projects/microcontainer/trunk/pom.xml	2009-05-13 08:34:06 UTC (rev 88787)
+++ projects/microcontainer/trunk/pom.xml	2009-05-13 08:52:04 UTC (rev 88788)
@@ -38,7 +38,7 @@
     <version.jboss.logging.log4j>2.0.5.GA</version.jboss.logging.log4j>
     <version.jbossxb>2.0.1.GA</version.jbossxb>
     <version.jboss.man>2.1.0.CR8</version.jboss.man>
-    <version.jboss.vfs>2.1.1.GA</version.jboss.vfs>
+    <version.jboss.vfs>2.1.2.GA</version.jboss.vfs>
     <version.javassist>3.10.0.GA</version.javassist>
     <version.jboss.aop>2.1.0.CR3</version.jboss.aop>
     <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>




More information about the jboss-cvs-commits mailing list