[jboss-cvs] JBossAS SVN: r59740 - in projects/aop/trunk/aop/src: main/org/jboss/aop/advice and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 17 20:48:06 EST 2007
Author: flavia.rainone at jboss.com
Date: 2007-01-17 20:48:05 -0500 (Wed, 17 Jan 2007)
New Revision: 59740
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java
projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java
projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java
Log:
[JBAOP-336] All calls inside constructors now have callingObject available
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -1802,14 +1802,36 @@
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);
}
-
+ /**
+ *@deprecated
+ */
+ public Object invokeConstructorCaller(int callingIndex, Object callingObject, Object target, Object[] args, CallerMethodInfo info)
+ throws Throwable
+ {
+ return invokeConstructorCaller((MethodByConInfo)info, callingObject, target, args);
+ }
+
+ /**
+ * @deprecated
+ *
+ * Prefer using the version with <code>callingObject</code> instead of this one,
+ * since this object is available for call invocations made inside constructors.
+ *
+ * @see #invokeConstructorCaller(MethodByConInfo, Object, Object, Object[])
+ */
public Object invokeConstructorCaller(MethodByConInfo info, Object target, Object[] args)
throws Throwable
{
- MethodCalledByConstructorInvocation invocation = new MethodCalledByConstructorInvocation(info, target, args, info.getInterceptors());
+ return this.invokeConstructorCaller(info, null, target, args);
+ }
+
+ public Object invokeConstructorCaller(MethodByConInfo info, Object callingObject, Object target, Object[] args)
+ throws Throwable
+ {
+ MethodCalledByConstructorInvocation invocation = new MethodCalledByConstructorInvocation(info, callingObject, target, args, info.getInterceptors());
invocation.setTargetObject(target);
return invocation.invokeNext();
}
@@ -1820,13 +1842,36 @@
public Object invokeConCalledByCon(int callingIndex, Object[] args, CallerConstructorInfo info)
throws Throwable
{
- return invokeConCalledByCon((ConByConInfo)info, args);
+ return invokeConCalledByCon((ConByConInfo)info, null, args);
}
+ /**
+ *@deprecated
+ */
+ public Object invokeConCalledByCon(int callingIndex, Object callingObject, Object[] args, CallerConstructorInfo info)
+ throws Throwable
+ {
+ return invokeConCalledByCon((ConByConInfo)info, callingObject, args);
+ }
+
+ /**
+ * @deprecated
+ *
+ * Prefer using the version with <code>callingObject</code> instead of this one,
+ * since this object is available for call invocations made inside constructors.
+ *
+ * @see #invokeConCalledByCon(ConByConInfo, Object, Object[])
+ */
public Object invokeConCalledByCon(ConByConInfo info, Object[] args)
throws Throwable
{
- ConstructorCalledByConstructorInvocation invocation = new ConstructorCalledByConstructorInvocation(info, args, info.getInterceptors());
+ return invokeConCalledByCon(info, null, args);
+ }
+
+ public Object invokeConCalledByCon(ConByConInfo info, Object callingObject, Object[] args)
+ throws Throwable
+ {
+ ConstructorCalledByConstructorInvocation invocation = new ConstructorCalledByConstructorInvocation(info, callingObject, args, info.getInterceptors());
return invocation.invokeNext();
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceAdvice.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -21,19 +21,17 @@
*/
package org.jboss.aop.advice;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
import org.jboss.aop.Advised;
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;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
/**
* Comment
*
@@ -65,17 +63,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: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerInstanceInterceptor.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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,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: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointAdvice.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -21,27 +21,23 @@
*/
package org.jboss.aop.advice;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
import org.jboss.aop.Advised;
import org.jboss.aop.Advisor;
import org.jboss.aop.ClassAdvisor;
import org.jboss.aop.InstanceAdvisor;
import org.jboss.aop.joinpoint.CallerInvocation;
-import org.jboss.aop.joinpoint.ConstructorCalledByConstructorJoinpoint;
-import org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation;
import org.jboss.aop.joinpoint.ConstructorCalledByMethodJoinpoint;
import org.jboss.aop.joinpoint.ConstructorJoinpoint;
import org.jboss.aop.joinpoint.FieldJoinpoint;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.Joinpoint;
-import org.jboss.aop.joinpoint.MethodCalledByConstructorJoinpoint;
-import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
import org.jboss.aop.joinpoint.MethodCalledByMethodJoinpoint;
import org.jboss.aop.joinpoint.MethodJoinpoint;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
/**
* Comment
*
@@ -60,9 +56,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 +113,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: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerJoinpointInterceptor.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -21,25 +21,21 @@
*/
package org.jboss.aop.advice;
+import java.lang.reflect.Modifier;
+
import org.jboss.aop.Advised;
import org.jboss.aop.Advisor;
import org.jboss.aop.ClassAdvisor;
import org.jboss.aop.InstanceAdvisor;
import org.jboss.aop.joinpoint.CallerInvocation;
-import org.jboss.aop.joinpoint.ConstructorCalledByConstructorJoinpoint;
-import org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation;
import org.jboss.aop.joinpoint.ConstructorCalledByMethodJoinpoint;
import org.jboss.aop.joinpoint.ConstructorJoinpoint;
import org.jboss.aop.joinpoint.FieldJoinpoint;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.Joinpoint;
-import org.jboss.aop.joinpoint.MethodCalledByConstructorJoinpoint;
-import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
import org.jboss.aop.joinpoint.MethodCalledByMethodJoinpoint;
import org.jboss.aop.joinpoint.MethodJoinpoint;
-import java.lang.reflect.Modifier;
-
/**
* Comment
*
@@ -58,9 +54,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 +108,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;
@@ -144,6 +129,4 @@
return interceptor.invoke(invocation);
}
}
-
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/CallerTransformer.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -383,7 +383,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($$); " +
@@ -510,7 +510,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: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/ConByConJoinPointGenerator.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -37,6 +37,7 @@
import org.jboss.aop.GeneratedClassAdvisor;
import org.jboss.aop.JoinPointInfo;
import org.jboss.aop.advice.AdviceMethodProperties;
+import org.jboss.aop.advice.AdviceMethodProperties.OptionalParameters;
import org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation;
import org.jboss.aop.util.ReflectToJavassist;
@@ -113,14 +114,19 @@
protected AdviceMethodProperties getAdviceMethodProperties(AdviceSetup setup)
{
Constructor ctor = ((ConByConInfo)info).getConstructor();
- return new AdviceMethodProperties(
+ AdviceMethodProperties properties = new AdviceMethodProperties(
setup.getAspectClass(),
setup.getAdviceName(),
info.getClass(),
INVOCATION_TYPE,
ctor.getDeclaringClass(),
ctor.getParameterTypes(),
- ctor.getExceptionTypes());
+ ctor.getExceptionTypes(),
+ null, false,
+ ((ConByConInfo) info).getCallingClass(),
+ true);
+ properties.setOptionalParameters(AdviceMethodProperties.OptionalParameters.CALLER);
+ return properties;
}
protected boolean isCaller()
@@ -130,7 +136,7 @@
protected boolean hasCallingObject()
{
- return false;
+ return true;
}
protected boolean hasTargetObject()
@@ -264,7 +270,7 @@
publicConstructor = CtNewConstructor.make(
new CtClass[] {constructorInfoClass},
new CtClass[0],
- "{super($1, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}",
+ "{super($1, null, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}",
jp);
jp.addConstructor(publicConstructor);
}
@@ -275,15 +281,17 @@
*/
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);
StringBuffer body = new StringBuffer();
body.append("{");
body.append(" this($1." + INFO_FIELD + ");");
-
- int offset = 1;
+ body.append(" super.callingObject=$2;");
+
+ int offset = 2;
for (int i = offset ; i < ctorParams.length ; i++)
{
body.append(" arg" + (i - offset) + " = $" + (i + 1) + ";");
@@ -301,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
@@ -310,7 +326,7 @@
invokeJoinpointMethod = CtNewMethod.make(
targetClass,
INVOKE_JOINPOINT,
- params,
+ getInvokeJoinPointParameters(),
targetCtor.getExceptionTypes(),
null,
jp);
@@ -329,12 +345,7 @@
private void addDispatchMethods() throws CannotCompileException, NotFoundException
{
addInvokeNextDispatchMethod();
-
- if (params.length > 0)
- {
- addInvokeJoinpointDispatchMethod();
- }
-
+ addInvokeJoinpointDispatchMethod();
addInvokeTargetMethod();
}
@@ -376,10 +387,17 @@
private void addInvokeJoinpointDispatchMethod() throws CannotCompileException, NotFoundException
{
+ 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));
+ }
//This dispatch method will be called by the invokeJoinPoint() method if the joinpoint has no around advices
String body =
"{" +
- " " + targetClass.getName() + " obj = new " + targetClass.getName() + "($$);" +
+ " " + targetClass.getName() + " obj = new " + targetClass.getName() + "(" + parameters.toString() + ");" +
" setTargetObject(obj);" +
" return obj;" +
"}";
@@ -390,7 +408,7 @@
CtMethod dispatch = CtNewMethod.make(
targetClass,
JoinPointGenerator.DISPATCH,
- params,
+ getInvokeJoinPointParameters(),
targetCtor.getExceptionTypes(),
body,
jp);
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -111,24 +111,27 @@
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);
}
String proceed = null;
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);
@@ -400,6 +403,12 @@
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);
+
String infoName = ConByConJoinPointGenerator.getInfoFieldName(cd.callingIndex, cd.classname, cd.calledHash);
String generatorName = ConByConJoinPointGenerator.getJoinPointGeneratorFieldName(cd.callingIndex, cd.classname, cd.calledHash);
String code =
@@ -410,20 +419,20 @@
" }" +
" if (" + infoName + " == null)" +
" { " +
- " return new " + cd.calledConstructor.getDeclaringClass().getName() + "($$); " +
+ " return new " + cd.calledConstructor.getDeclaringClass().getName() + "(" + getArguments(params.length, 1) + "); " +
" }" +
" else" +
" {" +
" return " + infoName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
" }" +
"}";
-
+
try
{
CtMethod method = CtNewMethod.make(
cd.calledConstructor.getDeclaringClass(),
cd.callerInfoField,
- cd.calledConstructor.getParameterTypes(),
+ params,
cd.calledConstructor.getExceptionTypes(),
code,
getGenadvisor());
@@ -438,16 +447,17 @@
protected void replaceMethodCallInCon(ConstructorDetail cd)throws CannotCompileException, NotFoundException
{
- final String advisor = " ((" + GeneratedAdvisorInstrumentor.getAdvisorFQN(callingClass) + ")" + Instrumentor.HELPER_FIELD_NAME + ")";
+ final String advisor = " ((" + GeneratedAdvisorInstrumentor.getAdvisorFQN(callingClass) + ")" +
+ GeneratedAdvisorInstrumentor.GET_CURRENT_ADVISOR + ")";
final int paramsLength = cd.calledMethod.getParameterTypes().length;
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)) ? "$_ = " : "";
@@ -547,9 +557,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: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodByConJoinPointGenerator.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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
@@ -125,7 +125,9 @@
method.getParameterTypes(),
method.getExceptionTypes(),
method.getDeclaringClass(),
- hasTargetObject());
+ hasTargetObject(),
+ ((MethodByConInfo) info).getCallingClass(),
+ hasCallingObject());
}
protected boolean isCaller()
@@ -135,7 +137,7 @@
protected boolean hasCallingObject()
{
- return false;
+ return true;
}
protected boolean hasTargetObject()
@@ -278,7 +280,7 @@
publicConstructor = CtNewConstructor.make(
new CtClass[] {methodInfoClass},
new CtClass[0],
- "{super($1, null, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}",
+ "{super($1, null, null, $1.getInterceptors()); this." + INFO_FIELD + " = $1;}",
jp);
jp.addConstructor(publicConstructor);
@@ -290,24 +292,25 @@
*/
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);
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++)
@@ -333,13 +336,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;
}
/**
@@ -370,11 +376,7 @@
private void addDispatchMethods() throws CannotCompileException, NotFoundException
{
addInvokeNextDispatchMethod();
- if (hasTargetObject || params.length > 0)
- {
- addInvokeJoinPointDispatchMethod();
- }
-
+ addInvokeJoinPointDispatchMethod();
addInvokeTargetMethod();
}
@@ -425,7 +427,7 @@
//This dispatch method will be called by the invokeJoinPoint() method if the joinpoint has no around advices
final boolean isVoid = targetMethod.getReturnType().equals(CtClass.voidType);
- final int offset = hasTargetObject ? 1 : 0;
+ final int offset = hasTargetObject ? 2 : 1;
StringBuffer parameters = new StringBuffer();
for (int i = 0 ; i < params.length ; i++)
{
@@ -441,7 +443,7 @@
}
else
{
- body.append(MethodExecutionTransformer.getAopReturnStr(isVoid) + "$1." + targetMethod.getName() + "(" + parameters + ");");
+ body.append(MethodExecutionTransformer.getAopReturnStr(isVoid) + "$2." + targetMethod.getName() + "(" + parameters + ");");
}
body.append("}");
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerInvocations.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -124,7 +124,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; "
@@ -233,7 +233,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: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedCallerTransformer.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/CallerInvocation.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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)
{
super(interceptors);
+ this.callingObject = callingObject;
}
-}
+
+ /**
+ * Returns the caller object.
+ *
+ * @return the caller object
+ */
+ public Object getCallingObject()
+ {
+ return this.callingObject;
+ }
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocation.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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()
@@ -211,7 +211,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;
@@ -219,6 +219,4 @@
wrapper.metadata = this.metadata;
return wrapper;
}
-
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByConstructorInvocationWrapper.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -45,7 +45,7 @@
public ConstructorCalledByConstructorInvocationWrapper(ConstructorCalledByConstructorInvocation wrapped, Interceptor[] interceptors)
{
- super(interceptors);
+ super(wrapped.getCallingObject(), interceptors);
this.wrapped = wrapped;
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocation.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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,7 +63,7 @@
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;
@@ -74,9 +72,9 @@
this.arguments = args;
}
- public ConstructorCalledByMethodInvocation(Interceptor[] interceptors)
+ public ConstructorCalledByMethodInvocation(Object callingObject, Interceptor[] interceptors)
{
- super(interceptors);
+ super(callingObject, interceptors);
}
/**
@@ -253,9 +251,4 @@
wrapper.currentInterceptor = this.currentInterceptor;
return wrapper;
}
-
- public Object getCallingObject()
- {
- return callingObject;
- }
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/ConstructorCalledByMethodInvocationWrapper.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -44,7 +44,7 @@
public ConstructorCalledByMethodInvocationWrapper(ConstructorCalledByMethodInvocation wrapped, Interceptor[] interceptors)
{
- super(interceptors);
+ super(wrapped.getCallingObject(), interceptors);
this.wrapped = wrapped;
}
@@ -161,9 +161,4 @@
{
wrapped.setArguments(arguments);
}
-
- public Object getCallingObject()
- {
- return wrapped.getCallingObject();
- }
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocation.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -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);
}
/**
@@ -149,7 +149,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;
@@ -194,4 +194,4 @@
{
return method;
}
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByConstructorInvocationWrapper.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -44,7 +44,7 @@
public MethodCalledByConstructorInvocationWrapper(MethodCalledByConstructorInvocation wrapped, Interceptor[] interceptors)
{
- super(interceptors);
+ super(wrapped.getCallingObject(), interceptors);
this.wrapped = wrapped;
}
@@ -148,5 +148,4 @@
invocation.currentInterceptor = this.currentInterceptor;
return invocation;
}
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocation.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -47,8 +47,7 @@
Method method;
protected Object[] arguments = null;
- protected Object callingObject;
-
+
public MethodCalledByMethodInvocation(MethodByMethodInfo info, Object callingObject, Object targetObject, Object[] arguments, Interceptor[] interceptors)
{
this(info.getAdvisor(), info.getCallingClass(), info.getCallingMethod(), info.getMethod(), callingObject, targetObject, arguments, 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);
}
/**
@@ -202,10 +200,4 @@
{
return method;
}
-
- public Object getCallingObject()
- {
- return callingObject;
- }
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/joinpoint/MethodCalledByMethodInvocationWrapper.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -43,7 +43,7 @@
public MethodCalledByMethodInvocationWrapper(MethodCalledByMethodInvocation wrapped, Interceptor[] interceptors)
{
- super(interceptors);
+ super(wrapped.getCallingObject(), interceptors);
this.wrapped = wrapped;
}
@@ -155,10 +155,4 @@
{
return wrapped.getCalledMethod();
}
-
- public Object getCallingObject()
- {
- return wrapped.getCallingObject();
- }
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/reflection/ReflectionAspect.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -1187,7 +1187,7 @@
if (info != null && info.hasAdvices())
{
- return advisor.invokeConCalledByCon(info, args);
+ return advisor.invokeConCalledByCon(info, inv.getCallingObject(), args);
}
}
}
@@ -1340,7 +1340,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: projects/aop/trunk/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java 2007-01-18 01:42:12 UTC (rev 59739)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/scope/ScopeTestCase.java 2007-01-18 01:48:05 UTC (rev 59740)
@@ -675,20 +675,20 @@
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));
-
for (int i = 0 ; i < Interceptions.size() ; i ++)
{
System.out.println(Interceptions.get(i));
@@ -702,12 +702,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
@@ -749,12 +752,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