[jboss-cvs] JBossAS SVN: r76653 - projects/aop/trunk/aop/src/main/org/jboss/aop.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 5 06:49:48 EDT 2008
Author: stalep
Date: 2008-08-05 06:49:48 -0400 (Tue, 05 Aug 2008)
New Revision: 76653
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java
Log:
[JBAOP-578] optimized for ClassContainer
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java 2008-08-05 10:41:48 UTC (rev 76652)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java 2008-08-05 10:49:48 UTC (rev 76653)
@@ -33,7 +33,7 @@
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -50,6 +50,7 @@
import org.jboss.aop.advice.AdviceBinding;
import org.jboss.aop.advice.AspectDefinition;
import org.jboss.aop.advice.CFlowInterceptor;
+import org.jboss.aop.advice.ClassifiedBindingCollection;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.advice.InterceptorFactory;
import org.jboss.aop.advice.PrecedenceSorter;
@@ -61,6 +62,7 @@
import org.jboss.aop.introduction.AnnotationIntroduction;
import org.jboss.aop.introduction.InterfaceIntroduction;
import org.jboss.aop.joinpoint.ConstructorJoinpoint;
+import org.jboss.aop.joinpoint.FieldJoinpoint;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.aop.joinpoint.Joinpoint;
@@ -1374,7 +1376,86 @@
}
}
}
+
+ protected void updateFieldPointcutAfterRemove(FieldInfo[] fieldInfos, AdviceBinding binding, boolean write)
+ {
+ ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+ Collection<AdviceBinding> bindings = write? bindingCol.getFieldWriteBindings():
+ bindingCol.getFieldReadBindings();
+ for (int i = 0; i < fieldInfos.length; i++)
+ {
+ Field field = fieldInfos[i].getField();
+ fieldInfos[i].resetInterceptors();
+ if ((!write && binding.getPointcut().matchesGet(this, field))
+ || (write && binding.getPointcut().matchesSet(this, field)))
+ {
+ if (AspectManager.verbose) System.err.println("[debug] Removing field, matched " + ((write) ? "write" : "read") + " binding: " + field);
+ fieldInfos[i].clear();
+
+ for(AdviceBinding ab : bindings)
+ {
+ if ((!write && ab.getPointcut().matchesGet(this, field))
+ || (write && ab.getPointcut().matchesSet(this, field)))
+ {
+ pointcutResolved(fieldInfos[i], ab, new FieldJoinpoint(field));
+ }
+ }
+ }
+ }
+ }
+
+ protected void updateConstructorPointcutAfterRemove(AdviceBinding binding)
+ {
+ ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+ if(constructorInfos != null && constructorInfos.length > 0)
+ {
+ for (int i = 0; i < constructors.length; i++)
+ {
+ constructorInfos[i].resetInterceptors();
+ Constructor<?> constructor = constructors[i];
+ if (binding.getPointcut().matchesExecution(this, constructor))
+ {
+ if (AspectManager.verbose) System.err.println("[debug] Removing constructor, matched binding: " + constructor);
+ constructorInfos[i].clear();
+ for(AdviceBinding ab : bindingCol.getConstructorExecutionBindings())
+ {
+ if (ab.getPointcut().matchesExecution(this, constructor))
+ {
+ pointcutResolved(constructorInfos[i], ab, new ConstructorJoinpoint(constructor));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected void updateConstructionPointcutAfterRemove(AdviceBinding binding)
+ {
+ ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
+ if (constructionInfos.length > 0)
+ {
+ for (int i = 0; i < constructionInfos.length ;i++)
+ {
+ constructionInfos[i].resetInterceptors();
+ ConstructionInfo info = constructionInfos[i];
+ Constructor<?> constructor = info.getConstructor();
+ if (binding.getPointcut().matchesConstruction(this, constructor))
+ {
+ if (AspectManager.verbose) System.err.println("[debug] Removing construction, matched binding: " + constructor);
+ constructionInfos[i].clear();
+ for(AdviceBinding ab : bindingCol.getConstructionBindings())
+ {
+ if (binding.getPointcut().matchesConstruction(this, constructor))
+ {
+ pointcutResolved(constructionInfos[i], ab, new ConstructorJoinpoint(constructor));
+ }
+ }
+ }
+ }
+ }
+ }
+
protected void lockWriteChain(MethodInterceptors methodInterceptors)
{
Object[] methodMatchInfos = methodInterceptors.infos.getValues();
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java 2008-08-05 10:41:48 UTC (rev 76652)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java 2008-08-05 10:49:48 UTC (rev 76653)
@@ -826,95 +826,6 @@
}
- protected void updateFieldPointcutAfterRemove(FieldInfo[] fieldInfos, AdviceBinding binding, boolean write)
- {
- ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
- Collection<AdviceBinding> bindings = write? bindingCol.getFieldWriteBindings():
- bindingCol.getFieldReadBindings();
- for (int i = 0; i < fieldInfos.length; i++)
- {
- Field field = fieldInfos[i].getField();
- fieldInfos[i].resetInterceptors();
-
- if ((!write && binding.getPointcut().matchesGet(this, field))
- || (write && binding.getPointcut().matchesSet(this, field)))
- {
- if (AspectManager.verbose) System.err.println("[debug] Removing field, matched " + ((write) ? "write" : "read") + " binding: " + field);
- fieldInfos[i].clear();
-
- for(AdviceBinding ab : bindings)
- {
- if ((!write && ab.getPointcut().matchesGet(this, field))
- || (write && ab.getPointcut().matchesSet(this, field)))
- {
- pointcutResolved(fieldInfos[i], ab, new FieldJoinpoint(field));
- }
- }
- if (write)
- {
- this.fieldWriteInterceptors[i] = fieldInfos[i].getInterceptors();
- }
- else
- {
- this.fieldReadInterceptors[i] = fieldInfos[i].getInterceptors();
- }
- }
- }
- }
-
- protected void updateConstructorPointcutAfterRemove(AdviceBinding binding)
- {
- ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
- if(constructorInfos != null && constructorInfos.length > 0)
- {
- for (int i = 0; i < constructors.length; i++)
- {
- constructorInfos[i].resetInterceptors();
- Constructor<?> constructor = constructors[i];
- if (binding.getPointcut().matchesExecution(this, constructor))
- {
- if (AspectManager.verbose) System.err.println("[debug] Removing constructor, matched binding: " + constructor);
- constructorInfos[i].clear();
- for(AdviceBinding ab : bindingCol.getConstructorExecutionBindings())
- {
- if (ab.getPointcut().matchesExecution(this, constructor))
- {
- pointcutResolved(constructorInfos[i], ab, new ConstructorJoinpoint(constructor));
- }
- }
- this.constructorInterceptors[i] = constructorInfos[i].getInterceptors();
- }
- }
- }
- }
-
- protected void updateConstructionPointcutAfterRemove(AdviceBinding binding)
- {
- ClassifiedBindingCollection bindingCol = manager.getBindingCollection();
- if (constructionInfos.length > 0)
- {
- for (int i = 0; i < constructionInfos.length ;i++)
- {
- constructionInfos[i].resetInterceptors();
- ConstructionInfo info = constructionInfos[i];
- Constructor<?> constructor = info.getConstructor();
- if (binding.getPointcut().matchesConstruction(this, constructor))
- {
- if (AspectManager.verbose) System.err.println("[debug] Removing construction, matched binding: " + constructor);
- constructionInfos[i].clear();
- for(AdviceBinding ab : bindingCol.getConstructionBindings())
- {
- if (binding.getPointcut().matchesConstruction(this, constructor))
- {
- pointcutResolved(constructionInfos[i], ab, new ConstructorJoinpoint(constructor));
- }
- }
- }
- }
- }
- }
-
-
private MethodByConInfo initializeConstructorCallerInterceptorsMap(Class<?> callingClass, int callingIndex, String calledClass, long calledMethodHash, Method calledMethod) throws Exception
{
HashMap<String, TLongObjectHashMap> calledClassesMap = methodCalledByConInterceptors[callingIndex];
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java 2008-08-05 10:41:48 UTC (rev 76652)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassContainer.java 2008-08-05 10:49:48 UTC (rev 76653)
@@ -35,6 +35,7 @@
import org.jboss.aop.metadata.ClassMetaDataBinding;
import org.jboss.aop.metadata.ClassMetaDataLoader;
import org.jboss.aop.util.Advisable;
+import org.jboss.aop.util.BindingClassifier;
import org.jboss.aop.util.ConstructorComparator;
import org.jboss.aop.util.FieldComparator;
import org.jboss.aop.util.MethodHashing;
@@ -154,7 +155,26 @@
@Override
protected void rebuildInterceptorsForRemovedBinding(AdviceBinding binding)
{
- rebuildInterceptors();
+
+ if (BindingClassifier.isExecution(binding))
+ {
+ updateMethodPointcutAfterRemove(binding);
+ }
+ if (BindingClassifier.isConstructorExecution(binding))
+ {
+ updateConstructorPointcutAfterRemove(binding);
+ }
+
+ if (BindingClassifier.isExecution(binding))
+ {
+ finalizeMethodChain();
+ }
+ if (BindingClassifier.isConstructorExecution(binding))
+ {
+ finalizeChain(constructorInfos);
+ }
+
+ doesHaveAspects = adviceBindings.size() > 0;
}
@Override
More information about the jboss-cvs-commits
mailing list