[jboss-cvs] JBossAS SVN: r63713 - projects/aop/trunk/aop/src/main/org/jboss/aop/instrument.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 28 12:48:44 EDT 2007
Author: kabir.khan at jboss.com
Date: 2007-06-28 12:48:43 -0400 (Thu, 28 Jun 2007)
New Revision: 63713
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
Log:
[JBAOP-432] Only push/pop the current invocation once, if using multiple args around advices
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java 2007-06-28 16:23:41 UTC (rev 63712)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java 2007-06-28 16:48:43 UTC (rev 63713)
@@ -830,12 +830,26 @@
code.append(");");
}
+ if (setups.getHasArgsAroundAdvices())
+ {
+ code.append("try{");
+ code.append(" org.jboss.aop.joinpoint.CurrentInvocation.push(jp); ");
+ }
+
+
if (!isVoid())
{
code.append(" " + RETURN_VALUE + " = ($r)");
}
code.append("jp.invokeNext();");
+ if (setups.getHasArgsAroundAdvices())
+ {
+ code.append("}finally{");
+ code.append(" org.jboss.aop.joinpoint.CurrentInvocation.pop(); ");
+ code.append("}");
+ }
+
// 'after' code will find all args inconsistent, since we have to update
// arguments array according to invocation values
inconsistentTypeArgs.get().addAll(joinPointArguments);
@@ -1454,12 +1468,14 @@
AdviceSetup[][] setups;
List<AdviceSetup> lightweightAdvicesRequiringInstanceAdvisor;
boolean hasAroundAdvices;
+ boolean hasArgsAroundAdvices;
AdviceSetups(JoinPointInfo info, AdviceSetup[] allSetups)
{
this.allSetups = allSetups;
int length = AdviceType.values().length;
ArrayList<AdviceSetup>[] aspects = (ArrayList<AdviceSetup>[]) new ArrayList<?>[length];
+
for (int i = 0 ; i < allSetups.length ; i++)
{
if (!allSetups[i].shouldInvokeAspect())
@@ -1484,6 +1500,14 @@
if (AdviceType.AROUND == type)
{
hasAroundAdvices = true;
+ if (!hasArgsAroundAdvices)
+ {
+ if (!hasInvocation(properties))
+ {
+ hasArgsAroundAdvices = true;
+ }
+ }
+
}
else if (allSetups[i].requiresInstanceAdvisor())
{
@@ -1511,6 +1535,19 @@
}
}
+ private boolean hasInvocation(AdviceMethodProperties properties)
+ {
+ int[] args = properties.getArgs();
+ for (int z = 0; z < args.length ; z++)
+ {
+ if (args[z] == AdviceMethodProperties.INVOCATION_ARG)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Returns the list of all advice setups, regardless of the advice type.
*/
@@ -1540,6 +1577,11 @@
{
return lightweightAdvicesRequiringInstanceAdvisor;
}
+
+ public boolean getHasArgsAroundAdvices()
+ {
+ return hasArgsAroundAdvices;
+ }
}
private interface GenerateJoinPointClassAction
@@ -1806,25 +1848,11 @@
this.consistencyEnforced = false;
int[] args = properties.getArgs();
- final boolean firstParamIsInvocation =
- (args.length >= 1 && args[0] == AdviceMethodProperties.INVOCATION_ARG);
-
- if (!firstParamIsInvocation)
- {
- call.append("try{");
- call.append(" org.jboss.aop.joinpoint.CurrentInvocation.push(this); ");
- }
call.append(" ");
call.append(returnStr);
call.append(" ");
boolean result = super.appendAdviceCall(setup, beforeCall, call, generator);
- if (!firstParamIsInvocation)
- {
- call.append("}finally{");
- call.append(" org.jboss.aop.joinpoint.CurrentInvocation.pop(); ");
- call.append("}");
- }
return result;
}
More information about the jboss-cvs-commits
mailing list