[jboss-cvs] JBossAS SVN: r57849 - in projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop: . src/main/org/jboss/aop src/resources/test/extender src/test/org/jboss/test/aop/extender

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 26 11:32:34 EDT 2006


Author: kabir.khan at jboss.com
Date: 2006-10-26 11:32:23 -0400 (Thu, 26 Oct 2006)
New Revision: 57849

Added:
   projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java
Modified:
   projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/build.xml
   projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/main/org/jboss/aop/Advisor.java
   projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/resources/test/extender/jboss-aop.xml
   projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java
Log:
Create patched aop 2 alpha1 for miro technologies sf 9984

Modified: projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/build.xml
===================================================================
--- projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/build.xml	2006-10-26 15:15:27 UTC (rev 57848)
+++ projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/build.xml	2006-10-26 15:32:23 UTC (rev 57849)
@@ -57,7 +57,7 @@
     -->
 
    <target name="configure" unless="configure.disable">
-      <property name="aop.version" value="jboss-aop-2.0.0.alpha1"/>
+      <property name="aop.version" value="jboss-aop-2.0.0.alpha1_SF9984"/>
       <property name="aop.title" value="JBoss AOP Framework"/>
 
       <!-- =================== -->
@@ -535,7 +535,7 @@
             <include name="src/jdk15/**/*.java"/>
             <include name="src/main/**/*.java"/>
             <include name="src/main/**/*.jjt"/>
-            <include name="src/test/**/*.java"/>         	
+            <include name="src/test/**/*.java"/>
             <include name="src/resources/test/**/*.xml"/>
             <include name="src/resources/bin/**/*"/>
             <include name="src/resources/xdoclet/META-INF/*.xml"/>

Modified: projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/main/org/jboss/aop/Advisor.java	2006-10-26 15:15:27 UTC (rev 57848)
+++ projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/main/org/jboss/aop/Advisor.java	2006-10-26 15:32:23 UTC (rev 57849)
@@ -85,7 +85,7 @@
    {
       return (MethodInfo)methodInterceptors.get(hash);
    }
-   
+
    private class AdviceInterceptorKey
    {
       private String adviceName;
@@ -150,12 +150,12 @@
    /** @deprecated Use constructorInfos instead */
    protected Interceptor[][] constructorInterceptors;
    protected ConstructorInfo[] constructorInfos; //This should replace constructorInterceptors
-   
+
    /** @deprecated Use constructorInfos instead */
    protected Interceptor[][] constructionInterceptors;
    protected ConstructionInfo[] constructionInfos;
-   
-   
+
+
    //FIXME - make metaDataContext a MetaDataContext once MC 2.0 is released
    MetaDataContext metadataContext;
 
@@ -206,7 +206,7 @@
    {
       return manager;
    }
-   
+
    /**
     * For use by generated advisors. They will explicitly set the manager
     * @param name
@@ -236,7 +236,7 @@
    {
       return methodMetaData;
    }
-   
+
    public FieldMetaData getFieldMetaData()
    {
       return fieldMetaData;
@@ -262,7 +262,7 @@
          }
       }
    }
-   
+
    public void deployAnnotationOverride(AnnotationIntroduction introduction)
    {
       if (System.getSecurityManager() == null)
@@ -307,7 +307,7 @@
    {
       manager.applyInterfaceIntroductions(this, theClass);
    }
-   
+
    protected void deployMethodAnnotationOverrides(Class theClass, AnnotationIntroduction introduction)
    {
       if (theClass.getSuperclass() != null)
@@ -337,10 +337,10 @@
          Object value = metadataContext.getAnnotation(annotation);
          if (value != null) return value;
       }
-      
+
       if (annotations.isDisabled(annotation))
          return null;
-      
+
       Object value = annotations.resolveClassAnnotation(annotation);
       if (clazz == null) return null;
       if (value == null) value = AnnotationElement.getVisibleAnnotation(clazz, annotation);
@@ -377,15 +377,15 @@
          Object val = metadataContext.getAnnotation(m, annotation);
          if (val != null) return val;
       }
-      
+
       if (annotations.isDisabled(m,annotation))
          return null;
-      
+
       Object value = annotations.resolveAnnotation(m, annotation);
       if (value == null) value = AnnotationElement.getVisibleAnnotation(m, annotation);
       return value;
    }
-   
+
    public Object resolveAnnotation(Method m, Class[] annotationChoices)
    {
       Object value = null;
@@ -393,7 +393,7 @@
       while (value == null && i < annotationChoices.length){
          value = annotations.resolveAnnotation(m, annotationChoices[i++]);
       }
-      
+
       i = 0;
       while (value == null && i < annotationChoices.length){
          value = AnnotationElement.getVisibleAnnotation(m, annotationChoices[i++]);
@@ -421,7 +421,7 @@
       {
          if (metadataContext.hasAnnotation(m, annotation)) return true;
       }
-      
+
       if (annotations.hasAnnotation(m, annotation)) return true;
       try
       {
@@ -492,7 +492,7 @@
       if (annotations.hasAnnotation(member, annotation)) return true;
       return AnnotationElement.isAnyAnnotationPresent(member, annotation);
    }
-   
+
    public MetaDataContext getMetadataContext()
    {
       return metadataContext;
@@ -512,7 +512,7 @@
    {
       return doesHaveAspects;
    }
-   
+
    public synchronized void removeAdviceBinding(AdviceBinding binding)
    {
       adviceBindings.remove(binding);
@@ -590,7 +590,7 @@
       }
       joinpoints.add(joinpoint);
    }
-  
+
    public void removePerInstanceJoinpointAspect(AspectDefinition def)
    {
       perInstanceJoinpointAspectDefinitions.remove(def);
@@ -673,7 +673,7 @@
       {
          Method method = (Method) advisedMethods.get(keys[i]);
          PointcutMethodMatch match = binding.getPointcut().matchesExecution(this, method);
-         
+
          if (match != null && match.isMatch())
          {
             adviceBindings.add(binding);
@@ -699,11 +699,11 @@
          }
       }
    }
-   
+
    protected void finalizeMethodChain(MethodInterceptors newMethodInterceptors)
    {
       TLongObjectHashMap newMethodInfos = new TLongObjectHashMap();
-      
+
       long[] keys = newMethodInterceptors.keys();
       for (int i = 0; i < keys.length; i++)
       {
@@ -712,7 +712,7 @@
 
          MethodInfo info = matchInfo.getInfo();
          newMethodInfos.put(keys[i], info);
-         
+
          ArrayList list = info.getInterceptorChain();
          Interceptor[] interceptors = null;
          if (list.size() > 0)
@@ -771,17 +771,17 @@
       {
          return name;
       }
-      
+
       return name.substring(lastIndex + 1);
    }
-   
+
    protected ArrayList initializeConstructorChain()
    {
       if (clazz != null && constructors == null)
       {
           constructors = clazz.getDeclaredConstructors();
       }
-      
+
       ArrayList newInfos = new ArrayList(constructors.length);
       for (int i = 0; i < constructors.length; i++)
       {
@@ -810,7 +810,7 @@
 
          info.setAdvisor(this);
          newInfos.add(info);
-         
+
          try
          {
             final String name = ConstructorExecutionTransformer.getConstructorInfoFieldName(getSimpleName(clazz), i);
@@ -832,7 +832,7 @@
                throw new NestedRuntimeException(e);
          }
       }
-      
+
       return newInfos;
    }
 
@@ -846,7 +846,7 @@
          info.setIndex(i);
          info.setAdvisor(this);
          newInfos.add(info);
-         
+
          try
          {
             Field infoField = clazz.getDeclaredField(ConstructionTransformer.getConstructionInfoFieldName(getSimpleName(clazz), i));
@@ -861,7 +861,7 @@
          {
             throw new RuntimeException(e);
          }
-         
+
       }
       return newInfos;
    }
@@ -912,21 +912,24 @@
       }
    }
 
-   protected void resolveConstructionPointcut(ArrayList newConstructionInfos, AdviceBinding binding)
-   {
-      for (int i = 0; i < constructors.length; i++)
-      {
-         Constructor constructor = constructors[i];
-         if (binding.getPointcut().matchesConstruction(this, constructor))
-         {
-            if (AspectManager.verbose) System.err.println(constructor + " matched binding " + binding.getName() + " " + binding.getPointcut().getExpr());
-            adviceBindings.add(binding);
-            binding.addAdvisor(this);
-            ConstructionInfo info = (ConstructionInfo) newConstructionInfos.get(i);
-            pointcutResolved(info, binding, new ConstructorJoinpoint(constructor));
-         }
-      }
-   }
+	protected void resolveConstructionPointcut(ArrayList newConstructionInfos, AdviceBinding binding)
+	{
+		if (newConstructionInfos.size() > 0)
+		{
+			for (Iterator it = newConstructionInfos.iterator() ; it.hasNext() ; )
+			{
+				ConstructionInfo info = (ConstructionInfo)it.next();
+				Constructor constructor = info.getConstructor();
+				if (binding.getPointcut().matchesConstruction(this, constructor))
+				{
+					if (AspectManager.verbose) System.err.println(constructor + " matched binding " + binding.getName() + " " + binding.getPointcut().getExpr());
+					adviceBindings.add(binding);
+					binding.addAdvisor(this);
+					pointcutResolved(info, binding, new ConstructorJoinpoint(constructor));
+				}
+			}
+		}
+	}
 
    /** @deprecated We should just be using xxxxInfos */
    protected void populateInterceptorsFromInfos()
@@ -937,7 +940,7 @@
          constructorInterceptors[i] = constructorInfos[i].getInterceptors();
       }
    }
- 
+
    /**
     * Default implementation adds interceptorChain directly to the info.
     * GeneratedClassAdvisor overrides this
@@ -957,12 +960,12 @@
          createInterceptorChain(binding.getInterceptorFactories(), curr, joinpoint);
       }
    }
-  
+
    Interceptor[] applyPrecedence(Interceptor[] interceptors)
    {
       return PrecedenceSorter.applyPrecedence(interceptors, manager);
    }
-   
+
    /**
     * Whether the type of advisor supports matching on pointcut expression, where the method is defined in a superclass only,
     * while the pointcut expression class matches the subclass. This is currently only supported for generated advisors, due to
@@ -971,7 +974,7 @@
     * public class Super {<BR/>
     * &nbsp;&nbsp;void method(){}<BR/>
     * }<BR/>
-    * <BR/>    
+    * <BR/>
     * public class Sub etxends Super {<BR/>
     * }<BR/>
     * </code>
@@ -986,17 +989,17 @@
     * </code><BR/>
     * Super.method() will be intercepted by A only<BR/>
     * Sub.method() will be intercepted by A and B
-    *  
+    *
     */
    public boolean chainOverridingForInheritedMethods()
    {
       return false;
    }
-   
+
    interface DeployAnnotationOverrideAction
    {
       void deploy(Advisor advisor, AnnotationIntroduction introduction);
-      
+
       DeployAnnotationOverrideAction PRIVILEGED = new DeployAnnotationOverrideAction()
       {
          public void deploy(final Advisor advisor, final AnnotationIntroduction introduction)
@@ -1015,8 +1018,8 @@
             catch (PrivilegedActionException e)
             {
                Exception ex = e.getException();
-               if (ex instanceof RuntimeException) 
-               { 
+               if (ex instanceof RuntimeException)
+               {
                   throw (RuntimeException)ex;
                }
                throw new RuntimeException(ex);

Modified: projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/resources/test/extender/jboss-aop.xml
===================================================================
--- projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/resources/test/extender/jboss-aop.xml	2006-10-26 15:15:27 UTC (rev 57848)
+++ projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/resources/test/extender/jboss-aop.xml	2006-10-26 15:32:23 UTC (rev 57849)
@@ -2,33 +2,40 @@
 
 <!DOCTYPE aop PUBLIC
    "-//JBoss//DTD JBOSS AOP 1.0//EN"
-   "http://www.jboss.org/aop/dtd/jboss-aop_1_0.dtd">
+   "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd">
 
 <aop>
 
 	<aspect class="org.jboss.test.aop.extender.SuperCallAspect"/>
+	<interceptor class="org.jboss.test.aop.extender.ConstructionInterceptor"/>
    <prepare expr="all(org.jboss.test.aop.extender.Base)"/>
    <prepare expr="all(org.jboss.test.aop.extender.Extender)"/>
    <bind pointcut="execution(* org.jboss.test.aop.extender.ChildBase->updateBase())">
       <interceptor class="org.jboss.test.aop.extender.ExtenderInterceptor"/>
    </bind>
-   
+
    <bind pointcut="execution(* org.jboss.test.aop.extender.Base->setBase(..))">
       <interceptor class="org.jboss.test.aop.extender.ExtenderInterceptor"/>
    </bind>
-   
+
    <bind pointcut="execution(* org.jboss.test.aop.extender.ChildExtender->*(..))">
       <interceptor class="org.jboss.test.aop.extender.ExtenderInterceptor"/>
    </bind>
-   
+
    <bind pointcut="execution(* org.jboss.test.aop.extender.InfantBase->*(..))">
       <interceptor class="org.jboss.test.aop.extender.ExtenderInterceptor"/>
    </bind>
-   
+
    <bind pointcut="execution(* $instanceof{org.jboss.test.aop.extender.Base}->superCall())">
    	<advice aspect="org.jboss.test.aop.extender.SuperCallAspect" name="invoke"/>
    </bind>
    <bind pointcut="execution(* org.jboss.test.aop.extender.Base->superCall())">
    	<advice aspect="org.jboss.test.aop.extender.SuperCallAspect" name="invoke"/>
    </bind>
+   <bind pointcut="construction(org.jboss.test.aop.extender.Base->new())">
+   	<interceptor-ref name="org.jboss.test.aop.extender.ConstructionInterceptor"/>
+   </bind>
+   <bind pointcut="construction(org.jboss.test.aop.extender.SubBase->new())">
+   	<interceptor-ref name="org.jboss.test.aop.extender.ConstructionInterceptor"/>
+   </bind>
 </aop>

Added: projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java
===================================================================
--- projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java	2006-10-26 15:15:27 UTC (rev 57848)
+++ projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java	2006-10-26 15:32:23 UTC (rev 57849)
@@ -0,0 +1,54 @@
+/*
+* 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.extender;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.ConstructionInvocation;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConstructionInterceptor implements Interceptor
+{
+   public static ArrayList interceptions = new ArrayList();
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      ConstructionInvocation ci = (ConstructionInvocation)invocation;
+      Constructor ctor = ci.getConstructor();
+      Class clazz = ctor.getDeclaringClass();
+      interceptions.add(clazz);
+      
+      return ci.invokeNext();
+   }
+
+}

Modified: projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java
===================================================================
--- projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java	2006-10-26 15:15:27 UTC (rev 57848)
+++ projects/aop/branches/JBoss_AOP_2_0_0_alpha1_sf9984/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java	2006-10-26 15:32:23 UTC (rev 57849)
@@ -83,4 +83,13 @@
       assertEquals(Base.class, SuperCallAspect.methodClasses.get(1));
       assertEquals(Base.class, SuperCallAspect.methodClasses.get(2));
    }
+   
+   public void testConstruction() throws Exception
+   {
+      ConstructionInterceptor.interceptions.clear();
+      SubBase child = new SubBase();
+      assertEquals(2, ConstructionInterceptor.interceptions.size());
+      assertEquals(Base.class, ConstructionInterceptor.interceptions.get(0));
+      assertEquals(SubBase.class, ConstructionInterceptor.interceptions.get(1));
+   }
 }




More information about the jboss-cvs-commits mailing list