[jboss-cvs] JBossAS SVN: r78457 - in projects/aop/trunk/aop/src/main/org/jboss/aop: advice and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 11 13:34:24 EDT 2008
Author: kabir.khan at jboss.com
Date: 2008-09-11 13:34:24 -0400 (Thu, 11 Sep 2008)
New Revision: 78457
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
Log:
[JBAOP-641] Move pointcut stats into ClassifiedBindingAndPointcutCollection
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java 2008-09-11 17:08:37 UTC (rev 78456)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java 2008-09-11 17:34:24 UTC (rev 78457)
@@ -76,7 +76,6 @@
import org.jboss.aop.pointcut.DeclareDef;
import org.jboss.aop.pointcut.DynamicCFlow;
import org.jboss.aop.pointcut.Pointcut;
-import org.jboss.aop.pointcut.PointcutExpression;
import org.jboss.aop.pointcut.PointcutInfo;
import org.jboss.aop.pointcut.PointcutStats;
import org.jboss.aop.pointcut.Typedef;
@@ -164,13 +163,13 @@
// these fields represent whether there are certain pointcut types.
// for performance reasons the transformers and binders can make a lot of us of this.
- protected boolean execution = false;
- protected boolean construction = false;
- protected boolean call = false;
- protected boolean within = false;
- protected boolean get = false;
- protected boolean set = false;
- protected boolean withincode = false;
+// protected boolean execution = false;
+// protected boolean construction = false;
+// protected boolean call = false;
+// protected boolean within = false;
+// protected boolean get = false;
+// protected boolean set = false;
+// protected boolean withincode = false;
public static boolean classicOrder = false;
protected volatile LinkedHashMap<String, ClassMetaDataBinding> classMetaData = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
@@ -1288,103 +1287,42 @@
*/
public synchronized void addPointcut(Pointcut pointcut)
{
- bindingCollection.add(pointcut);
- updatePointcutStats(pointcut);
+ bindingCollection.add(pointcut, this);
}
- /**
- * THis method is used for performance reasons.
- *
- * @param pointcut
- */
- protected void updatePointcutStats(Pointcut pointcut)
- {
- synchronized(bindingCollection)
- {
- // the following is for performance reasons.
- if (pointcut instanceof PointcutExpression)
- {
- PointcutExpression expr = (PointcutExpression) pointcut;
- expr.setManager(this);
- PointcutStats stats = expr.getStats();
- updateStats(stats);
- }
- else
- {
- // can't be sure so set all
- execution = true;
- construction = true;
- call = true;
- within = true;
- get = true;
- set = true;
- withincode = true;
- }
- }
- }
-
- protected synchronized void updateStats(PointcutStats stats)
- {
- synchronized(bindingCollection)
- {
- if (stats != null)
- {
- construction |= stats.isConstruction();
- execution |= stats.isExecution();
- call |= stats.isCall();
- within |= stats.isWithin();
- get |= stats.isGet();
- set |= stats.isSet();
- withincode |= stats.isWithincode();
- }
- else
- {
- if (verbose && logger.isDebugEnabled()) logger.debug("Setting all pointcut stats to true");
- // can't be sure so set all
- execution = true;
- construction = true;
- call = true;
- within = true;
- get = true;
- set = true;
- withincode = true;
- }
- }
- }
-
public boolean isExecution()
{
- return execution;
+ return bindingCollection.isExecution();
}
public boolean isConstruction()
{
- return construction;
+ return bindingCollection.isConstruction();
}
public boolean isCall()
{
- return call;
+ return bindingCollection.isCall();
}
public boolean isWithin()
{
- return within;
+ return bindingCollection.isWithin();
}
public boolean isWithincode()
{
- return withincode;
+ return bindingCollection.isWithincode();
}
public boolean isGet()
{
- return get;
+ return bindingCollection.isGet();
}
public boolean isSet()
{
- return set;
+ return bindingCollection.isSet();
}
/**
@@ -1463,8 +1401,7 @@
{
removedBinding = internalRemoveBinding(binding.getName());
affectedAdvisors = removedBinding == null ? null : new HashSet<Advisor>(removedBinding.getAdvisors());
- bindingCollection.add(binding);
- updatePointcutStats(binding.getPointcut());
+ bindingCollection.add(binding, this);
}
synchronized (advisors)
{
@@ -1775,7 +1712,7 @@
PointcutStats stats;
stats = new PointcutStats(declare.getAst(), manager);
stats.matches();
- updateStats(stats);
+ bindingCollection.updateStats(stats);
}
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java 2008-09-11 17:08:37 UTC (rev 78456)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java 2008-09-11 17:34:24 UTC (rev 78457)
@@ -49,7 +49,6 @@
import org.jboss.aop.pointcut.DynamicCFlow;
import org.jboss.aop.pointcut.Pointcut;
import org.jboss.aop.pointcut.PointcutInfo;
-import org.jboss.aop.pointcut.PointcutStats;
import org.jboss.aop.pointcut.Typedef;
import org.jboss.aop.pointcut.ast.ClassExpression;
import org.jboss.aop.util.UnmodifiableEmptyCollections;
@@ -1029,19 +1028,19 @@
parent.setDynamicAOPStrategy(strategy);
}
- @Override
- protected void updatePointcutStats(Pointcut pointcut)
- {
- parent.updatePointcutStats(pointcut);
- }
+// @Override
+// protected void updatePointcutStats(Pointcut pointcut)
+// {
+// parent.updatePointcutStats(pointcut);
+// }
+//
+// @Override
+// protected void updateStats(PointcutStats stats)
+// {
+// parent.updateStats(stats);
+// }
@Override
- protected void updateStats(PointcutStats stats)
- {
- parent.updateStats(stats);
- }
-
- @Override
public boolean isExecution()
{
return parent.isExecution();
@@ -1281,6 +1280,104 @@
}
}
+ @Override
+ public boolean isExecution()
+ {
+ if (super.isExecution())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isExecution();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isConstruction()
+ {
+ if (super.isConstruction())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isConstruction();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isCall()
+ {
+ if (super.isCall())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isCall();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isWithin()
+ {
+ if (super.isWithin())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isWithin();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isWithincode()
+ {
+ if (super.isWithincode())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isWithincode();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isGet()
+ {
+ if (super.isGet())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isGet();
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isSet()
+ {
+ if (super.isSet())
+ {
+ return true;
+ }
+ if (inheritsBindings)
+ {
+ return parent.isSet();
+ }
+ return false;
+ }
+
private <T> Collection<T> unifyCollections(Collection<T> collection1,
Collection<T> collection2, boolean prioritizeFirst)
{
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java 2008-09-11 17:08:37 UTC (rev 78456)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/InstanceDomain.java 2008-09-11 17:34:24 UTC (rev 78457)
@@ -52,7 +52,7 @@
public synchronized void addBinding(AdviceBinding binding)
{
removeBinding(binding.getName());
- bindingCollection.add(binding);
+ bindingCollection.add(binding, this);
super.addPointcut(binding.getPointcut());
if (advisor != null) advisor.newBindingAdded();
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java 2008-09-11 17:08:37 UTC (rev 78456)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java 2008-09-11 17:34:24 UTC (rev 78457)
@@ -29,7 +29,9 @@
import org.jboss.aop.AspectManager;
import org.jboss.aop.pointcut.Pointcut;
+import org.jboss.aop.pointcut.PointcutExpression;
import org.jboss.aop.pointcut.PointcutInfo;
+import org.jboss.aop.pointcut.PointcutStats;
import org.jboss.aop.util.BindingClassifier;
import org.jboss.aop.util.UnmodifiableEmptyCollections;
import org.jboss.aop.util.UnmodifiableLinkedHashMap;
@@ -67,14 +69,13 @@
private volatile LinkedHashMap<String, PointcutInfo> pointcutInfos;
//Pointcut stats
- protected boolean execution = false;
- protected boolean construction = false;
- protected boolean call = false;
- protected boolean within = false;
- protected boolean get = false;
- protected boolean set = false;
- protected boolean withincode = false;
- public static boolean classicOrder = false;
+ private boolean execution = false;
+ private boolean construction = false;
+ private boolean call = false;
+ private boolean within = false;
+ private boolean get = false;
+ private boolean set = false;
+ private boolean withincode = false;
/**
* Constructor.<p>
@@ -376,7 +377,7 @@
/**
* Adds a binding to this collection.
*/
- public void add(AdviceBinding binding)
+ public void add(AdviceBinding binding, AspectManager manager)
{
lockWrite();
try
@@ -389,6 +390,7 @@
addMethodExecution(binding);
addConstructorCall(binding);
addMethodCall(binding);
+ updatePointcutStats(binding.getPointcut(), manager);
}
finally
{
@@ -399,13 +401,14 @@
/**
* Adds a pointcut to this collection
*/
- public void add(Pointcut pointcut)
+ public void add(Pointcut pointcut, AspectManager manager)
{
lockWrite();
try
{
removePointcut(pointcut.getName());
addPointcut(pointcut);
+ updatePointcutStats(pointcut, manager);
}
finally
{
@@ -722,4 +725,62 @@
}
pointcutInfos.put(pointcut.getName(), new PointcutInfo(pointcut, AspectManager.hasTransformationStarted()));
}
+
+ private void updatePointcutStats(Pointcut pointcut, AspectManager manager)
+ {
+ // the following is for performance reasons.
+ if (pointcut instanceof PointcutExpression)
+ {
+ PointcutExpression expr = (PointcutExpression) pointcut;
+ expr.setManager(manager);
+ PointcutStats stats = expr.getStats();
+ updateStats(stats);
+ }
+ else
+ {
+ // can't be sure so set all
+ execution = true;
+ construction = true;
+ call = true;
+ within = true;
+ get = true;
+ set = true;
+ withincode = true;
+ }
+ }
+
+ public void updateStats(PointcutStats stats)
+ {
+ lockWrite();
+ try
+ {
+ if (stats != null)
+ {
+ construction |= stats.isConstruction();
+ execution |= stats.isExecution();
+ call |= stats.isCall();
+ within |= stats.isWithin();
+ get |= stats.isGet();
+ set |= stats.isSet();
+ withincode |= stats.isWithincode();
+ }
+ else
+ {
+ if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Setting all pointcut stats to true");
+ // can't be sure so set all
+ execution = true;
+ construction = true;
+ call = true;
+ within = true;
+ get = true;
+ set = true;
+ withincode = true;
+ }
+ }
+ finally
+ {
+ unlockWrite();
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list