[jboss-cvs] JBossAS SVN: r59675 - in branches/Branch_AOP_1_5/aop: src/main/org/jboss/aop and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 16 13:17:13 EST 2007


Author: flavia.rainone at jboss.com
Date: 2007-01-16 13:15:24 -0500 (Tue, 16 Jan 2007)
New Revision: 59675

Modified:
   branches/Branch_AOP_1_5/aop/build.xml
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java
   branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java
Log:
[JBAOP-336] All calls inside constructors now have callingObject available

Modified: branches/Branch_AOP_1_5/aop/build.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/build.xml	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/build.xml	2007-01-16 18:15:24 UTC (rev 59675)
@@ -711,7 +711,7 @@
          <param name="test" value="field"/>
       </antcall>
 
-      	<antcall target="_run-bootclasspath-test" inheritRefs="true">
+      <antcall target="_run-bootclasspath-test" inheritRefs="true">
          <param name="test" value="instanceofintroduced"/>
       </antcall>
       <antcall target="_run-bootclasspath-test" inheritRefs="true">
@@ -897,6 +897,10 @@
          <param name="caller" value="precompiled-genadvisor-tests"/>
          <param name="exclude" value="**/OverrideTestCase.class"/>
       </antcall>
+      <antcall target="_run-precompiled-test" inheritRefs="true">
+         <param name="test" value="regression"/>
+         <param name="caller" value="precompiled-genadvisor-tests"/>
+      </antcall>
    </target>
 
 
@@ -1176,6 +1180,7 @@
          <test fork="yes" todir="${report.dir}" name="org.jboss.test.aop.regression.inheritedfield.InheritedFieldTestCase"/>
          <test fork="yes" todir="${report.dir}" name="org.jboss.test.aop.regression.ejbthree315.UnderscoreMethodTester"/>
          <test fork="yes" todir="${report.dir}" name="org.jboss.test.aop.regression.jbaop137.ExtenderTestCase"/>
+         <test fork="yes" todir="${report.dir}" name="org.jboss.test.aop.regression.jbaop336callnpe.CallerNPETestCase"/>
       </junit>
 
       <junit printsummary="yes" fork="yes" haltonfailure="no">

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -1757,15 +1757,15 @@
    public Object invokeConstructorCaller(int callingIndex, Object target, Object[] args, CallerMethodInfo info)
    throws Throwable
    {
-      return invokeConstructorCaller((MethodByConInfo)info, target, args);
+      return invokeConstructorCaller((MethodByConInfo)info, null, target, args);
    }
       
    
-   public Object invokeConstructorCaller(MethodByConInfo info, Object target, Object[] args)
+   public Object invokeConstructorCaller(MethodByConInfo info, Object callingObject, Object target, Object[] args)
    throws Throwable
    {
       info.initialiseInterceptors();
-      MethodCalledByConstructorInvocation invocation = new MethodCalledByConstructorInvocation(info, target, args, info.getInterceptors());
+      MethodCalledByConstructorInvocation invocation = new MethodCalledByConstructorInvocation(info, callingObject, target, args, info.getInterceptors());
       invocation.setTargetObject(target);
       return invocation.invokeNext();
    }
@@ -1776,14 +1776,14 @@
    public Object invokeConCalledByCon(int callingIndex, Object[] args, CallerConstructorInfo info)
    throws Throwable
    {
-      return invokeConCalledByCon((ConByConInfo)info, args);
+      return invokeConCalledByCon((ConByConInfo)info, null, args);
    }
    
-   public Object invokeConCalledByCon(ConByConInfo info, Object[] args)
+   public Object invokeConCalledByCon(ConByConInfo info, Object callingObject, Object[] args)
    throws Throwable
    {
       info.initialiseInterceptors();
-      ConstructorCalledByConstructorInvocation invocation = new ConstructorCalledByConstructorInvocation(info, args, info.getInterceptors());
+      ConstructorCalledByConstructorInvocation invocation = new ConstructorCalledByConstructorInvocation(info, callingObject, args, info.getInterceptors());
       return invocation.invokeNext();
    }
 

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -65,17 +65,8 @@
       {
          //TODO: Naive implementation. Ideally callers should be able to look up the aspect by target instance
          //to make sure that there is only one instance per target rather than caller
-         Object callingObject = null;
+         Object callingObject = ((CallerInvocation) invocation).getCallingObject();
 
-         if (invocation instanceof ConstructorCalledByMethodInvocation)
-         {
-            callingObject = ((ConstructorCalledByMethodInvocation)invocation).getCallingObject();
-         }
-         else if (invocation instanceof MethodCalledByMethodInvocation)
-         {
-            callingObject = ((MethodCalledByMethodInvocation)invocation).getCallingObject();
-         }
-
          if (callingObject == null) return invocation.invokeNext(); // called from static method
          
          Advised advised = (Advised) callingObject;

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -25,9 +25,7 @@
 import org.jboss.aop.Advisor;
 import org.jboss.aop.InstanceAdvisor;
 import org.jboss.aop.joinpoint.CallerInvocation;
-import org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation;
 import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
 import org.jboss.aop.proxy.container.ClassProxyContainer;
 import org.jboss.aop.proxy.container.ContainerProxyMethodInvocation;
 
@@ -58,17 +56,7 @@
       {
          //TODO: Naive implementation. Ideally callers should be able to look up the aspect by target instance
          //to make sure that there is only one instance per target rather than caller
-         Object callingObject = null;
-
-         if (invocation instanceof ConstructorCalledByMethodInvocation)
-         {
-            callingObject = ((ConstructorCalledByMethodInvocation)invocation).getCallingObject();
-         }
-         else if (invocation instanceof MethodCalledByMethodInvocation)
-         {
-            callingObject = ((MethodCalledByMethodInvocation)invocation).getCallingObject();
-         }
-
+         Object callingObject = ((CallerInvocation)invocation).getCallingObject();
          if (callingObject == null) return invocation.invokeNext(); // called from static method
          
          Advised advised = (Advised) callingObject;

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -60,9 +60,7 @@
             return PerVmAdvice.generateInterceptor(joinpoint, def.getFactory().createPerJoinpoint(advisor, joinpoint), adviceName);
          }
       }
-      else if (joinpoint instanceof ConstructorJoinpoint
-      || joinpoint instanceof ConstructorCalledByConstructorJoinpoint
-      || joinpoint instanceof MethodCalledByConstructorJoinpoint)
+      else if (joinpoint instanceof ConstructorJoinpoint)
       {
          return PerVmAdvice.generateInterceptor(joinpoint, def.getFactory().createPerJoinpoint(advisor, joinpoint), adviceName);
       }
@@ -119,17 +117,8 @@
       {
          //TODO: Naive implementation. Ideally callers should be able to look up the aspect by target instance
          //to make sure that there is only one instance per target rather than caller
-         Object callingObject = null;
+         Object callingObject = ((CallerInvocation) invocation).getCallingObject();
 
-         if (invocation instanceof ConstructorCalledByMethodInvocation)
-         {
-            callingObject = ((ConstructorCalledByMethodInvocation)invocation).getCallingObject();
-         }
-         else if (invocation instanceof MethodCalledByMethodInvocation)
-         {
-            callingObject = ((MethodCalledByMethodInvocation)invocation).getCallingObject();
-         }
-
          if (callingObject == null) return invocation.invokeNext(); // called from static method
          
          Advised advised = (Advised) callingObject;

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -58,9 +58,7 @@
             return (Interceptor) def.getFactory().createPerJoinpoint(advisor, joinpoint);
          }
       }
-      else if (joinpoint instanceof ConstructorJoinpoint
-              || joinpoint instanceof ConstructorCalledByConstructorJoinpoint
-              || joinpoint instanceof MethodCalledByConstructorJoinpoint)
+      else if (joinpoint instanceof ConstructorJoinpoint)
       {
          return (Interceptor) def.getFactory().createPerJoinpoint(advisor, joinpoint);
       }
@@ -114,17 +112,8 @@
       {
          //TODO: Naive implementation. Ideally callers should be able to look up the aspect by target instance
          //to make sure that there is only one instance per target rather than caller
-         Object callingObject = null;
+         Object callingObject = ((CallerInvocation) invocation).getCallingObject();
 
-         if (invocation instanceof ConstructorCalledByMethodInvocation)
-         {
-            callingObject = ((ConstructorCalledByMethodInvocation)invocation).getCallingObject();
-         }
-         else if (invocation instanceof MethodCalledByMethodInvocation)
-         {
-            callingObject = ((MethodCalledByMethodInvocation)invocation).getCallingObject();
-         }
-
          if (callingObject == null) return invocation.invokeNext(); // called from static method
          
          Advised advised = (Advised) callingObject;

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -382,7 +382,7 @@
          String replaced =
             methodByConInfoFromWeakReference("info", cd.callerInfoField) +
             "if (info.getInterceptors() != (org.jboss.aop.advice.Interceptor[])null) { " +
-            "$_ = ($r)aop$classAdvisor$aop.invokeConstructorCaller(info, $0, $args);" + 
+            "$_ = ($r)aop$classAdvisor$aop.invokeConstructorCaller(info, this, $0, $args);" + 
             //+ cd.callingIndex + ", $0, $args, " + cd.callerInfoField + "); " +
             "} else { " +
             "$_ = $proceed($$); " +
@@ -509,7 +509,7 @@
          String replaced =
             conByConInfoFromWeakReference("info", cd.callerInfoField) +
             "if (info.getInterceptors() != (org.jboss.aop.advice.Interceptor[])null) { " +
-            "$_ = ($r)aop$classAdvisor$aop.invokeConCalledByCon(info, $args);" +
+            "$_ = ($r)aop$classAdvisor$aop.invokeConCalledByCon(info, this, $args);" +
             //+ cd.callingIndex + ", $args, " + cd.callerInfoField + "); " +
             "} else { " +
             "$_ = $proceed($$); " +

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -130,7 +130,7 @@
    
    protected boolean hasCallingObject()
    {
-      return false; 
+      return true; 
    }
    
    protected boolean hasTargetObject()
@@ -271,7 +271,7 @@
                new CtClass[0], 
                jp);
                
-         publicConstructor.setBody("{super($1, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}");
+         publicConstructor.setBody("{super($1, null, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}");
          jp.addConstructor(publicConstructor);
       }
       
@@ -281,9 +281,10 @@
        */
       protected void addProtectedConstructor() throws CannotCompileException
       {
-         CtClass[] ctorParams = new CtClass[params.length + 1];
+         CtClass[] ctorParams = new CtClass[params.length + 2];
          ctorParams[0] = jp;
-         System.arraycopy(params, 0, ctorParams, 1, params.length);
+         ctorParams[1] = callingClass;
+         System.arraycopy(params, 0, ctorParams, 2, params.length);
          protectedConstructor = CtNewConstructor.make(
                ctorParams,
                new CtClass[0],
@@ -293,8 +294,9 @@
          StringBuffer body = new StringBuffer();
          body.append("{");
          body.append("   this($1." + INFO_FIELD + ");");
+		 body.append("   super.callingObject=$2;");
          
-         int offset = 1;
+         int offset = 2;
          for (int i = offset ; i < ctorParams.length ; i++)
          {
             body.append("   arg" + (i - offset) + " = $" + (i + 1)  + ";");
@@ -307,6 +309,14 @@
          
       }
       
+      private CtClass[] getInvokeJoinPointParameters()
+      {
+         CtClass[] invokeParams = new CtClass[params.length + 1];
+         invokeParams[0] = callingClass;
+         System.arraycopy(params, 0, invokeParams, 1, params.length);
+         return invokeParams;
+      }
+      
       /**
        * Add an empty invokeJoinpoint() method. This method will be overridden by generated subclasses,
        * when the interceptors are rebuilt
@@ -316,7 +326,7 @@
          invokeJoinpointMethod  = CtNewMethod.make(
                targetClass, 
                INVOKE_JOINPOINT, 
-               params, 
+               getInvokeJoinPointParameters(), 
                targetCtor.getExceptionTypes(), 
                null, 
                jp);
@@ -334,11 +344,9 @@
       private void addDispatchMethods() throws CannotCompileException, NotFoundException
       {
          addInvokeNextDispatchMethod();
-         
-         if (params.length > 0)
-         {
-            addInvokeJoinpointDispatchMethod();
-         }
+         // since caller is available,
+         // it is necessary to generate invoke join point dispatch method
+         addInvokeJoinpointDispatchMethod();
       }
       
       private void addInvokeNextDispatchMethod() throws CannotCompileException, NotFoundException
@@ -386,15 +394,23 @@
          CtMethod dispatch = CtNewMethod.make(
                targetClass, 
                MethodJoinPointGenerator.DISPATCH, 
-               params, 
+               getInvokeJoinPointParameters(), 
                targetCtor.getExceptionTypes(), 
                null, 
                jp);
          dispatch.setModifiers(Modifier.PROTECTED);
          
+         final int offset = 1;
+         StringBuffer parameters = new StringBuffer();
+         for (int i = 0 ; i < params.length ; i++)
+         {
+            if (i > 0)parameters.append(", ");
+            parameters.append("$" + (i + offset + 1));
+         }
+         
          String body = 
             "{" +
-            "   " + targetClass.getName() + " obj = new " + targetClass.getName() + "($$);" +
+            "   " + targetClass.getName() + " obj = new " + targetClass.getName() + "(" + parameters.toString() + ");" +
             "   setTargetObject(obj);" +
             "   return obj;" + 
             "}";

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -111,13 +111,16 @@
 
          if (hasTargetObject)
          {
-            params = new CtClass[originalLength + 1];
-            params[0] = instrumentor.forName(cd.classname); //target object
-            System.arraycopy(cd.calledMethod.getParameterTypes(), 0, params, 1, originalLength);
+            params = new CtClass[originalLength + 2];
+            params[0] = callingClass;
+            params[1] = instrumentor.forName(cd.classname); //target object
+            System.arraycopy(cd.calledMethod.getParameterTypes(), 0, params, 2, originalLength);
          }
          else
          {
-            params = cd.calledMethod.getParameterTypes();
+            params = new CtClass[originalLength + 1];
+            params[0] = callingClass;
+            System.arraycopy(cd.calledMethod.getParameterTypes(), 0, params, 1, originalLength);
          }
 
          CtMethod method = CtNewMethod.make(
@@ -133,11 +136,11 @@
 
          if (hasTargetObject)
          {
-            proceed = MethodExecutionTransformer.getAopReturnStr(cd.calledMethod) + "$1." + cd.calledMethod.getName() + "(" + getArguments(params.length, 1) +");";
+            proceed = MethodExecutionTransformer.getAopReturnStr(cd.calledMethod) + "$2." + cd.calledMethod.getName() + "(" + getArguments(params.length, 2) + ");";
          }
          else
          {
-            proceed = MethodExecutionTransformer.getAopReturnStr(cd.calledMethod) + cd.classname + "." + cd.calledMethod.getName() + "($$);";
+            proceed = MethodExecutionTransformer.getAopReturnStr(cd.calledMethod) + cd.classname + "." + cd.calledMethod.getName() + "(" + getArguments(params.length, 1) +");";
          }
 
          String infoName = MethodByConJoinPointGenerator.getInfoFieldName(cd.callingIndex, cd.classname, cd.calledHash);
@@ -406,10 +409,15 @@
 
       private void createGenAdvisorConByConMethod(ConByConDetail cd)throws CannotCompileException, NotFoundException
       {
+         final int originalLength = cd.calledConstructor.getParameterTypes().length;
+         CtClass[] params = new CtClass[originalLength + 1];
+         params[0] = callingClass;
+         System.arraycopy(cd.calledConstructor.getParameterTypes(), 0, params, 1, originalLength);
+         
          CtMethod method = CtNewMethod.make(
                cd.calledConstructor.getDeclaringClass(),
                cd.callerInfoField,
-               cd.calledConstructor.getParameterTypes(),
+               params,
                cd.calledConstructor.getExceptionTypes(),
                null,
                getGenadvisor());
@@ -425,7 +433,7 @@
             "   }" +
             "   if (" + infoName + " == null)" +
             "   { " +
-            "      return new " + cd.calledConstructor.getDeclaringClass().getName() + "($$); " +
+            "      return new " + cd.calledConstructor.getDeclaringClass().getName() + "(" + getArguments(params.length, 1) + "); " +
             "   }" +
             "   else" +
             "   {" +
@@ -451,11 +459,11 @@
          String args = null;
          if (Modifier.isStatic(cd.calledMethod.getModifiers()))
          {
-            args = (paramsLength > 0) ? "$$" : "";
+            args = "this" + ((paramsLength > 0 ) ? ", $$" : "");
          }
          else
          {
-            args = "$0" + ((paramsLength > 0) ? ", $$" : "");
+            args = "this, $0" + ((paramsLength > 0 ) ? ", $$" : "");
          }
 
          final String ret = (!cd.calledMethod.getReturnType().equals(CtClass.voidType)) ? "$_ = " : "";
@@ -555,9 +563,11 @@
       protected void replaceConCallInCon(ConByConDetail cd)throws CannotCompileException, NotFoundException
       {
          String advisor = "((" + GeneratedAdvisorInstrumentor.getAdvisorFQN(callingClass) + ")" +
-                     Instrumentor.HELPER_FIELD_NAME + ")";
+               GeneratedAdvisorInstrumentor.GET_CURRENT_ADVISOR + ")";
 
-         String replaced = "$_ = " + advisor + "." + cd.callerInfoField + "($$);";
+         final int paramsLength = cd.calledConstructor.getParameterTypes().length;
+         String args = "this" + ((paramsLength > 0) ? ", $$" : "");
+         String replaced = "$_ = " + advisor + "." + cd.callerInfoField + "(" + args + ");";
 
          try
          {

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -537,7 +537,7 @@
                cflows.append(", cflow" + asetups[i].getIndex());
             }
          }
-
+         
          code.append("      if(" + INFO_FIELD + ".getFactories() != null)");
          code.append("      {");
          code.append("         " + joinpointFqn + " jp = new " + joinpointClass.getName() + "(this, $$" + aspects.toString() + cflows.toString() + ");");
@@ -878,7 +878,7 @@
       body.append(cflowInit.toString());
       body.append("}");   
       
-      ctor.setBody(body.toString());      
+      ctor.setBody(body.toString());
    }
 
 

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -42,9 +42,9 @@
 
 public class MethodByConJoinPointGenerator extends JoinPointGenerator
 {
-   public static final String GENERATOR_PREFIX = JoinPointGenerator.GENERATOR_PREFIX + "CByM_";
-   public static final String JOINPOINT_CLASS_PREFIX = JoinPointGenerator.JOINPOINT_CLASS_PREFIX + "CByM_";
-   public static final String JOINPOINT_FIELD_PREFIX = JoinPointGenerator.JOINPOINT_FIELD_PREFIX + "CByM_";
+   public static final String GENERATOR_PREFIX = JoinPointGenerator.GENERATOR_PREFIX + "MByC_";
+   public static final String JOINPOINT_CLASS_PREFIX = JoinPointGenerator.JOINPOINT_CLASS_PREFIX + "MByC_";
+   public static final String JOINPOINT_FIELD_PREFIX = JoinPointGenerator.JOINPOINT_FIELD_PREFIX + "MByC_";
    private static final Class INVOCATION_TYPE = MethodCalledByConstructorInvocation.class;
    private static final CtClass INVOCATION_CT_TYPE;
    static
@@ -124,7 +124,7 @@
    
    protected boolean hasCallingObject()
    {
-      return false; 
+      return true; 
    }
    
    protected boolean hasTargetObject()
@@ -269,7 +269,7 @@
                new CtClass[0], 
                jp);
                
-         publicConstructor.setBody("{super($1, null, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}");
+         publicConstructor.setBody("{super($1, null, null, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}");
          jp.addConstructor(publicConstructor);
       }
       
@@ -279,13 +279,14 @@
        */
       protected void addProtectedConstructor() throws CannotCompileException
       {
-         final int offset =  hasTargetObject ? 2 : 1;
+         final int offset =  hasTargetObject ? 3 : 2;
          CtClass[] ctorParams = new CtClass[params.length + offset];
          ctorParams[0] = jp;
+         ctorParams[1] = callingClass;
          
          if (hasTargetObject)
          {
-            ctorParams[1] = targetClass;
+            ctorParams[2] = targetClass;
          }
          System.arraycopy(params, 0, ctorParams, offset, params.length);
          protectedConstructor = CtNewConstructor.make(
@@ -297,11 +298,12 @@
          StringBuffer body = new StringBuffer();
          body.append("{");
          body.append("   this($1." + INFO_FIELD + ");");
+         body.append("   super.callingObject=$2;");
          
          if (hasTargetObject)
          {
-            body.append("   super.targetObject=$2;");
-            body.append("   this.tgt=$2;");
+            body.append("   super.targetObject=$3;");
+            body.append("   this.tgt=$3;");
          }
          
          for (int i = offset ; i < ctorParams.length ; i++)
@@ -321,13 +323,16 @@
       {
          if (hasTargetObject)
          {
-            CtClass[] invokeParams = new CtClass[params.length + 1];
-            invokeParams[0] = targetClass;
-            System.arraycopy(params, 0, invokeParams, 1, params.length);
+            CtClass[] invokeParams = new CtClass[params.length + 2];
+            invokeParams[0] = callingClass;
+            invokeParams[1] = targetClass;
+            System.arraycopy(params, 0, invokeParams, 2, params.length);
             return invokeParams;
          }
-         
-         return params;
+         CtClass[] invokeParams = new CtClass[params.length + 1];
+         invokeParams[0] = callingClass;
+         System.arraycopy(params, 0, invokeParams, 1, params.length);
+         return invokeParams;
       }
       
       /**
@@ -359,10 +364,9 @@
       private void addDispatchMethods() throws CannotCompileException, NotFoundException
       {
          addInvokeNextDispatchMethod();
-         if (hasTargetObject || params.length > 0)
-         {
-            addInvokeJoinPointDispatchMethod();
-         }
+         // since caller is available,
+         // it is necessary to generate invoke join point dispatch method
+         addInvokeJoinPointDispatchMethod();
       }      
       
       private void addInvokeNextDispatchMethod() throws CannotCompileException, NotFoundException
@@ -421,7 +425,7 @@
                jp);
          dispatch.setModifiers(Modifier.PROTECTED);
          
-         final int offset = hasTargetObject ? 1 : 0;
+         final int offset = hasTargetObject ? 2 : 1;
          StringBuffer parameters = new StringBuffer();
          for (int i = 0 ; i < params.length ; i++)
          {
@@ -437,7 +441,7 @@
          }
          else
          {
-            body.append(MethodExecutionTransformer.getAopReturnStr(isVoid) + "$1." + targetMethod.getName() + "(" + parameters + ");");
+            body.append(MethodExecutionTransformer.getAopReturnStr(isVoid) + "$2." + targetMethod.getName() + "(" + parameters + ");");
          }
          
          body.append("}");

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -129,7 +129,7 @@
       + invocation.getName()
       + " wrapper = new "
       + invocation.getName()
-      + "(this.advisor, this.calling, this.method, this.targetObject, this.arguments, this.interceptors);"
+      + "(this.advisor, this.calling, this.method, this.callingObject, this.targetObject, this.arguments, this.interceptors);"
       + "   wrapper.metadata = this.metadata; "
       + "   wrapper.currentInterceptor = this.currentInterceptor; "
       + "   wrapper.instanceResolver = this.instanceResolver; "
@@ -232,7 +232,7 @@
       + invocation.getName()
       + " wrapper = new "
       + invocation.getName()
-      + "(this.advisor, this.calling, this.constructor, this.wrappingMethod, this.arguments, this.interceptors);"
+      + "(this.advisor, this.calling, this.constructor, this.wrappingMethod, this.callingObject, this.arguments, this.interceptors);"
       + "   wrapper.metadata = super.metadata; "
       + "   wrapper.currentInterceptor = super.currentInterceptor; "
       + "   wrapper.instanceResolver = super.instanceResolver; "

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -129,7 +129,7 @@
          methodByConInfoFromWeakReference("info", cd.callerInfoField) +
          "if (info.getInterceptors() != (org.jboss.aop.advice.Interceptor[])null) { " +
          invocationClassName + " invocation = new "
-         + invocationClassName + "    (info, $0, $args, info.getInterceptors());" +
+         + invocationClassName + "    (info, this, $0, $args, info.getInterceptors());" +
          typedTargetObject +
          OptimizedBehaviourInvocations.setArguments(cd.calledMethod.getParameterTypes().length) +
          "invocation.setTargetObject($0);" +
@@ -214,7 +214,7 @@
          conByConInfoFromWeakReference("info", cd.callerInfoField) +
          "if (info.getInterceptors() != (org.jboss.aop.advice.Interceptor[])null) { " +
          invocationClassName + " invocation = new " 
-         + invocationClassName + "(info, $args, info.getInterceptors());" +
+         + invocationClassName + "(info, this, $args, info.getInterceptors());" +
          OptimizedBehaviourInvocations.setArguments(cd.calledConstructor.getParameterTypes().length) +
          "$_ = ($r)invocation.invokeNext();" +
          "} else { " +

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -33,14 +33,28 @@
 {   
    private static final long serialVersionUID = -6040602776303974658L;
    
-   public CallerInvocation(Advisor advisor, Interceptor[] interceptors)
+   protected Object callingObject;
+   
+   public CallerInvocation(Advisor advisor, Object callingObject, Interceptor[] interceptors)
    {
       super(interceptors);
+      this.callingObject = callingObject;
       super.advisor = advisor;
    }
 
-   public CallerInvocation(Interceptor[] interceptors)
+   public CallerInvocation(Object callingObject, Interceptor[] interceptors)
    {
+      this.callingObject = callingObject;
       super(interceptors);
    }
+   
+   /**
+    * Returns the caller object.
+    * 
+    * @return the caller object
+    */
+   public Object getCallingObject()
+   {
+	   return this.callingObject;
+   }
 }

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -49,28 +49,28 @@
    protected Constructor constructor;
    protected Method wrappingMethod;
    
-   public ConstructorCalledByConstructorInvocation(ConByConInfo info, Object[] args, Interceptor[] interceptors)
+   public ConstructorCalledByConstructorInvocation(ConByConInfo info, Object callingObject, Object[] args, Interceptor[] interceptors)
    {
-      this(info.getAdvisor(), info.getCalling(), info.getConstructor(), info.getWrappingMethod(), args, interceptors);
+      this(info.getAdvisor(), info.getCalling(), info.getConstructor(), info.getWrappingMethod(), callingObject, args, interceptors);
    }
    
-   public ConstructorCalledByConstructorInvocation(ConByConInfo info, Interceptor[] interceptors)
+   public ConstructorCalledByConstructorInvocation(ConByConInfo info, Object callingObject, Interceptor[] interceptors)
    {
-      this(info.getAdvisor(), info.getCalling(), info.getConstructor(), info.getWrappingMethod(), null, interceptors);
+      this(info.getAdvisor(), info.getCalling(), info.getConstructor(), info.getWrappingMethod(), callingObject, null, interceptors);
    }
    
-   public ConstructorCalledByConstructorInvocation(Advisor advisor, Constructor calling, Constructor constructor, Method wrappingMethod, Object[] args, Interceptor[] interceptors)
+   public ConstructorCalledByConstructorInvocation(Advisor advisor, Constructor calling, Constructor constructor, Method wrappingMethod, Object callingObject, Object[] args, Interceptor[] interceptors)
    {
-      super(advisor, interceptors);
+      super(advisor, callingObject, interceptors);
       this.calling = calling;
       this.constructor = constructor;
       this.wrappingMethod = wrappingMethod;
       this.arguments = args;
    }
    
-   public ConstructorCalledByConstructorInvocation(Interceptor[] interceptors)
+   public ConstructorCalledByConstructorInvocation(Object callingObject, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(callingObject, interceptors);
    }
    
    public Object[] getArguments()
@@ -201,7 +201,7 @@
     */
    public Invocation copy()
    {
-      ConstructorCalledByConstructorInvocation wrapper = new ConstructorCalledByConstructorInvocation(advisor, calling, constructor, wrappingMethod, arguments, interceptors);
+      ConstructorCalledByConstructorInvocation wrapper = new ConstructorCalledByConstructorInvocation(advisor, calling, constructor, wrappingMethod, callingObject, arguments, interceptors);
       wrapper.setAdvisor(this.getAdvisor());
       wrapper.setTargetObject(this.getTargetObject());
       wrapper.currentInterceptor = this.currentInterceptor;
@@ -209,6 +209,4 @@
       wrapper.metadata = this.metadata;
       return wrapper;
    }
-
-
-}
+}
\ No newline at end of file

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -45,7 +45,7 @@
 
    public ConstructorCalledByConstructorInvocationWrapper(ConstructorCalledByConstructorInvocation wrapped, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(wrapped.callingObject, interceptors);
       this.wrapped = wrapped;
    }
 

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -50,8 +50,6 @@
    protected Constructor constructor;
    protected Method wrappingMethod; 
    
-   protected Object callingObject;
-
    public ConstructorCalledByMethodInvocation(ConByMethodInfo info, Object callingObject, Object[] args, Interceptor[] interceptors)
    {
       this(info.getAdvisor(), info.getCallingClass(), info.getCallingMethod(), info.getConstructor(), info.getWrappingMethod(), callingObject, args, interceptors);
@@ -65,18 +63,17 @@
    public ConstructorCalledByMethodInvocation(Advisor advisor, Class callingClass, 
          Method callingMethod, Constructor constructor, Method wrappingMethod, Object callingObject, Object[] args, Interceptor[] interceptors)
    {
-      super(advisor, interceptors);
+      super(advisor, callingObject, interceptors);
       this.callingClass = callingClass;
       this.callingMethod = callingMethod;
       this.constructor = constructor;
       this.wrappingMethod = wrappingMethod;
-      this.callingObject = callingObject;
       this.arguments = args;
    }
 
-   public ConstructorCalledByMethodInvocation(Interceptor[] interceptors)
+   public ConstructorCalledByMethodInvocation(Object callingObject, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(callingObject, interceptors);
    }
 
    /**
@@ -245,9 +242,4 @@
       wrapper.currentInterceptor = this.currentInterceptor;
       return wrapper;
    }
-
-   public Object getCallingObject()
-   {
-      return callingObject;
-   }
 }

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -44,7 +44,7 @@
 
    public ConstructorCalledByMethodInvocationWrapper(ConstructorCalledByMethodInvocation wrapped, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(wrapped.getCallingObject(), interceptors);
       this.wrapped = wrapped;
    }
 

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -47,28 +47,28 @@
    protected Method method;
    protected Object[] arguments = null;
 
-   public MethodCalledByConstructorInvocation(MethodByConInfo info, Object target, Object[] args, Interceptor[] interceptors)
+   public MethodCalledByConstructorInvocation(MethodByConInfo info, Object callingObject, Object target, Object[] args, Interceptor[] interceptors)
    {
-      this(info.getAdvisor(), info.getCalling(), info.getMethod(), target, args, interceptors);
+      this(info.getAdvisor(), info.getCalling(), info.getMethod(), callingObject, target, args, interceptors);
    }
 
-   public MethodCalledByConstructorInvocation(MethodByConInfo info, Object target, Interceptor[] interceptors)
+   public MethodCalledByConstructorInvocation(MethodByConInfo info, Object callingObject, Object target, Interceptor[] interceptors)
    {
-      this(info.getAdvisor(), info.getCalling(), info.getMethod(), target, null, interceptors);
+      this(info.getAdvisor(), info.getCalling(), info.getMethod(), callingObject, target, null, interceptors);
    }
    
-   public MethodCalledByConstructorInvocation(Advisor advisor, Constructor calling, Method method, Object target, Object[] args, Interceptor[] interceptors)
+   public MethodCalledByConstructorInvocation(Advisor advisor, Constructor calling, Method method, Object callingObject, Object target, Object[] args, Interceptor[] interceptors)
    {
-      super(advisor, interceptors);
+      super(advisor, callingObject, interceptors);
       this.calling = calling;
       this.method = method;
       setTargetObject(target);
       this.arguments = args;
    }
 
-   public MethodCalledByConstructorInvocation(Interceptor[] interceptors)
+   public MethodCalledByConstructorInvocation(Object callingObject, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(callingObject, interceptors);
    }
 
    /**
@@ -140,7 +140,7 @@
    public Invocation copy()
    {
       MethodCalledByConstructorInvocation wrapper = new MethodCalledByConstructorInvocation(
-            advisor, calling, method, targetObject, arguments, interceptors);
+            advisor, calling, method, callingObject, targetObject, arguments, interceptors);
       wrapper.currentInterceptor = this.currentInterceptor;
       wrapper.metadata = this.metadata;
       wrapper.instanceResolver = this.instanceResolver;
@@ -185,4 +185,4 @@
    {
       return method;
    }
-}
+}
\ No newline at end of file

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -44,7 +44,7 @@
 
    public MethodCalledByConstructorInvocationWrapper(MethodCalledByConstructorInvocation wrapped, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(wrapped.callingObject, interceptors);
       this.wrapped = wrapped;
    }
 

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -47,7 +47,6 @@
    Method method;
    
    protected Object[] arguments = null;
-   protected Object callingObject;
 
    public MethodCalledByMethodInvocation(MethodByMethodInfo info, Object callingObject, Object targetObject, Object[] arguments, Interceptor[] interceptors)
    {
@@ -62,18 +61,17 @@
    public MethodCalledByMethodInvocation(Advisor advisor, Class callingClass, 
          Method callingMethod, Method method, Object callingObject, Object targetObject, Object[] args, Interceptor[] interceptors)
    {
-      super(advisor, interceptors);
+      super(advisor, callingObject, interceptors);
       this.callingClass = callingClass;
       this.callingMethod = callingMethod;
       this.method = method;
-      this.callingObject = callingObject;
       setTargetObject(targetObject);
       this.arguments = args;
    }
    
-   public MethodCalledByMethodInvocation(Interceptor[] interceptors)
+   public MethodCalledByMethodInvocation(Object callingObject, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(callingObject, interceptors);
    }
 
    /**
@@ -193,10 +191,4 @@
    {
       return method;
    }
-
-   public Object getCallingObject()
-   {
-      return callingObject;
-   }
-
-}
+}
\ No newline at end of file

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -43,7 +43,7 @@
 
    public MethodCalledByMethodInvocationWrapper(MethodCalledByMethodInvocation wrapped, Interceptor[] interceptors)
    {
-      super(interceptors);
+      super(wrapped.callingObject, interceptors);
       this.wrapped = wrapped;
    }
 

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -1184,7 +1184,7 @@
 
                         if (info != null && info.hasAdvices())
                         {
-                           return advisor.invokeConCalledByCon(info, args);
+                           return advisor.invokeConCalledByCon(info, inv.getCallingObject(), args);
                         }
                      }
                   }
@@ -1337,7 +1337,7 @@
                         if (info != null && info.hasAdvices())
                         {
                            //return advisor.invokeConstructorCaller(index, targetObject, args, info);
-                           return advisor.invokeConstructorCaller(info, targetObject, args);
+                           return advisor.invokeConstructorCaller(info, inv.getCallingObject(), targetObject, args);
                         }
                      }
                   }

Modified: branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/regression/jboss-aop.xml	2007-01-16 18:15:24 UTC (rev 59675)
@@ -129,7 +129,12 @@
    <prepare expr="all(org.jboss.test.aop.regression.jbaop316annotationsinwrapperonly.POJO)"/>
 
    <interceptor class="org.jboss.test.aop.regression.jbaop336callnpe.LogInterceptor" scope="PER_INSTANCE"/>
+   
    <bind pointcut="call(org.jboss.test.aop.regression.jbaop336callnpe.Log->new(java.lang.String))">
    	<interceptor-ref name="org.jboss.test.aop.regression.jbaop336callnpe.LogInterceptor"/>
   	</bind>
+  	
+   <bind pointcut="call(void org.jboss.test.aop.regression.jbaop336callnpe.Log->overwriteFile(java.lang.String))">
+   	<interceptor-ref name="org.jboss.test.aop.regression.jbaop336callnpe.LogInterceptor"/>
+  	</bind>
 </aop>

Modified: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/CallerNPETestCase.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -25,7 +25,9 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
+import org.jboss.aop.Advised;
 
+
 /**
  * http://jira.jboss.com/jira/browse/JBAOP-316
  * 
@@ -51,10 +53,33 @@
       super(name);
    }
 
-   public void testCallerInterceptor()throws Exception
+   public void testConstructorCallerInterceptor1() throws Exception
    {
       POJO pojo = new POJO("XYZ");
       assertEquals("XYZ", LogInterceptor.logFile);
+      assertNotNull(((Advised) pojo)._getInstanceAdvisor());
    }
+   
+   public void testConstructorCallerInterceptor2() throws Exception
+   {
+      POJO pojo = new POJO("XYZ", "ABC");
+      assertEquals("ABC", LogInterceptor.logFile);
+      assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+   }
+   
+   public void testMethodCallerInterceptor1()
+   {
+      POJO pojo = new POJO();
+      pojo.recreateLog("UVW");
+      assertEquals("UVW", LogInterceptor.logFile);
+      assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+   }
 
-}
+   public void testMethodCallerInterceptor2()
+   {
+      POJO pojo = new POJO();
+      pojo.setLogFile("DEF");
+      assertEquals("DEF", LogInterceptor.logFile);
+      assertNotNull(((Advised) pojo)._getInstanceAdvisor());
+   }
+}
\ No newline at end of file

Modified: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/Log.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -34,4 +34,14 @@
    {
       this.logFile = logFile;
    }
+   
+   public Log()
+   {
+	   this.logFile = null;
+   }
+   
+   public void overwriteFile(String logFile)
+   {
+	   this.logFile = logFile;
+   }
 }

Modified: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/LogInterceptor.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -1,29 +1,32 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.
-*/ 
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.aop.regression.jbaop336callnpe;
 
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation;
+import org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation;
 import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodCalledByConstructorInvocation;
+import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
 
 /**
  * 
@@ -41,7 +44,23 @@
 
    public Object invoke(Invocation invocation) throws Throwable
    {
-      logFile = (String)((ConstructorCalledByConstructorInvocation)invocation).getArguments()[0];
+      if (invocation instanceof ConstructorCalledByConstructorInvocation)
+      {
+         logFile = (String)((ConstructorCalledByConstructorInvocation)invocation).getArguments()[0];
+      }
+      else if (invocation instanceof ConstructorCalledByMethodInvocation)
+      {
+         logFile = (String) ((ConstructorCalledByMethodInvocation) invocation).getArguments()[0];
+      }
+      else if (invocation instanceof MethodCalledByConstructorInvocation)
+      {
+         logFile = (String)((MethodCalledByConstructorInvocation)invocation).getArguments()[0];
+      }
+      else if (invocation instanceof MethodCalledByMethodInvocation)
+      {
+         logFile = (String) ((MethodCalledByMethodInvocation) invocation).getArguments()[0];
+      }
+      
       return invocation.invokeNext();
    }
 

Modified: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/regression/jbaop336callnpe/POJO.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, 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.
-*/ 
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.aop.regression.jbaop336callnpe;
 
 /**
@@ -28,10 +28,31 @@
  */
 public class POJO
 {
-   private Log log;
-   
+   Log log;
+
+   public POJO()
+   {
+      log = new Log();
+   }
+
    public POJO(String logFile)
    {
       log = new Log(logFile);
    }
+
+   public POJO(String logFile, String newLogFile)
+   {
+      log = new Log(logFile);
+      log.overwriteFile(newLogFile);
+   }
+
+   public void recreateLog(String logFile)
+   {
+      log = new Log(logFile);
+   }
+
+   public void setLogFile(String logFile)
+   {
+      log.overwriteFile(logFile);
+   }
 }

Modified: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java	2007-01-16 17:12:16 UTC (rev 59674)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java	2007-01-16 18:15:24 UTC (rev 59675)
@@ -671,17 +671,18 @@
       CallingPOJO pojo = new CallingPOJO();
       CallingPOJO pojo2 = new CallingPOJO();
 
-      String[] expectedNames = new String[16];
+      String[] expectedNames = new String[20];
       
-      for (int i = 0 ; i < 16 ; i += 4)
+      for (int i = 0 ; i < 20 ; i += 5)
       {
-         System.arraycopy(staticNames, 0, expectedNames, i, staticNames.length);
+         System.arraycopy(nonStaticNames, 0, expectedNames, i, nonStaticNames.length);
       }
       checkExpectedNames(expectedNames);
-      assertNotSame(Interceptions.get(0), Interceptions.get(4));
-      assertSame(Interceptions.get(1), Interceptions.get(5));
-      assertSame(Interceptions.get(2), Interceptions.get(6));
-      assertNotSame(Interceptions.get(3), Interceptions.get(7));
+      assertNotSame(Interceptions.get(0), Interceptions.get(5));
+      assertSame(Interceptions.get(1), Interceptions.get(6));
+      assertSame(Interceptions.get(2), Interceptions.get(7));
+      assertNotSame(Interceptions.get(3), Interceptions.get(8));
+      assertSame(Interceptions.get(4), Interceptions.get(9));
       
       
       
@@ -698,12 +699,15 @@
       pojo2 = new CallingPOJO();
       ArrayList ctorB = (ArrayList)Interceptions.interceptions.clone();
       
-      assertNotSame(Interceptions.get(0), Interceptions.get(4));
-      assertSame(Interceptions.get(1), Interceptions.get(5));
-      assertSame(Interceptions.get(2), Interceptions.get(6));
-      assertNotSame(Interceptions.get(3), Interceptions.get(7));
+      assertNotSame(Interceptions.get(0), Interceptions.get(5));
+      assertSame(Interceptions.get(1), Interceptions.get(6));
+      assertSame(Interceptions.get(2), Interceptions.get(7));
+      assertNotSame(Interceptions.get(3), Interceptions.get(8));
+      assertSame(Interceptions.get(4), Interceptions.get(9));
       
-      checkSimilarities(ctorA, ctorB, new Boolean[] {Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE});
+      checkSimilarities(ctorA, ctorB, new Boolean[] {
+            Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE,
+            Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE});
    }
    
    public void testCallerFromStaticMethodWithMixedChains() throws Exception
@@ -745,12 +749,6 @@
       assertNotSame(Interceptions.get(3), Interceptions.get(7));
       
       checkSimilarities(staticA, staticB, new Boolean[] {Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE, Boolean.TRUE});
-
-      Interceptions.clear();
-      CallingPOJO pojo = new CallingPOJO();
-      ArrayList ctorA = (ArrayList)Interceptions.interceptions.clone();
-
-      checkSimilarities(staticA, ctorA, new Boolean[] {Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, Boolean.FALSE});      
    }
    
    public void testCallerFromMethodWithMixedChains() throws Exception




More information about the jboss-cvs-commits mailing list