[jboss-cvs] JBossAS SVN: r72766 - in projects/aop/trunk/aop/src: resources/test/rebuildingchain and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Apr 27 20:37:53 EDT 2008
Author: flavia.rainone at jboss.com
Date: 2008-04-27 20:37:53 -0400 (Sun, 27 Apr 2008)
New Revision: 72766
Added:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructionSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByConstructorSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByMethodSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorExecutionSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldReadSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldWriteSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByConstructorSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByMethodSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodExecutionSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldReadSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldWriteSyncThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticMethodExecutionSyncThread.java
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructionTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructorExecutionTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java
projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
projects/aop/trunk/aop/src/resources/test/rebuildingchain/jboss-aop.xml
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncInterceptor.java
projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java
Log:
[JBAOP-537] The bug is fixed (applied suggested workaround on all genadivsor wrappers).
The tests were added to the rebuildingchain test suite.
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 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorCallerTransformer.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -142,27 +142,27 @@
String infoName = cd.callerInfoField;
String code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
+ " try" +
" {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
- " {" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
+ " {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
+ " }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " " + proceed +
+ " }" +
+ " else" +
+ " {" +
+ " return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
+ " }" +
+ " } finally {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
- " }" +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " " + proceed +
- " }" +
- " else" +
- " {" +
- " return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
- " }" +
"}";
try
@@ -253,27 +253,27 @@
String infoName = md.callerInfoField;
String code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
+ " try" +
" {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
+ " }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " " + proceed +
+ " }" +
+ " else" +
+ " {" +
+ " " + MethodExecutionTransformer.getReturnStr(md.calledMethod) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
+ " }" +
+ " } finally {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
- " }" +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " " + proceed +
- " }" +
- " else" +
- " {" +
- " " + MethodExecutionTransformer.getReturnStr(md.calledMethod) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
- " }" +
"}";
@@ -354,27 +354,28 @@
String infoName = cd.callerInfoField;
StringBuffer code = new StringBuffer();
code.append("{");
- code.append(" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())");
+ code.append(GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName));
+ code.append(" try" );
code.append(" {");
- code.append(GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName));
- code.append(" try" );
+ code.append(" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())");
code.append(" {");
code.append(" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())");
code.append(" {");
code.append(" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");");
code.append(" }");
- code.append(" } finally {");
+ code.append(" }");
+ code.append(" if (" + joinpointName + " == null)");
+ code.append(" { ");
+ code.append(" return new " + cd.calledConstructor.getDeclaringClass().getName() + "(" + getArguments(params.length, hasCallingObject ? 1 : 0) + "); ");
+ code.append(" }");
+ code.append(" else");
+ code.append(" {");
+ code.append(" return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);");
+ code.append(" }");
+ code.append(" } finally {");
code.append(GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName));
- code.append(" }");
code.append(" }");
- code.append(" if (" + joinpointName + " == null)");
- code.append(" { ");
- code.append(" return new " + cd.calledConstructor.getDeclaringClass().getName() + "(" + getArguments(params.length, hasCallingObject ? 1 : 0) + "); ");
- code.append(" }");
- code.append(" else");
- code.append(" {");
- code.append(" return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);");
- code.append(" }");
+
code.append("}");
try
@@ -444,27 +445,27 @@
String infoName = cd.callerInfoField;
String code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
+ " try" +
" {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
+ " }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " return new " + cd.calledConstructor.getDeclaringClass().getName() + "(" + getArguments(params.length, 1) + "); " +
+ " }" +
+ " else" +
+ " {" +
+ " return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
+ " }" +
+ " } finally {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
- " }" +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " return new " + cd.calledConstructor.getDeclaringClass().getName() + "(" + getArguments(params.length, 1) + "); " +
- " }" +
- " else" +
- " {" +
- " return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
- " }" +
"}";
try
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructionTransformer.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructionTransformer.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -146,23 +146,23 @@
String infoName = getConstructionInfoFieldName(constructor.getDeclaringClass().getSimpleName(), index);
String code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
+ " try" +
" {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
+ " }" +
+ " if (" + joinpointName + " != null)" +
+ " { " +
+ " " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
+ " }" +
+ " } finally {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
- " }" +
" }" +
- " if (" + joinpointName + " != null)" +
- " { " +
- " " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
- " }" +
"}";
return code;
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructorExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructorExecutionTransformer.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorConstructorExecutionTransformer.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -220,33 +220,29 @@
String code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
- " {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " try" +
+ " {" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " return new " + trans.getClassName() + "($$); " +
+ " }" +
+ " else" +
+ " {" +
+ " return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
+ " }" +
+ " } finally {" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " return new " + trans.getClassName() + "($$); " +
- " }" +
- " else" +
- " {" +
- " return " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
- " }" +
"}";
codifier.addPendingCode(innerWrapper, code);
}
-
-
-
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorFieldAccessTransformer.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -262,54 +262,54 @@
{
code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
- " {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " try" +
+ " {" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " return " + clazz.getName() + "." + field.getName() + ";" +
+ " }" +
+ " else" +
+ " {" +
+ " " + MethodExecutionTransformer.getAopReturnStr(false) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "();" +
+ " }" +
+ " } finally {" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " return " + clazz.getName() + "." + field.getName() + ";" +
- " }" +
- " else" +
- " {" +
- " " + MethodExecutionTransformer.getAopReturnStr(false) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "();" +
- " }" +
"}";
}
else
{
code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
- " {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " try" +
+ " {" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " return ((" + clazz.getName() + ")$1)." + field.getName() + ";" +
+ " }" +
+ " else" +
+ " {" +
+ " " + MethodExecutionTransformer.getAopReturnStr(false) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "((" + clazz.getName() + ")$1);" +
+ " }" +
+ " } finally {" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " return ((" + clazz.getName() + ")$1)." + field.getName() + ";" +
- " }" +
- " else" +
- " {" +
- " " + MethodExecutionTransformer.getAopReturnStr(false) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "((" + clazz.getName() + ")$1);" +
- " }" +
"}";
}
@@ -329,28 +329,28 @@
String fieldString = clazz.getName() + "." + field.getName();
code =
"{" +
- " " + getArrayWriteRegistration(shouldReplaceArrayAccess, targetString, field, fieldString, "$2") +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
- " {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " try" +
+ " {" +
+ " " + getArrayWriteRegistration(shouldReplaceArrayAccess, targetString, field, fieldString, "$2") +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " " + fieldString + " = $2;" +
+ " }" +
+ " else" +
+ " {" +
+ " " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($2);" +
+ " }" +
+ " } finally {" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " " + fieldString + " = $2;" +
- " }" +
- " else" +
- " {" +
- " " + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($2);" +
- " }" +
"}";
}
else
@@ -359,28 +359,28 @@
String fieldString = targetString + "." + field.getName();
code =
"{" +
- " " + getArrayWriteRegistration(shouldReplaceArrayAccess, targetString, field, fieldString, "$2") +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
- " {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " try" +
+ " {" +
+ " " + getArrayWriteRegistration(shouldReplaceArrayAccess, targetString, field, fieldString, "$2") +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " " + fieldString + " = $2;" +
+ " }" +
+ " else" +
+ " {" +
+ " " + MethodExecutionTransformer.getAopReturnStr(false) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "((" + clazz.getName() + ")$1, $2);" +
+ " }" +
+ " } finally {" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " " + fieldString + " = $2;" +
- " }" +
- " else" +
- " {" +
- " " + MethodExecutionTransformer.getAopReturnStr(false) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "((" + clazz.getName() + ")$1, $2);" +
- " }" +
"}";
}
@@ -534,5 +534,4 @@
}
}
}
-
-}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -434,27 +434,27 @@
String code =
"{" +
- " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
+ GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
+ " try" +
" {" +
- GeneratedAdvisorInstrumentor.generateInterceptorChainLockCode(infoName) +
- " try" +
+ " if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" if (" + joinpointName + " == null && " + infoName + " != null && " + infoName + ".hasAdvices())" +
" {" +
" super." + JoinPointGenerator.GENERATE_JOINPOINT_CLASS + "(" + infoName + ");" +
" }" +
- " } finally {" +
+ " }" +
+ " if (" + joinpointName + " == null)" +
+ " { " +
+ " " + getReturnStr(trans.getWMethod()) + trans.getClazzName() + "." + trans.getWrappedName() +"($$);" +
+ " }" +
+ " else" +
+ " {" +
+ " " + getAopReturnStr(trans.getWMethod()) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
+ " }" +
+ " } finally {" +
GeneratedAdvisorInstrumentor.generateInterceptorChainUnlockCode(infoName) +
- " }" +
" }" +
- " if (" + joinpointName + " == null)" +
- " { " +
- " " + getReturnStr(trans.getWMethod()) + trans.getClazzName() + "." + trans.getWrappedName() +"($$);" +
- " }" +
- " else" +
- " {" +
- " " + getAopReturnStr(trans.getWMethod()) + joinpointName + "." + JoinPointGenerator.INVOKE_JOINPOINT + "($$);" +
- " }" +
"}";
return code;
Modified: projects/aop/trunk/aop/src/resources/test/rebuildingchain/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/rebuildingchain/jboss-aop.xml 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/resources/test/rebuildingchain/jboss-aop.xml 2008-04-28 00:37:53 UTC (rev 72766)
@@ -1,4 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<aop>
- <prepare expr="execution(* org.jboss.test.aop.rebuildingchain.SyncThread->checkStatus())" />
-</aop>
+
+ <!-- field read -->
+ <prepare expr="get(int org.jboss.test.aop.rebuildingchain.FieldReadSyncThread->field)"/>
+ <!-- static field read -->
+ <prepare expr="get(int org.jboss.test.aop.rebuildingchain.StaticFieldReadSyncThread->field)"/>
+ <!-- field write -->
+ <prepare expr="set(int org.jboss.test.aop.rebuildingchain.FieldWriteSyncThread->field)"/>
+ <!-- static field write -->
+ <prepare expr="set(int org.jboss.test.aop.rebuildingchain.StaticFieldWriteSyncThread->field)"/>
+
+ <!-- constructor execution -->
+ <prepare expr="execution(org.jboss.test.aop.rebuildingchain.ConstructorExecutionSyncThread$Pojo->new())"/>
+ <!-- construction -->
+ <prepare expr="construction(org.jboss.test.aop.rebuildingchain.ConstructionSyncThread$Pojo->new())"/>
+
+ <!-- method execution -->
+ <prepare expr="execution(* org.jboss.test.aop.rebuildingchain.MethodExecutionSyncThread->method())" />
+ <!-- static method execution -->
+ <prepare expr="execution(* org.jboss.test.aop.rebuildingchain.StaticMethodExecutionSyncThread->method())"/>
+
+ <!-- constructor call by constructor -->
+ <prepare expr="call(org.jboss.test.aop.rebuildingchain.ConstructorCallByConstructorSyncThread$Pojo2->new())"/>
+ <!-- constructor call by method -->
+ <prepare expr="call(org.jboss.test.aop.rebuildingchain.ConstructorCallByMethodSyncThread$Pojo->new())"/>
+ <!-- method call by constructor -->
+ <prepare expr="call(* org.jboss.test.aop.rebuildingchain.MethodCallByConstructorSyncThread$Pojo->method())"/>
+ <!-- method call by method -->
+ <prepare expr="call(* org.jboss.test.aop.rebuildingchain.MethodCallByMethodSyncThread->method())"/>
+
+
+</aop>
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructionSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructionSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructionSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,44 @@
+/*
+ * 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.rebuildingchain;
+
+
+/**
+ * This thread executes a construction joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ConstructionSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "construction(org.jboss.test.aop.rebuildingchain.ConstructionSyncThread$Pojo->new())";
+ public static final String NAME = "Construction";
+
+ protected void invokeJoinPoint()
+ {
+ new Pojo();
+ }
+
+ private static class Pojo
+ {
+ public Pojo() {}
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByConstructorSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByConstructorSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByConstructorSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,53 @@
+/*
+ * 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.rebuildingchain;
+
+
+/**
+ * This thread executes a constructor call by constructor joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ConstructorCallByConstructorSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "call(org.jboss.test.aop.rebuildingchain.ConstructorCallByConstructorSyncThread$Pojo2->new())";
+ public static final String NAME = "ConstructorCallByConstructor";
+
+ protected void invokeJoinPoint()
+ {
+ new Pojo1();
+ }
+
+ private static class Pojo1
+ {
+ public Pojo1()
+ {
+ new Pojo2();
+ }
+ }
+
+ // TODO test omitting this constructor
+ private static class Pojo2
+ {
+ public Pojo2(){}
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByMethodSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByMethodSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorCallByMethodSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,45 @@
+/*
+ * 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.rebuildingchain;
+
+
+/**
+ * This thread executes a constructor call by method joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ConstructorCallByMethodSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "call(org.jboss.test.aop.rebuildingchain.ConstructorCallByMethodSyncThread$Pojo->new())";
+ public static final String NAME = "ConstructorCallByMethod";
+
+ protected void invokeJoinPoint()
+ {
+ new Pojo();
+ }
+
+ private static class Pojo
+ {
+ // TODO test omitting this constructor
+ public Pojo(){}
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorExecutionSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorExecutionSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/ConstructorExecutionSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,43 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a constructor execution joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ConstructorExecutionSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "execution(org.jboss.test.aop.rebuildingchain.ConstructorExecutionSyncThread$Pojo->new())";
+ public static final String NAME = "ConstructorExecution";
+
+ protected void invokeJoinPoint()
+ {
+ new Pojo();
+ }
+
+ private static class Pojo
+ {
+ public Pojo() {}
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldReadSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldReadSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldReadSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,42 @@
+/*
+ * 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.rebuildingchain;
+
+
+/**
+ * This thread executes a field read joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class FieldReadSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "get(int org.jboss.test.aop.rebuildingchain.FieldReadSyncThread->field)";
+ public static final String NAME = "FieldRead";
+
+ private int field = 0;
+
+ protected void invokeJoinPoint()
+ {
+ @SuppressWarnings("unused")
+ int value = field;
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldWriteSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldWriteSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/FieldWriteSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,41 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a field write joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class FieldWriteSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "set(int org.jboss.test.aop.rebuildingchain.FieldWriteSyncThread->field)";
+ public static final String NAME = "FieldWrite";
+
+ @SuppressWarnings("unused")
+ private int field = 0;
+
+ protected void invokeJoinPoint()
+ {
+ field = 1;
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByConstructorSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByConstructorSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByConstructorSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,48 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a method call by constructor joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class MethodCallByConstructorSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "call(* org.jboss.test.aop.rebuildingchain.MethodCallByConstructorSyncThread$Pojo->method())";
+ public static final String NAME = "MethodCallByConstructor";
+
+ protected void invokeJoinPoint()
+ {
+ new Pojo();
+ }
+
+ private static class Pojo
+ {
+ public Pojo()
+ {
+ this.method();
+ }
+
+ private void method() {}
+ }
+}
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByMethodSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByMethodSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodCallByMethodSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,40 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a method call by method joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class MethodCallByMethodSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "call(* org.jboss.test.aop.rebuildingchain.MethodCallByMethodSyncThread->method())";
+ public static final String NAME = "MethodCallByMethod";
+
+ protected void invokeJoinPoint()
+ {
+ method();
+ }
+
+ public void method() {}
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodExecutionSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodExecutionSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/MethodExecutionSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,40 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a method execution joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class MethodExecutionSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "execution(* org.jboss.test.aop.rebuildingchain.MethodExecutionSyncThread->method())";
+ public static final String NAME = "MethodExecution";
+
+ protected void invokeJoinPoint()
+ {
+ method();
+ }
+
+ public void method() {}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -33,36 +33,52 @@
*/
public class RebuildThread extends Thread
{
+ private volatile boolean done = false;
+ private String pointcutExpression;
+ private String bindingPrefix;
+ public RebuildThread(String pointcutExpression, String bindingPrefix)
+ {
+ this.pointcutExpression = pointcutExpression;
+ this.bindingPrefix = bindingPrefix;
+ }
@Override
public void run()
{
- for(int i=0; i < 30; i++)
+ try
{
- linkNewAdvice("Test" + i);
- unlinkAdvice("Test" + i);
+ for(int i = 0; i < 30; i++)
+ {
+ linkNewAdvice(bindingPrefix + i);
+ unlinkAdvice(bindingPrefix + i);
+ if(isDone())
+ {
+ return;
+ }
+ }
}
-
+ catch(Exception e)
+ {
+ System.out.println("An exception occurred: " + e);
+ e.printStackTrace();
+ RebuildingChainTestCase.setTestFailed();
+ }
}
- public void linkNewAdvice()
+ public void linkNewAdvice() throws ParseException
{
- linkNewAdvice("Base");
+ linkNewAdvice(bindingPrefix + "Base");
}
+
+ public void unlinkAdvice()
+ {
+ unlinkAdvice(bindingPrefix + "Base");
+ }
- private void linkNewAdvice(String name)
+ private void linkNewAdvice(String name) throws ParseException
{
- //System.out.println("adding new advice" + name);
- AdviceBinding binding1 = null;
- try
- {
- binding1 = new AdviceBinding("execution(* org.jboss.test.aop.rebuildingchain.SyncThread->checkStatus())", null);
- }
- catch (ParseException e)
- {
- e.printStackTrace();
- }
+ AdviceBinding binding1 = new AdviceBinding(pointcutExpression, null);
binding1.addInterceptor(SyncInterceptor.class);
binding1.setName(name);
AspectManager.instance().addBinding(binding1);
@@ -70,8 +86,17 @@
private void unlinkAdvice(String name)
{
- //System.out.println("unlinking " + name);
AspectManager.instance().removeBinding(name);
}
-
-}
+
+
+ public void setDone(boolean b)
+ {
+ done = b;
+ }
+
+ private boolean isDone()
+ {
+ return done;
+ }
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/RebuildingChainTestCase.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -49,72 +49,215 @@
return suite;
}
- public void testRebuildingChain() throws Exception
+ public void setUp() throws Exception
{
- System.out.println("testing rebuildingchain!");
-// AspectManager.instance().verbose = true;
- SyncThread st = new SyncThread();
- RebuildThread rt = new RebuildThread();
- rt.linkNewAdvice();
+ failed = false;
+ super.setUp();
+ }
+
+ public void testFieldReadWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new FieldReadSyncThread(),
+ FieldReadSyncThread.POINTCUT, FieldReadSyncThread.NAME);
+ }
+
+ public void testFieldReadWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new FieldReadSyncThread(),
+ FieldReadSyncThread.POINTCUT, FieldReadSyncThread.NAME);
+ }
+
+ public void testStaticFieldReadWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new StaticFieldReadSyncThread(),
+ StaticFieldReadSyncThread.POINTCUT, StaticFieldReadSyncThread.NAME);
+ }
+
+ public void testStaticFieldReadWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new StaticFieldReadSyncThread(),
+ StaticFieldReadSyncThread.POINTCUT, StaticFieldReadSyncThread.NAME);
+ }
+
+ public void testFieldWriteWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new FieldWriteSyncThread(),
+ FieldWriteSyncThread.POINTCUT, FieldWriteSyncThread.NAME);
+ }
+
+ public void testFieldWriteWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new FieldWriteSyncThread(),
+ FieldWriteSyncThread.POINTCUT, FieldWriteSyncThread.NAME);
+ }
+
+ public void testStaticFieldWriteWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new StaticFieldWriteSyncThread(),
+ StaticFieldWriteSyncThread.POINTCUT, StaticFieldWriteSyncThread.NAME);
+ }
+
+ public void testStaticFieldWriteWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new StaticFieldWriteSyncThread(),
+ StaticFieldWriteSyncThread.POINTCUT, StaticFieldWriteSyncThread.NAME);
+ }
+
+ public void testConstructorExecutionWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new ConstructorExecutionSyncThread(),
+ ConstructorExecutionSyncThread.POINTCUT,
+ ConstructorExecutionSyncThread.NAME);
+ }
+
+ public void testConstructorExecutionWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new ConstructorExecutionSyncThread(),
+ ConstructorExecutionSyncThread.POINTCUT,
+ ConstructorExecutionSyncThread.NAME);
+ }
+
+ public void testConstructionWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new ConstructionSyncThread(),
+ ConstructionSyncThread.POINTCUT, ConstructionSyncThread.NAME);
+ }
+
+ public void testConstructionWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new ConstructionSyncThread(),
+ ConstructionSyncThread.POINTCUT, ConstructionSyncThread.NAME);
+ }
+
+ public void testMethodExecutionWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new MethodExecutionSyncThread(),
+ MethodExecutionSyncThread.POINTCUT, MethodExecutionSyncThread.NAME);
+ }
+
+ public void testMethodExecutionWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new MethodExecutionSyncThread(),
+ MethodExecutionSyncThread.POINTCUT, MethodExecutionSyncThread.NAME);
+ }
+
+ public void testStaticMethodExecutionWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new StaticMethodExecutionSyncThread(),
+ StaticMethodExecutionSyncThread.POINTCUT,
+ StaticMethodExecutionSyncThread.NAME);
+ }
+
+ public void testStaticMethodExecutionWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new StaticMethodExecutionSyncThread(),
+ StaticMethodExecutionSyncThread.POINTCUT,
+ StaticMethodExecutionSyncThread.NAME);
+ }
+
+ public void testConstructorCallByConstructorWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new ConstructorCallByConstructorSyncThread(),
+ ConstructorCallByConstructorSyncThread.POINTCUT,
+ ConstructorCallByConstructorSyncThread.NAME);
+ }
+
+ public void testConstructorCallByConstructorWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new ConstructorCallByConstructorSyncThread(),
+ ConstructorCallByConstructorSyncThread.POINTCUT,
+ ConstructorCallByConstructorSyncThread.NAME);
+ }
+
+ // TODO This must be uncommented as part of task JBAOP-537 after JBAOP-433 is fixed
+ /*public void testConstructorCallByMethodWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new ConstructorCallByMethodSyncThread(),
+ ConstructorCallByMethodSyncThread.POINTCUT,
+ ConstructorCallByMethodSyncThread.NAME);
+ }
+
+ public void testConstructorCallByMethodWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new ConstructorCallByMethodSyncThread(),
+ ConstructorCallByMethodSyncThread.POINTCUT,
+ ConstructorCallByMethodSyncThread.NAME);
+ }
+
+ public void testMethodCallByConstructorWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new MethodCallByConstructorSyncThread(),
+ MethodCallByConstructorSyncThread.POINTCUT,
+ MethodCallByConstructorSyncThread.NAME);
+ }
+
+ public void testMethodCallByConstructorWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new MethodCallByConstructorSyncThread(),
+ MethodCallByConstructorSyncThread.POINTCUT,
+ MethodCallByConstructorSyncThread.NAME);
+ }
+
+ public void testMethodCallByMethodWithSetDone() throws Exception
+ {
+ assertRebuildingChainWithSetDone(new MethodCallByMethodSyncThread(),
+ MethodCallByMethodSyncThread.POINTCUT,
+ MethodCallByMethodSyncThread.NAME);
+ }
+
+ public void testMethodCallByMethodWithJoin() throws Exception
+ {
+ assertRebuildingChainWithJoin(new MethodCallByMethodSyncThread(),
+ MethodCallByMethodSyncThread.POINTCUT,
+ MethodCallByMethodSyncThread.NAME);
+ }*/
+
+ private void assertRebuildingChainWithSetDone(SyncThread st,
+ String pointcutExpression, String bindingPrefix) throws Exception
+ {
+ RebuildThread rt = startThreads(st, pointcutExpression, bindingPrefix);
- Thread.sleep(10000);
+ Thread.sleep(200);
- rt.start();
- //rt.join();
- st.start();
+ st.setDone(true);
+ rt.setDone(true);
+ rt.unlinkAdvice();
+
+ assertFalse("Failed to match pointcut when rebuilding the chain....", failed);
+ }
+
+ private void assertRebuildingChainWithJoin(SyncThread st, String pointcutExpression,
+ String bindingPrefix) throws Exception
+ {
+ RebuildThread rt = startThreads(st, pointcutExpression, bindingPrefix + "Join");
+
+ st.join();
rt.join();
- st.join();
+ rt.unlinkAdvice();
+
assertFalse("Failed to match pointcut when rebuilding the chain....", failed);
}
- public void testRebuildingChainWithJoin() throws Exception
+ private RebuildThread startThreads(SyncThread st, String pointcutExpression,
+ String bindingPrefix) throws Exception
{
System.out.println("testing rebuildingchain!");
-// AspectManager.instance().verbose = true;
- SyncThread st = new SyncThread();
- RebuildThread rt = new RebuildThread();
+
+ RebuildThread rt = new RebuildThread(pointcutExpression, bindingPrefix);
rt.linkNewAdvice();
+ Thread.sleep(20);
+
rt.start();
st.start();
- /*try
- {
- long start = System.currentTimeMillis();
- Thread.sleep(20);
- System.out.println("Slept for: "+(System.currentTimeMillis()-start));
- }
- catch(InterruptedException ie)
- {
- System.err.println("BAH "+ie.getMessage());
- }
- */
- //st.setDone(true);
- //rt.setDone(true);
-
- st.join();
- rt.join();
-
- assertFalse("Failed to match pointcut when rebuilding the chain....", failed);
+ return rt;
}
public static void setTestFailed()
{
failed = true;
}
-
- /*public static void main(String[] args)throws Exception
- {
- try
- {
- RebuildingChainTestCase test = new RebuildingChainTestCase("XXX");
- test.testRebuildingChain();
- }
- catch (RuntimeException e)
- {
- System.err.println(e);
- }
- }*/
-}
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldReadSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldReadSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldReadSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,41 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a static field read joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class StaticFieldReadSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "get(int org.jboss.test.aop.rebuildingchain.StaticFieldReadSyncThread->field)";
+ public static final String NAME = "StaticFieldRead";
+
+ private static int field = 0;
+
+ protected void invokeJoinPoint()
+ {
+ @SuppressWarnings("unused")
+ int value = field;
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldWriteSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldWriteSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticFieldWriteSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,41 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a static field write joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class StaticFieldWriteSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "set(int org.jboss.test.aop.rebuildingchain.StaticFieldWriteSyncThread->field)";
+ public static final String NAME = "StaticFieldWrite";
+
+ @SuppressWarnings("unused")
+ private static int field = 0;
+
+ protected void invokeJoinPoint()
+ {
+ field = 1;
+ }
+}
\ No newline at end of file
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticMethodExecutionSyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticMethodExecutionSyncThread.java (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/StaticMethodExecutionSyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -0,0 +1,40 @@
+/*
+ * 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.rebuildingchain;
+
+/**
+ * This thread executes a static method execution joinpoint.
+ *
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class StaticMethodExecutionSyncThread extends SyncThread
+{
+ public static final String POINTCUT = "execution(* org.jboss.test.aop.rebuildingchain.StaticMethodExecutionSyncThread->method())";
+ public static final String NAME = "StaticMethodExecution";
+
+ protected void invokeJoinPoint()
+ {
+ method();
+ }
+
+ public static void method() {}
+}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncInterceptor.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncInterceptor.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -43,20 +43,8 @@
public synchronized Object invoke(Invocation invocation) throws Throwable
{
long time = System.currentTimeMillis();
- try
- {
- System.out.println("SyncInterceptor: " + time);
- SyncThread.setStatus(true);
- return invocation.invokeNext();
- }
- catch(Exception e)
- {
- throw e;
- }
- finally
- {
- SyncThread.setStatus(false);
- System.out.println("SyncInterceptor EXITED");
- }
+ System.out.println("SyncInterceptor: " + time);
+ SyncThread.setStatus(true);
+ return invocation.invokeNext();
}
}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java 2008-04-28 00:32:48 UTC (rev 72765)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/rebuildingchain/SyncThread.java 2008-04-28 00:37:53 UTC (rev 72766)
@@ -27,25 +27,38 @@
* @author <a href="stale.pedersen at jboss.org">Stale W. Pedersen</a>
* @version $Revision: 1.1 $
*/
-public class SyncThread extends Thread
+public abstract class SyncThread extends Thread
{
private static Object lock = new Object();
private static volatile boolean status = false;
+ private volatile boolean done = false;
@Override
public void run()
{
- for(int i=0; i < 30; i++)
+ try
{
-
- checkStatus();
+ for(int i = 0; i < 30; i++)
+ {
+ setStatus(false);
+ invokeJoinPoint();
+ checkStatus();
+ if(isDone())
+ {
+ return;
+ }
+ }
}
+ catch (Exception e)
+ {
+ System.out.println("An exception occurred: " + e);
+ e.printStackTrace();
+ RebuildingChainTestCase.setTestFailed();
+ }
}
private void checkStatus()
{
- long time = System.currentTimeMillis();
- System.out.println("CHECKING STATUS: " + time);
System.out.println("ST checking status...");
if(getStatus() == false)
{
@@ -69,4 +82,16 @@
status = b;
}
}
+
+ public void setDone(boolean b)
+ {
+ done = b;
+ }
+
+ private boolean isDone()
+ {
+ return done;
+ }
+
+ protected abstract void invokeJoinPoint();
}
More information about the jboss-cvs-commits
mailing list