[jboss-cvs] JBossAS SVN: r88267 - in projects/aop/trunk/aop/src: main/java/org/jboss/aop/advice and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed May 6 11:03:54 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-05-06 11:03:54 -0400 (Wed, 06 May 2009)
New Revision: 88267
Added:
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA1.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA2.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA3.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectB.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectC.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/DomainTestCase.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowA.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowB.java
projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowC.java
Modified:
projects/aop/trunk/aop/src/main/java/org/jboss/aop/AspectManager.java
projects/aop/trunk/aop/src/main/java/org/jboss/aop/Domain.java
projects/aop/trunk/aop/src/main/java/org/jboss/aop/GeneratedClassAdvisor.java
projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
projects/aop/trunk/aop/src/main/java/org/jboss/aop/standalone/AOPTransformer.java
Log:
[JBAOP-707] Scoped aop domains need to look at all the scoped aop domains within the classloader domain
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/AspectManager.java 2009-05-06 14:49:09 UTC (rev 88266)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/AspectManager.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -176,7 +176,7 @@
protected static AOPLock lock = new AOPLock();
protected volatile LinkedHashMap<String, ClassMetaDataBinding> classMetaData = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
- protected volatile HashMap<String, DomainDefinition> containers = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
+ protected volatile Map<String, DomainDefinition> containers = UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP;
protected volatile LinkedHashMap<String, PrecedenceDef> precedenceDefs = UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
protected PrecedenceDefEntry[] sortedPrecedenceDefEntries;
protected WeavingStrategy weavingStrategy;
@@ -2073,6 +2073,11 @@
public Object getPerVMAspect(String def, Advisor advisor)
{
+ return getPerVMAspectInternal(def, advisor);
+ }
+
+ protected Object getPerVMAspectInternal(String def, Advisor advisor)
+ {
Object aspect = perVMAspects.get(def);
if (aspect == null)
{
@@ -2742,13 +2747,13 @@
}
protected void initContainersMap()
{
- if (containers == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
+ if (containers == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
{
synchronized(lazyCollectionLock)
{
- if (containers == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
+ if (containers == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
{
- containers = new HashMap<String, DomainDefinition>();
+ containers = new ConcurrentHashMap<String, DomainDefinition>();
}
}
}
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/Domain.java 2009-05-06 14:49:09 UTC (rev 88266)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/Domain.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -79,6 +79,8 @@
protected boolean hasOwnPrecedenceDefs;
protected boolean hasOwnClassMetaData;
private static int sequenceNumber;
+
+ protected DomainSearchStrategy domainSearchStrategy = new DefaultDomainSearchStrategy();
public Domain(AspectManager manager, String name, boolean parentFirst)
{
@@ -88,6 +90,11 @@
manager.addSubDomainByName(this);
}
+ public AspectManager getParent()
+ {
+ return parent;
+ }
+
/**
* Creates the binding collection to be used as the collection by this domain
* @return a {@link DomainClassifiedBindingAndPointcutCollection}
@@ -185,11 +192,6 @@
return super.getBindings();
}
- public boolean hasOwnBindings()
- {
- return hasOwnBindings;
- }
-
@Override
public void addBinding(AdviceBinding binding)
{
@@ -244,11 +246,6 @@
return bindingCollection.getPointcuts();
}
- public boolean hasOwnPointcuts()
- {
- return hasOwnPointcuts;
- }
-
@Override
public void addPointcut(Pointcut pointcut)
{
@@ -288,7 +285,6 @@
@Override
public List<AnnotationIntroduction> getAnnotationIntroductions()
{
-
if (inheritsBindings)
{
List<AnnotationIntroduction> result = new ArrayList<AnnotationIntroduction>();
@@ -296,24 +292,24 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
result.addAll(parent.getAnnotationIntroductions());
- synchronized (annotationIntroductions)
+ synchronized (domainSearchStrategy.synchronizeAnnotationIntroductions())
{
- result = new ArrayList<AnnotationIntroduction>(annotationIntroductions.values());
+ result.addAll(domainSearchStrategy.getAnnotationIntroductions().values());
}
return result;
}
else
{
- synchronized (annotationIntroductions)
+ synchronized (domainSearchStrategy.synchronizeAnnotationIntroductions())
{
- result = new ArrayList<AnnotationIntroduction>(annotationIntroductions.values());
+ result = new ArrayList<AnnotationIntroduction>(domainSearchStrategy.getAnnotationIntroductions().values());
}
result.addAll(parent.getAnnotationIntroductions());
return result;
}
}
- return super.getAnnotationIntroductions();
+ return new ArrayList<AnnotationIntroduction>(domainSearchStrategy.getAnnotationIntroductions().values());
}
@Override
@@ -326,39 +322,34 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getArrayReplacements());
- synchronized (arrayReplacements)
+ synchronized (domainSearchStrategy.synchronizeArrayReplacements())
{
- map.putAll(arrayReplacements);
+ map.putAll(domainSearchStrategy.getArrayReplacements());
}
return map;
}
else
{
- synchronized (arrayReplacements)
+ synchronized (domainSearchStrategy.synchronizeArrayReplacements())
{
- map.putAll(arrayReplacements);
+ map.putAll(domainSearchStrategy.getArrayReplacements());
}
map.putAll(parent.getArrayReplacements());
return map;
}
}
- return super.getArrayReplacements();
+ return domainSearchStrategy.getArrayReplacements();
}
- public boolean hasOwnAnnotationIntroductions()
- {
- return hasOwnAnnotationIntroductions;
- }
-
@Override
public void addAnnotationIntroduction(AnnotationIntroduction pointcut)
{
lock.lockWrite();
try
{
+ super.addAnnotationIntroduction(pointcut);
hasOwnAnnotationIntroductions = true;
- super.addAnnotationIntroduction(pointcut);
}
finally
{
@@ -380,7 +371,7 @@
lock.unlockWrite();
}
}
-
+
@Override
public List<AnnotationIntroduction> getAnnotationOverrides()
{
@@ -391,38 +382,33 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
list.addAll(parent.getAnnotationOverrides());
- synchronized (annotationOverrides)
+ synchronized (domainSearchStrategy.synchronizeAnnotationOverrides())
{
- list.addAll(annotationOverrides.values());
+ list.addAll(domainSearchStrategy.getAnnotationOverrides().values());
}
return list;
}
else
{
- synchronized (annotationOverrides)
+ synchronized (domainSearchStrategy.getAnnotationOverrides())
{
- list.addAll(annotationOverrides.values());
+ list.addAll(domainSearchStrategy.getAnnotationOverrides().values());
}
list.addAll(parent.getAnnotationOverrides());
return list;
}
}
- return super.getAnnotationOverrides();
+ return new ArrayList<AnnotationIntroduction>(domainSearchStrategy.getAnnotationOverrides().values());
}
- public boolean hasOwnAnnotationOverrides()
- {
- return hasOwnAnnotationOverrides;
- }
-
@Override
public void addAnnotationOverride(AnnotationIntroduction pointcut)
{
lock.lockWrite();
try
{
+ super.addAnnotationOverride(pointcut);
hasOwnAnnotationOverrides = true;
- super.addAnnotationOverride(pointcut);
}
finally
{
@@ -455,38 +441,33 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getInterfaceIntroductions());
- synchronized (interfaceIntroductions)
+ synchronized (domainSearchStrategy.synchronizeInterfaceIntroductions())
{
- map.putAll(interfaceIntroductions);
+ map.putAll(domainSearchStrategy.getInterfaceIntroductions());
}
return map;
}
else
{
- synchronized (interfaceIntroductions)
+ synchronized (domainSearchStrategy.synchronizeInterfaceIntroductions())
{
- map.putAll(interfaceIntroductions);
+ map.putAll(domainSearchStrategy.getInterfaceIntroductions());
}
map.putAll(parent.getInterfaceIntroductions());
return map;
}
}
- return super.getInterfaceIntroductions();
+ return domainSearchStrategy.getInterfaceIntroductions();
}
- public boolean hasOwnInterfaceIntroductions()
- {
- return hasOwnInterfaceIntroductions;
- }
-
@Override
public void addInterfaceIntroduction(InterfaceIntroduction pointcut)
{
lock.lockWrite();
try
{
+ super.addInterfaceIntroduction(pointcut);
hasOwnInterfaceIntroductions = true;
- super.addInterfaceIntroduction(pointcut);
}
finally
{
@@ -519,39 +500,34 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getTypedefs());
- synchronized (typedefs)
+ synchronized (domainSearchStrategy.synchronizeTypedefs())
{
- map.putAll(typedefs);
+ map.putAll(domainSearchStrategy.getTypedefs());
}
return map;
}
else
{
- synchronized (typedefs)
+ synchronized (domainSearchStrategy.synchronizeTypedefs())
{
- map.putAll(typedefs);
+ map.putAll(domainSearchStrategy.getTypedefs());
}
map.putAll(parent.getTypedefs());
return map;
}
}
- return super.getTypedefs();
+ return domainSearchStrategy.getTypedefs();
}
- public boolean hasOwnTypedefs()
- {
- return hasOwnTypedefs;
- }
-
@Override
public void addTypedef(Typedef def) throws Exception
{
lock.lockWrite();
try
{
+ super.addTypedef(def);
hasOwnTypedefs = true;
- super.addTypedef(def);
}
finally
{
@@ -583,23 +559,23 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getInterceptorStacks());
- synchronized (interceptorStacks)
+ synchronized (domainSearchStrategy.synchronizeAdviceStacks())
{
- map.putAll(interceptorStacks);
+ map.putAll(domainSearchStrategy.getInterceptorStacks());
}
return map;
}
else
{
- synchronized (interceptorStacks)
+ synchronized (domainSearchStrategy.synchronizeAdviceStacks())
{
- map.putAll(interceptorStacks);
+ map.putAll(domainSearchStrategy.getInterceptorStacks());
}
map.putAll(parent.getInterceptorStacks());
return map;
}
}
- return super.getInterceptorStacks();
+ return domainSearchStrategy.getInterceptorStacks();
}
@Override
@@ -612,23 +588,23 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getClassMetaDataLoaders());
- synchronized (classMetaDataLoaders)
+ synchronized (domainSearchStrategy.synchronizeClassMetaDataLoaders())
{
- map.putAll(classMetaDataLoaders);
+ map.putAll(domainSearchStrategy.getClassMetaDataLoaders());
}
return map;
}
else
{
- synchronized (classMetaDataLoaders)
+ synchronized (domainSearchStrategy.synchronizeClassMetaDataLoaders())
{
- map.putAll(classMetaDataLoaders);
+ map.putAll(domainSearchStrategy.getClassMetaDataLoaders());
}
map.putAll(parent.getClassMetaDataLoaders());
return map;
}
}
- return super.getClassMetaDataLoaders();
+ return domainSearchStrategy.getClassMetaDataLoaders();
}
@Override
@@ -641,23 +617,23 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getCflowStacks());
- synchronized (cflowStacks)
+ synchronized (domainSearchStrategy.synchronizeCFlowStacks())
{
- map.putAll(cflowStacks);
+ map.putAll(domainSearchStrategy.getCflowStacks());
}
return map;
}
else
{
- synchronized (cflowStacks)
+ synchronized (domainSearchStrategy.synchronizeCFlowStacks())
{
- map.putAll(cflowStacks);
+ map.putAll(domainSearchStrategy.getCflowStacks());
}
map.putAll(parent.getCflowStacks());
return map;
}
}
- return super.getCflowStacks();
+ return domainSearchStrategy.getCflowStacks();
}
@Override
@@ -670,23 +646,23 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getDynamicCFlows());
- synchronized (dynamicCFlows)
+ synchronized (domainSearchStrategy.synchronizeDynamicCflows())
{
- map.putAll(dynamicCFlows);
+ map.putAll(domainSearchStrategy.getDynamicCFlows());
}
return map;
}
else
{
- synchronized (dynamicCFlows)
+ synchronized (domainSearchStrategy.synchronizeDynamicCflows())
{
- map.putAll(dynamicCFlows);
+ map.putAll(domainSearchStrategy.getDynamicCFlows());
}
map.putAll(parent.getDynamicCFlows());
return map;
}
}
- return super.getDynamicCFlows();
+ return domainSearchStrategy.getDynamicCFlows();
}
@Override
@@ -699,17 +675,17 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getPerVMAspects());
- synchronized (perVMAspects)
+ synchronized (domainSearchStrategy.getPerVMAspects())
{
- map.putAll(perVMAspects);
+ map.putAll(domainSearchStrategy.getPerVMAspects());
}
return map;
}
else
{
- synchronized (perVMAspects)
+ synchronized (domainSearchStrategy.getPerVMAspects())
{
- map.putAll(perVMAspects);
+ map.putAll(domainSearchStrategy.getPerVMAspects());
}
map.putAll(parent.getPerVMAspects());
return map;
@@ -727,24 +703,19 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
LinkedHashMap<String, PrecedenceDef> map = new LinkedHashMap<String, PrecedenceDef>(parent.getPrecedenceDefs());
- map.putAll(this.precedenceDefs);
+ map.putAll(domainSearchStrategy.getPrecedenceDefs());
return map;
}
else
{
- LinkedHashMap<String, PrecedenceDef> map = new LinkedHashMap<String, PrecedenceDef>(this.precedenceDefs);
+ LinkedHashMap<String, PrecedenceDef> map = new LinkedHashMap<String, PrecedenceDef>(domainSearchStrategy.getPrecedenceDefs());
map.putAll(parent.getPrecedenceDefs());
return map;
}
}
- return super.getPrecedenceDefs();
+ return domainSearchStrategy.getPrecedenceDefs();
}
- public boolean hasOwnPrecedenceDefs()
- {
- return hasOwnPrecedenceDefs;
- }
-
@Override
public void addPrecedence(PrecedenceDef precedenceDef)
{
@@ -769,17 +740,17 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
map.putAll(parent.getClassMetaData());
- synchronized (classMetaData)
+ synchronized (domainSearchStrategy.synchronizeClassMetaData())
{
- map.putAll(classMetaData);
+ map.putAll(domainSearchStrategy.getClassMetaData());
}
return map;
}
else
{
- synchronized (classMetaData)
+ synchronized (domainSearchStrategy.synchronizeClassMetaData())
{
- map.putAll(classMetaData);
+ map.putAll(domainSearchStrategy.getClassMetaData());
}
map.putAll(parent.getClassMetaData());
return map;
@@ -788,11 +759,6 @@
return super.getClassMetaData();
}
- public boolean hasOwnClassMetaData()
- {
- return hasOwnClassMetaData;
- }
-
@Override
public void removeClassMetaData(String name)
{
@@ -828,7 +794,7 @@
factory = parent.getInterceptorFactory(name);
if (factory != null) return factory;
}
- factory = super.getInterceptorFactory(name);
+ factory = domainSearchStrategy.getInterceptorFactory(name);
if (factory != null) return factory;
return parent.getInterceptorFactory(name);
@@ -843,7 +809,7 @@
factory = parent.getAdviceStack(name);
if (factory != null) return factory;
}
- factory = super.getAdviceStack(name);
+ factory = domainSearchStrategy.getAdviceStack(name);
if (factory != null) return factory;
return parent.getAdviceStack(name);
@@ -864,7 +830,7 @@
factory = parent.getPerVMAspect(def, advisor);
if (factory != null) return factory;
}
- factory = super.getPerVMAspect(def, advisor);
+ factory = domainSearchStrategy.getPerVMAspect(def, advisor);
if (factory != null) return factory;
return parent.getPerVMAspect(def, advisor);
@@ -879,7 +845,7 @@
factory = parent.getAspectDefinition(name);
if (factory != null) return factory;
}
- factory = super.getAspectDefinition(name);
+ factory = domainSearchStrategy.getAspectDefinition(name);
if (factory != null) return factory;
return parent.getAspectDefinition(name);
@@ -894,7 +860,7 @@
factory = parent.getTypedef(name);
if (factory != null) return factory;
}
- factory = super.getTypedef(name);
+ factory = domainSearchStrategy.getTypedef(name);
if (factory != null) return factory;
return parent.getTypedef(name);
@@ -909,7 +875,7 @@
container = parent.getContainer(name);
if (container != null) return container;
}
- container = super.getContainer(name);
+ container = domainSearchStrategy.getContainer(name);
if (container != null) return container;
return parent.getContainer(name);
}
@@ -962,7 +928,7 @@
{
if (!parentFirst)
{
- CFlowStack cflow = super.getCFlowStack(name);
+ CFlowStack cflow = domainSearchStrategy.getCFlowStack(name);
if (cflow == null)
{
cflow = parent.getCFlowStack(name);
@@ -974,18 +940,17 @@
CFlowStack cflow = parent.getCFlowStack(name);
if (cflow == null)
{
- cflow = super.getCFlowStack(name);
+ cflow = domainSearchStrategy.getCFlowStack(name);
}
return cflow;
}
}
else
{
- return super.getCFlowStack(name);
+ return domainSearchStrategy.getCFlowStack(name);
}
}
-
@Override
public DynamicCFlow getDynamicCFlow(String name, ClassLoader cl)
{
@@ -993,7 +958,7 @@
{
if (!parentFirst)
{
- DynamicCFlow cflow = super.getDynamicCFlow(name, cl);
+ DynamicCFlow cflow = domainSearchStrategy.getDynamicCFlow(name, cl);
if (cflow == null)
{
cflow = parent.getDynamicCFlow(name, cl);
@@ -1005,14 +970,14 @@
DynamicCFlow cflow = parent.getDynamicCFlow(name, cl);
if (cflow == null)
{
- cflow = super.getDynamicCFlow(name, cl);
+ cflow = domainSearchStrategy.getDynamicCFlow(name, cl);
}
return cflow;
}
}
else
{
- return super.getDynamicCFlow(name, cl);
+ return domainSearchStrategy.getDynamicCFlow(name, cl);
}
}
@@ -1023,7 +988,7 @@
{
if (!parentFirst)
{
- ClassMetaDataLoader loader = super.findClassMetaDataLoader(group);
+ ClassMetaDataLoader loader = domainSearchStrategy.findClassMetaDataLoader(group);
if (loader == null)
{
loader = parent.findClassMetaDataLoader(group);
@@ -1035,13 +1000,13 @@
ClassMetaDataLoader loader = parent.findClassMetaDataLoader(group);
if (loader == null)
{
- loader = super.findClassMetaDataLoader(group);
+ loader = domainSearchStrategy.findClassMetaDataLoader(group);
}
return loader;
}
}
- return super.findClassMetaDataLoader(group);
+ return domainSearchStrategy.findClassMetaDataLoader(group);
}
@Override
@@ -1053,21 +1018,20 @@
{
// when child first, parent bindings go in first so that they can be overridden by child.
LinkedHashMap<String, LifecycleCallbackBinding> map = new LinkedHashMap<String, LifecycleCallbackBinding>(parent.getLifecycleBindings());
- map.putAll(super.getLifecycleBindings());
+ map.putAll(domainSearchStrategy.getLifecycleBindings());
return map;
}
else
{
- LinkedHashMap<String, LifecycleCallbackBinding> map = new LinkedHashMap<String, LifecycleCallbackBinding>(super.getLifecycleBindings());
+ LinkedHashMap<String, LifecycleCallbackBinding> map = new LinkedHashMap<String, LifecycleCallbackBinding>(domainSearchStrategy.getLifecycleBindings());
map.putAll(parent.getLifecycleBindings());
return map;
}
}
- return super.getLifecycleBindings();
+ return domainSearchStrategy.getLifecycleBindings();
}
-
//////////////////////////////////////////////////////////////////////////
//Methods that should delegate to the top AspectManager
@@ -1131,15 +1095,15 @@
parent.setDynamicAOPStrategy(strategy);
}
- private class DomainClassifiedBindingAndPointcutCollection extends ClassifiedBindingAndPointcutCollection
+ public class DomainClassifiedBindingAndPointcutCollection extends ClassifiedBindingAndPointcutCollection
{
@Override
public LinkedHashMap<String, AdviceBinding> getBindings()
{
- LinkedHashMap<String, AdviceBinding> result = super.getBindingsInternal();
+ LinkedHashMap<String, AdviceBinding> result = getBindingsForDomain();
LinkedHashMap<String, AdviceBinding> parentResult =
- inheritsBindings ? parent.getBindingCollection().getBindingsInternal() :
+ inheritsBindings ? parent.getBindingCollection().getBindings() :
UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
LinkedHashMap<String, AdviceBinding> overall = unifyMaps(result, parentResult, parentFirst);
if (overall == result || overall == parentResult)
@@ -1149,13 +1113,18 @@
return overall;
}
+ protected LinkedHashMap<String, AdviceBinding> getBindingsForDomain()
+ {
+ return super.getBindingsInternal();
+ }
+
@Override
public LinkedHashMap<String, Pointcut> getPointcuts()
{
- LinkedHashMap<String, Pointcut> result = super.getPointcutsInternal();
+ LinkedHashMap<String, Pointcut> result = getPointcutsForDomain();
LinkedHashMap<String, Pointcut> parentResult =
inheritsBindings ?
- parent.getBindingCollection().getPointcutsInternal() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+ parent.getBindingCollection().getPointcuts() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
LinkedHashMap<String, Pointcut> overall = unifyMaps(result, parentResult, parentFirst);
if (overall == result || overall == parentResult)
{
@@ -1163,14 +1132,19 @@
}
return overall;
}
+
+ protected LinkedHashMap<String, Pointcut> getPointcutsForDomain()
+ {
+ return super.getPointcutsInternal();
+ }
@Override
public LinkedHashMap<String, PointcutInfo> getPointcutInfos()
{
- LinkedHashMap<String, PointcutInfo> result = super.getPointcutInfosInternal();
+ LinkedHashMap<String, PointcutInfo> result = getPointcutInfosForDomain();
LinkedHashMap<String, PointcutInfo> parentResult =
inheritsBindings ?
- parent.getBindingCollection().getPointcutInfosInternal() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
+ parent.getBindingCollection().getPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP;
LinkedHashMap<String, PointcutInfo> overall = unifyMaps(result, parentResult, parentFirst);
if (overall == result || overall == parentResult)
{
@@ -1179,51 +1153,75 @@
return overall;
}
+ protected LinkedHashMap<String, PointcutInfo> getPointcutInfosForDomain()
+ {
+ return super.getPointcutInfosInternal();
+ }
@Override
public Collection<AdviceBinding> getFieldReadBindings()
{
- Collection<AdviceBinding> result = super.getFieldReadBindings();
+ Collection<AdviceBinding> result = getFieldReadBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ?
parent.getBindingCollection().getFieldReadBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getFieldReadBindingsForDomain()
+ {
+ return super.getFieldReadBindings();
+ }
+
@Override
public Collection<AdviceBinding> getFieldWriteBindings()
{
- Collection<AdviceBinding> result = super.getFieldWriteBindings();
+ Collection<AdviceBinding> result = getFieldWriteBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ? parent.getBindingCollection().getFieldWriteBindings():
UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getFieldWriteBindingsForDomain()
+ {
+ return super.getFieldWriteBindings();
+ }
+
@Override
public Collection<AdviceBinding> getConstructionBindings()
{
- Collection<AdviceBinding> result = super.getConstructionBindings();
+ Collection<AdviceBinding> result = getConstructionBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ? parent.getBindingCollection().getConstructionBindings() :
UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getConstructionBindingsForDomain()
+ {
+ return super.getConstructionBindings();
+ }
+
@Override
public Collection<AdviceBinding> getConstructorExecutionBindings()
{
- Collection<AdviceBinding> result = super.getConstructorExecutionBindings();
+ Collection<AdviceBinding> result = getConstructorExecutionBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructorExecutionBindings() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getConstructorExecutionBindingsForDomain()
+ {
+ return super.getConstructorExecutionBindings();
+ }
+
@Override
public Collection<AdviceBinding> getMethodExecutionBindings()
{
- Collection<AdviceBinding> result = super.getMethodExecutionBindings();
+ Collection<AdviceBinding> result = getMethodExecutionBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ?
parent.getBindingCollection().getMethodExecutionBindings() :
@@ -1231,10 +1229,15 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getMethodExecutionBindingsForDomain()
+ {
+ return super.getMethodExecutionBindings();
+ }
+
@Override
public Collection<AdviceBinding> getConstructorCallBindings()
{
- Collection<AdviceBinding> result = super.getConstructorCallBindings();
+ Collection<AdviceBinding> result = getConstructorCallBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructorCallBindings() :
@@ -1242,10 +1245,15 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getConstructorCallBindingsForDomain()
+ {
+ return super.getConstructorCallBindings();
+ }
+
@Override
public Collection<AdviceBinding> getMethodCallBindings()
{
- Collection<AdviceBinding> result = super.getMethodCallBindings();
+ Collection<AdviceBinding> result = getMethodCallBindingsForDomain();
Collection<AdviceBinding> parentResult =
inheritsBindings ?
parent.getBindingCollection().getMethodCallBindings() :
@@ -1253,19 +1261,29 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<AdviceBinding> getMethodCallBindingsForDomain()
+ {
+ return super.getMethodCallBindings();
+ }
+
public Collection<Pointcut> getFieldReadPointcuts()
{
- Collection<Pointcut> result = super.getFieldReadPointcuts();
+ Collection<Pointcut> result = getFieldReadPointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getFieldReadPointcuts() :
UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
return unifyCollections(result, parentResult, parentFirst);
}
+
+ protected Collection<Pointcut> getFieldReadPointcutsForDomain()
+ {
+ return super.getFieldReadPointcuts();
+ }
public Collection<Pointcut> getFieldWritePointcuts()
{
- Collection<Pointcut> result = super.getFieldWritePointcuts();
+ Collection<Pointcut> result = getFieldWritePointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getFieldWritePointcuts() :
@@ -1273,9 +1291,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<Pointcut> getFieldWritePointcutsForDomain()
+ {
+ return super.getFieldWritePointcuts();
+ }
+
public Collection<Pointcut> getConstructionPointcuts()
{
- Collection<Pointcut> result = super.getConstructionPointcuts();
+ Collection<Pointcut> result = getConstructionPointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructionPointcuts() :
@@ -1283,9 +1306,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<Pointcut> getConstructionPointcutsForDomain()
+ {
+ return super.getConstructionPointcuts();
+ }
+
public Collection<Pointcut> getConstructorExecutionPointcuts()
{
- Collection<Pointcut> result = super.getConstructorExecutionPointcuts();
+ Collection<Pointcut> result = getConstructorExecutionPointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructorExecutionPointcuts() :
@@ -1293,9 +1321,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<Pointcut> getConstructorExecutionPointcutsForDomain()
+ {
+ return super.getConstructorExecutionPointcuts();
+ }
+
public Collection<Pointcut> getMethodExecutionPointcuts()
{
- Collection<Pointcut> result = super.getMethodExecutionPointcuts();
+ Collection<Pointcut> result = getMethodExecutionPointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getMethodExecutionPointcuts() :
@@ -1303,9 +1336,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<Pointcut> getMethodExecutionPointcutsForDomain()
+ {
+ return super.getMethodExecutionPointcuts();
+ }
+
public Collection<Pointcut> getConstructorCallPointcuts()
{
- Collection<Pointcut> result = super.getConstructorCallPointcuts();
+ Collection<Pointcut> result = getConstructorCallPointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructorCallPointcuts() :
@@ -1313,9 +1351,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<Pointcut> getConstructorCallPointcutsForDomain()
+ {
+ return super.getConstructorCallPointcuts();
+ }
+
public Collection<Pointcut> getMethodCallPointcuts()
{
- Collection<Pointcut> result = super.getMethodCallPointcuts();
+ Collection<Pointcut> result = getMethodCallPointcutsForDomain();
Collection<Pointcut> parentResult =
inheritsBindings ?
parent.getBindingCollection().getMethodCallPointcuts() :
@@ -1323,9 +1366,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<Pointcut> getMethodCallPointcutsForDomain()
+ {
+ return super.getMethodCallPointcuts();
+ }
+
public Collection<PointcutInfo> getFieldReadPointcutInfos()
{
- Collection<PointcutInfo> result = super.getFieldReadPointcutInfos();
+ Collection<PointcutInfo> result = getFieldReadPointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getFieldReadPointcutInfos() :
@@ -1333,9 +1381,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getFieldReadPointcutInfosForDomain()
+ {
+ return super.getFieldReadPointcutInfos();
+ }
+
public Collection<PointcutInfo> getFieldWritePointcutInfos()
{
- Collection<PointcutInfo> result = super.getFieldWritePointcutInfos();
+ Collection<PointcutInfo> result = getFieldWritePointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getFieldWritePointcutInfos() :
@@ -1343,9 +1396,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getFieldWritePointcutInfosForDomain()
+ {
+ return super.getFieldWritePointcutInfos();
+ }
+
public Collection<PointcutInfo> getConstructionPointcutInfos()
{
- Collection<PointcutInfo> result = super.getConstructionPointcutInfos();
+ Collection<PointcutInfo> result = getConstructionPointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructionPointcutInfos() :
@@ -1353,9 +1411,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getConstructionPointcutInfosForDomain()
+ {
+ return super.getConstructionPointcutInfos();
+ }
+
public Collection<PointcutInfo> getConstructorExecutionPointcutInfos()
{
- Collection<PointcutInfo> result = super.getConstructorExecutionPointcutInfos();
+ Collection<PointcutInfo> result = getConstructorExecutionPointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructorExecutionPointcutInfos() :
@@ -1363,9 +1426,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getConstructorExecutionPointcutInfosForDomain()
+ {
+ return super.getConstructorExecutionPointcutInfos();
+ }
+
public Collection<PointcutInfo> getMethodExecutionPointcutInfos()
{
- Collection<PointcutInfo> result = super.getMethodExecutionPointcutInfos();
+ Collection<PointcutInfo> result = getMethodExecutionPointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getMethodExecutionPointcutInfos() :
@@ -1373,9 +1441,14 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getMethodExecutionPointcutInfosForDomain()
+ {
+ return super.getMethodExecutionPointcutInfos();
+ }
+
public Collection<PointcutInfo> getConstructorCallPointcutInfos()
{
- Collection<PointcutInfo> result = super.getConstructorCallPointcutInfos();
+ Collection<PointcutInfo> result = getConstructorCallPointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getConstructorCallPointcutInfos() :
@@ -1383,15 +1456,25 @@
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getConstructorCallPointcutInfosForDomain()
+ {
+ return super.getConstructorCallPointcutInfos();
+ }
+
public Collection<PointcutInfo> getMethodCallPointcutInfos()
{
- Collection<PointcutInfo> result = super.getMethodCallPointcutInfos();
+ Collection<PointcutInfo> result = getMethodCallPointcutInfosForDomain();
Collection<PointcutInfo> parentResult =
inheritsBindings ?
parent.getBindingCollection().getMethodCallPointcutInfos() : UnmodifiableEmptyCollections.EMPTY_ARRAYLIST;
return unifyCollections(result, parentResult, parentFirst);
}
+ protected Collection<PointcutInfo> getMethodCallPointcutInfosForDomain()
+ {
+ return super.getMethodCallPointcutInfos();
+ }
+
@Override
public boolean isExecution()
{
@@ -1540,4 +1623,215 @@
return map1;
}
}
+
+ public interface DomainSearchStrategy
+ {
+ Object synchronizeAnnotationIntroductions();
+ Map<String, AnnotationIntroduction> getAnnotationIntroductions();
+ Object synchronizeAnnotationOverrides();
+ Map<String, AnnotationIntroduction> getAnnotationOverrides();
+ Object synchronizeArrayReplacements();
+ Map<String, ArrayReplacement> getArrayReplacements();
+ Object synchronizeInterfaceIntroductions();
+ Map<String, InterfaceIntroduction> getInterfaceIntroductions();
+ Object synchronizeTypedefs();
+ Map<String, Typedef> getTypedefs();
+ Typedef getTypedef(String name);
+ Object synchronizeAdviceStacks();
+ Map<String, AdviceStack> getInterceptorStacks();
+ AdviceStack getAdviceStack(String name);
+ Object synchronizeClassMetaDataLoaders();
+ Map<String, ClassMetaDataLoader> getClassMetaDataLoaders();
+ ClassMetaDataLoader findClassMetaDataLoader(String group);
+ Object synchronizeCFlowStacks();
+ Map<String, CFlowStack> getCflowStacks();
+ CFlowStack getCFlowStack(String name);
+ Object synchronizeDynamicCflows();
+ Map<String, DynamicCFlowDefinition> getDynamicCFlows();
+ DynamicCFlow getDynamicCFlow(String name, ClassLoader cl);
+ Object synchronizePrecedenceDefs();
+ LinkedHashMap<String, PrecedenceDef> getPrecedenceDefs();
+ Object synchronizeClassMetaData();
+ Map<String, ClassMetaDataBinding> getClassMetaData();
+ InterceptorFactory getInterceptorFactory(String name);
+ AspectDefinition getAspectDefinition(String name);
+ DomainDefinition getContainer(String name);
+ Map<String, LifecycleCallbackBinding> getLifecycleBindings();
+ Object synchronizePerVmAspects();
+ Map<String, Object> getPerVMAspects();
+ Object getPerVMAspect(String def, Advisor advisor);
+ }
+
+ class DefaultDomainSearchStrategy implements DomainSearchStrategy
+ {
+ public Object synchronizeAnnotationIntroductions()
+ {
+ return annotationIntroductions;
+ }
+
+ public Map<String, AnnotationIntroduction> getAnnotationIntroductions()
+ {
+ return annotationIntroductions;
+ }
+
+ public Object synchronizeAnnotationOverrides()
+ {
+ return annotationOverrides;
+ }
+
+ public Map<String, AnnotationIntroduction> getAnnotationOverrides()
+ {
+ return annotationOverrides;
+ }
+
+ public Object synchronizeArrayReplacements()
+ {
+ return arrayReplacements;
+ }
+
+ public Map<String, ArrayReplacement> getArrayReplacements()
+ {
+ return arrayReplacements;
+ }
+
+ public Object synchronizeInterfaceIntroductions()
+ {
+ return interfaceIntroductions;
+ }
+
+ public Map<String, InterfaceIntroduction> getInterfaceIntroductions()
+ {
+ return interfaceIntroductions;
+ }
+
+ public Object synchronizeTypedefs()
+ {
+ return typedefs;
+ }
+
+ public Map<String, Typedef> getTypedefs()
+ {
+ return typedefs;
+ }
+
+ public Typedef getTypedef(String name)
+ {
+ return Domain.super.getTypedef(name);
+ }
+
+ public Object synchronizeAdviceStacks()
+ {
+ return interceptorStacks;
+ }
+
+ public Map<String, AdviceStack> getInterceptorStacks()
+ {
+ return interceptorStacks;
+ }
+
+ public AdviceStack getAdviceStack(String name)
+ {
+ return Domain.super.getAdviceStack(name);
+ }
+
+ public Object synchronizeClassMetaDataLoaders()
+ {
+ return classMetaDataLoaders;
+ }
+
+ public Map<String, ClassMetaDataLoader> getClassMetaDataLoaders()
+ {
+ return classMetaDataLoaders;
+ }
+
+ public ClassMetaDataLoader findClassMetaDataLoader(String group)
+ {
+ return Domain.super.findClassMetaDataLoader(group);
+ }
+
+ public Object synchronizeCFlowStacks()
+ {
+ return cflowStacks;
+ }
+
+ public Map<String, CFlowStack> getCflowStacks()
+ {
+ return cflowStacks;
+ }
+
+ public CFlowStack getCFlowStack(String name)
+ {
+ return Domain.super.getCFlowStack(name);
+ }
+
+ public Object synchronizeDynamicCflows()
+ {
+ return dynamicCFlows;
+ }
+
+ public Map<String, DynamicCFlowDefinition> getDynamicCFlows()
+ {
+ return dynamicCFlows;
+ }
+
+ public DynamicCFlow getDynamicCFlow(String name, ClassLoader cl)
+ {
+ return Domain.super.getDynamicCFlow(name, cl);
+ }
+
+ public Object synchronizePrecedenceDefs()
+ {
+ return precedenceDefs;
+ }
+
+ public LinkedHashMap<String, PrecedenceDef> getPrecedenceDefs()
+ {
+ return precedenceDefs;
+ }
+
+ public Object synchronizeClassMetaData()
+ {
+ return classMetaData;
+ }
+
+ public Map<String, ClassMetaDataBinding> getClassMetaData()
+ {
+ return classMetaData;
+ }
+
+ public InterceptorFactory getInterceptorFactory(String name)
+ {
+ return Domain.super.getInterceptorFactory(name);
+ }
+
+ public AspectDefinition getAspectDefinition(String name)
+ {
+ return Domain.super.getAspectDefinition(name);
+ }
+
+ public DomainDefinition getContainer(String name)
+ {
+ return Domain.super.getContainer(name);
+ }
+
+ public Map<String, LifecycleCallbackBinding> getLifecycleBindings()
+ {
+ return lifecycleManager.getLifecycleBindings();
+ }
+
+ public Object synchronizePerVmAspects()
+ {
+ return perVMAspects;
+ }
+
+ public Map<String, Object> getPerVMAspects()
+ {
+ return perVMAspects;
+ }
+
+ public Object getPerVMAspect(String def, Advisor advisor)
+ {
+ return Domain.super.getPerVMAspect(def, advisor);
+ }
+ }
}
\ No newline at end of file
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/GeneratedClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/GeneratedClassAdvisor.java 2009-05-06 14:49:09 UTC (rev 88266)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/GeneratedClassAdvisor.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -133,7 +133,10 @@
//TODO Not really sure what was attempted here
//GeneratedAdvisorDomain manager = (GeneratedAdvisorDomain)it.next();
//Map advisors = manager.getAdvisors();
- it.remove();
+ if (it.next() != null)
+ {
+ it.remove();
+ }
}
}
}
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java 2009-05-06 14:49:09 UTC (rev 88266)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/advice/ClassifiedBindingAndPointcutCollection.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -148,6 +148,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getFieldReadBindingsInternal()
+ {
+ return this.fieldReadBindings;
+ }
+
+ /**
* Returns only the bindings whose pointcuts may match successfully field write
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -161,6 +170,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getFieldWriteBindingsInternal()
+ {
+ return this.fieldWriteBindings;
+ }
+
+ /**
* Returns only the bindings whose pointcuts may match successfully construction
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -174,6 +192,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getConstructionBindingsInternal()
+ {
+ return this.constructionBindings;
+ }
+
+ /**
* Returns only the bindings whose pointcuts may match successfully constructor
* execution joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -187,6 +214,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getConstructorExecutionBindingsInternal()
+ {
+ return this.constructorExecutionBindings;
+ }
+
+ /**
* Returns only the bindings whose pointcuts may match successfully method
* execution joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -200,6 +236,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getMethodExecutionBindingsInternal()
+ {
+ return this.methodExecutionBindings;
+ }
+
+ /**
* Returns only the bindings whose pointcuts may match successfully constructor
* call joinpoints.
* <p>
@@ -214,6 +259,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getConstructorCallBindingsInternal()
+ {
+ return this.constructorCallBindings;
+ }
+
+ /**
* Returns only the bindings whose pointcuts may match successfully method
* call joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -227,6 +281,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<AdviceBinding> getMethodCallBindingsInternal()
+ {
+ return this.methodCallBindings;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully field read
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -240,6 +303,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getFieldReadPointcutsInternal()
+ {
+ return this.fieldReadPointcuts;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully field write
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -253,6 +325,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getFieldWritePointcutsInternal()
+ {
+ return this.fieldWritePointcuts;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully construction
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -266,6 +347,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getConstructionPointcutsInternal()
+ {
+ return this.constructionPointcuts;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully constructor
* execution joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -279,6 +369,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getConstructorExecutionPointcutsInternal()
+ {
+ return this.constructorExecutionPointcuts;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully method
* execution joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -292,6 +391,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getMethodExecutionPointcutsInternal()
+ {
+ return this.methodExecutionPointcuts;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully constructor
* call joinpoints.
* <p>
@@ -306,6 +414,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getConstructorCallPointcutsInternal()
+ {
+ return this.constructorCallPointcuts;
+ }
+
+ /**
* Returns only the pointcuts that may match successfully method
* call joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -319,6 +436,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<Pointcut> getMethodCallPointcutsInternal()
+ {
+ return this.methodCallPointcuts;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully field read
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -332,6 +458,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getFieldReadPointcutInfosInternal()
+ {
+ return this.fieldReadPointcutInfos;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully field write
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -345,6 +480,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getFieldWritePointcutInfosInternal()
+ {
+ return this.fieldWritePointcutInfos;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully construction
* joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -358,6 +502,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getConstructionPointcutInfosInternal()
+ {
+ return this.constructionPointcutInfos;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully constructor
* execution joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -371,6 +524,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getConstructorExecutionPointcutInfosInternal()
+ {
+ return this.constructorExecutionPointcutInfos;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully method
* execution joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -384,6 +546,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getMethodExecutionPointcutInfosInternal()
+ {
+ return this.methodExecutionPointcutInfos;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully constructor
* call joinpoints.
* <p>
@@ -398,6 +569,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getConstructorCallPointcutInfosInternal()
+ {
+ return this.constructorCallPointcutInfos;
+ }
+
+ /**
* Returns only the pointcut infos that may match successfully method
* call joinpoints.<p>
* <b>Attention:</b> this collection is not supposed to be edited.
@@ -411,6 +591,15 @@
}
/**
+ * For internal use only
+ */
+ @Deprecated
+ public Collection<PointcutInfo> getMethodCallPointcutInfosInternal()
+ {
+ return this.methodCallPointcutInfos;
+ }
+
+ /**
* Indicate whether this collection is empty.
*/
public boolean isEmpty()
@@ -502,6 +691,8 @@
}
pointcutInfos.put(pointcutInfo.getPointcut().getName(), pointcutInfo);
+ updatePointcutStats(binding.getPointcut(), manager);
+
addGet(binding, pointcutInfo);
addSet(binding, pointcutInfo);
addConstruction(binding, pointcutInfo);
@@ -509,7 +700,6 @@
addMethodExecution(binding, pointcutInfo);
addConstructorCall(binding, pointcutInfo);
addMethodCall(binding, pointcutInfo);
- updatePointcutStats(binding.getPointcut(), manager);
}
/**
@@ -518,9 +708,9 @@
public void add(Pointcut pointcut, AspectManager manager)
{
removePointcut(pointcut.getName());
- addPointcut(pointcut);
updatePointcutStats(pointcut, manager);
+ addPointcut(pointcut);
}
/**
Modified: projects/aop/trunk/aop/src/main/java/org/jboss/aop/standalone/AOPTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/java/org/jboss/aop/standalone/AOPTransformer.java 2009-05-06 14:49:09 UTC (rev 88266)
+++ projects/aop/trunk/aop/src/main/java/org/jboss/aop/standalone/AOPTransformer.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -90,5 +90,9 @@
{
throw new RuntimeException(e);
}
+ finally
+ {
+ AspectManager.verbose = false;
+ }
}
}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA1.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA1.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA1.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectA1
+{
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA2.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA2.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA2.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectA2
+{
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA3.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA3.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectA3.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectA3
+{
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectB.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectB.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectB.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectB
+{
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectC.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectC.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/AspectC.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,32 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectC
+{
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/DomainTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/DomainTestCase.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/DomainTestCase.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,1009 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.DomainDefinition;
+import org.jboss.aop.advice.AdviceBinding;
+import org.jboss.aop.advice.AdviceStack;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.ClassifiedBindingAndPointcutCollection;
+import org.jboss.aop.advice.DynamicCFlowDefinition;
+import org.jboss.aop.advice.GenericAspectFactory;
+import org.jboss.aop.advice.InterceptorFactory;
+import org.jboss.aop.advice.PrecedenceDef;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aop.advice.ScopedInterceptorFactory;
+import org.jboss.aop.array.ArrayReplacement;
+import org.jboss.aop.introduction.AnnotationIntroduction;
+import org.jboss.aop.introduction.InterfaceIntroduction;
+import org.jboss.aop.metadata.ClassMetaDataBinding;
+import org.jboss.aop.metadata.SimpleClassMetaDataBinding;
+import org.jboss.aop.metadata.SimpleClassMetaDataLoader;
+import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
+import org.jboss.aop.pointcut.CFlowStack;
+import org.jboss.aop.pointcut.Pointcut;
+import org.jboss.aop.pointcut.PointcutInfo;
+import org.jboss.aop.pointcut.Typedef;
+import org.jboss.aop.pointcut.TypedefExpression;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DomainTestCase extends TestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(DomainTestCase.class);
+ }
+
+ public DomainTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testBindingCollectionExecution() throws Exception
+ {
+ Domains domains = new Domains();
+
+ AdviceBinding ex1 = new AdviceBinding("A", "all(PojoA)", null);
+ AdviceBinding ex2 = new AdviceBinding("B", "all(PojoB)", null);
+ AdviceBinding ex3 = new AdviceBinding("C", "all(PojoC)", null);
+ domains.getMain().addBinding(ex1);
+ domains.getMiddle().addBinding(ex2);
+ domains.getBottom().addBinding(ex3);
+ AdviceBinding[] expectedExectutionBindings = new AdviceBinding[] {ex2, ex1, ex3};
+
+ checkAllBindingsAndPointcuts(domains, expectedExectutionBindings);
+ checkFieldReadBindingsAndPointcuts(domains, expectedExectutionBindings);
+ checkFieldWriteBindingsAndPointcuts(domains, expectedExectutionBindings);
+ checkConstructorExecutionBindingsAndPointcuts(domains, expectedExectutionBindings);
+ checkMethodExecutionBindingsAndPointcuts(domains, expectedExectutionBindings);
+
+ AdviceBinding mc1 = new AdviceBinding("MCA", "call(* PojoA->*(..))", null);
+ AdviceBinding mc2 = new AdviceBinding("MCB", "call(* PojoB->*(..))", null);
+ AdviceBinding mc3 = new AdviceBinding("MCC", "call(* PojoC->*(..))", null);
+
+ AdviceBinding cc1 = new AdviceBinding("CCA", "call(PojoA->new(..))", null);
+ AdviceBinding cc2 = new AdviceBinding("CCB", "call(PojoB->new(..))", null);
+ AdviceBinding cc3 = new AdviceBinding("CCC", "call(PojoC->new(..))", null);
+
+ domains.getMain().addBinding(mc1);
+ domains.getMiddle().addBinding(mc2);
+ domains.getBottom().addBinding(mc3);
+
+ domains.getMain().addBinding(cc1);
+ domains.getMiddle().addBinding(cc2);
+ domains.getBottom().addBinding(cc3);
+
+ checkMethodCallBindingsAndPointcuts(domains, new AdviceBinding[] {mc2, mc1, mc3});
+ checkConstructorCallBindingsAndPointcuts(domains, new AdviceBinding[] {cc2, cc1, cc3});
+ }
+
+ private void checkAllBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+ ClassifiedBindingAndPointcutCollection coll = domains.getBottom().getBindingCollection();
+ Map<String, AdviceBinding> allBindings = coll.getBindings();
+ assertEquals(expectedBindings.length, allBindings.size());
+ int i = 0;
+ for (String key : allBindings.keySet())
+ {
+ assertEquals(expectedBindings[i].getName(), key);
+ assertEquals(expectedBindings[i], allBindings.get(key));
+ i++;
+ }
+
+ i = 0;
+ Map<String, Pointcut> allPointcuts = coll.getPointcuts();
+ assertEquals(expectedBindings.length, allPointcuts.size());
+ for (String key : allPointcuts.keySet())
+ {
+ assertEquals(expectedBindings[i].getPointcut(), allPointcuts.get(key));
+ i++;
+ }
+
+ i = 0;
+ Map<String, PointcutInfo> allPointcutInfos = coll.getPointcutInfos();
+ assertEquals(expectedBindings.length, allPointcutInfos.size());
+ for (String key : allPointcutInfos.keySet())
+ {
+ assertEquals(expectedBindings[i].getPointcut(), allPointcutInfos.get(key).getPointcut());
+ i++;
+ }
+ }
+
+ private void checkFieldReadBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+ checkExpectedBindingsAndPointcuts(domains, expectedBindings, new BindingsAndPointcutSetup()
+ {
+ public Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getFieldReadBindings();
+ }
+
+ public Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getFieldReadPointcuts();
+ }
+
+ public Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getFieldReadPointcutInfos();
+ }
+ });
+ }
+
+ private void checkFieldWriteBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+
+ checkExpectedBindingsAndPointcuts(domains, expectedBindings, new BindingsAndPointcutSetup()
+ {
+ public Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getFieldWriteBindings();
+ }
+
+ public Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getFieldWritePointcuts();
+ }
+
+ public Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getFieldWritePointcutInfos();
+ }
+ });
+ }
+
+ private void checkConstructorExecutionBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+
+ checkExpectedBindingsAndPointcuts(domains, expectedBindings, new BindingsAndPointcutSetup()
+ {
+ public Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getConstructorExecutionBindings();
+ }
+
+ public Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getConstructorExecutionPointcuts();
+ }
+
+ public Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getConstructorExecutionPointcutInfos();
+ }
+ });
+ }
+
+ private void checkMethodExecutionBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+ checkExpectedBindingsAndPointcuts(domains, expectedBindings, new BindingsAndPointcutSetup()
+ {
+ public Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getMethodExecutionBindings();
+ }
+
+ public Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getMethodExecutionPointcuts();
+ }
+
+ public Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getMethodExecutionPointcutInfos();
+ }
+ });
+ }
+
+ private void checkMethodCallBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+ checkExpectedBindingsAndPointcuts(domains, expectedBindings, new BindingsAndPointcutSetup()
+ {
+ public Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getMethodCallBindings();
+ }
+
+ public Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getMethodCallPointcuts();
+ }
+
+ public Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getMethodCallPointcutInfos();
+ }
+ });
+ }
+
+
+ private void checkConstructorCallBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings)
+ {
+ checkExpectedBindingsAndPointcuts(domains, expectedBindings, new BindingsAndPointcutSetup()
+ {
+ public Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getConstructorCallBindings();
+ }
+
+ public Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getConstructorCallPointcuts();
+ }
+
+ public Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection)
+ {
+ return collection.getConstructorCallPointcutInfos();
+ }
+ });
+ }
+
+ private void checkExpectedBindingsAndPointcuts(Domains domains, AdviceBinding[] expectedBindings, BindingsAndPointcutSetup setup)
+ {
+ ClassifiedBindingAndPointcutCollection coll = domains.getBottom().getBindingCollection();
+
+ List<AdviceBinding> bindings = collectionToList(setup.bindings(coll));
+ List<Pointcut> pointcuts = collectionToList(setup.pointcuts(coll));
+ List<PointcutInfo> pointcutInfos = collectionToList(setup.pointcutInfos(coll));
+
+ assertEquals(expectedBindings.length, bindings.size());
+ assertEquals(expectedBindings.length, pointcuts.size());
+ assertEquals(expectedBindings.length, pointcutInfos.size());
+
+ for (int i = 0 ; i < expectedBindings.length ; i++)
+ {
+ assertSame(expectedBindings[i], bindings.get(i));
+ assertSame(expectedBindings[i].getPointcut(), pointcuts.get(i));
+ assertSame(expectedBindings[i].getPointcut(), pointcutInfos.get(i).getPointcut());
+ }
+ }
+
+ private interface BindingsAndPointcutSetup
+ {
+ Collection<AdviceBinding> bindings(ClassifiedBindingAndPointcutCollection collection);
+ Collection<Pointcut> pointcuts(ClassifiedBindingAndPointcutCollection collection);
+ Collection<PointcutInfo> pointcutInfos(ClassifiedBindingAndPointcutCollection collection);
+ }
+
+ private <T> List<T> collectionToList(Collection<T> collection)
+ {
+ ArrayList<T> list = new ArrayList<T>();
+ for (T entry : collection)
+ {
+ list.add(entry);
+ }
+ return list;
+ }
+
+ public void testAnnotationIntroductionsAndOverrides()
+ {
+ Domains domains = new Domains();
+
+ AnnotationIntroduction intro1 = AnnotationIntroduction.createClassAnnotationIntroduction("POJO", "@org.acme.Blah1", true);
+ AnnotationIntroduction intro2 = AnnotationIntroduction.createClassAnnotationIntroduction("POJO", "@org.acme.Blah2", true);
+ AnnotationIntroduction intro3 = AnnotationIntroduction.createClassAnnotationIntroduction("POJO", "@org.acme.Blah3", true);
+
+ domains.getMain().addAnnotationIntroduction(intro1);
+ domains.getMain().addAnnotationOverride(intro1);
+
+ Domain domain = domains.getMiddle();
+ domain.addAnnotationIntroduction(intro2);
+ domain.addAnnotationOverride(intro2);
+
+ domain = domains.getBottom();
+ domain.addAnnotationIntroduction(intro3);
+ domain.addAnnotationOverride(intro3);
+
+ //Don't bother checking the order, it's irrelevant
+ List<AnnotationIntroduction> intros = domains.getBottom().getAnnotationIntroductions();
+ assertEquals(3, intros.size());
+ assertTrue(intros.contains(intro1));
+ assertTrue(intros.contains(intro2));
+ assertTrue(intros.contains(intro3));
+
+ List<AnnotationIntroduction> overrides = domains.getBottom().getAnnotationOverrides();
+ assertEquals(3, overrides.size());
+ assertTrue(overrides.contains(intro1));
+ assertTrue(overrides.contains(intro2));
+ assertTrue(overrides.contains(intro3));
+
+ domains.getMain().removeAnnotationIntroduction(intro1);
+ intros = domains.getBottom().getAnnotationIntroductions();
+ assertEquals(2, intros.size());
+ assertTrue(intros.contains(intro2));
+ assertTrue(intros.contains(intro3));
+ domains.getMain().addAnnotationIntroduction(intro1);
+
+ domains.getMain().removeAnnotationOverride(intro1);
+ overrides = domains.getBottom().getAnnotationOverrides();
+ assertEquals(2, overrides.size());
+ assertTrue(overrides.contains(intro2));
+ assertTrue(overrides.contains(intro3));
+ domains.getMain().addAnnotationOverride(intro1);
+
+ domains.getMiddle().removeAnnotationIntroduction(intro2);
+ intros = domains.getBottom().getAnnotationIntroductions();
+ assertEquals(2, intros.size());
+ assertTrue(intros.contains(intro1));
+ assertTrue(intros.contains(intro3));
+
+ domains.getMiddle().removeAnnotationOverride(intro2);
+ overrides = domains.getBottom().getAnnotationOverrides();
+ assertEquals(2, overrides.size());
+ assertTrue(overrides.contains(intro1));
+ assertTrue(overrides.contains(intro3));
+ }
+
+ public void testArrayReplacement()
+ {
+ Domains domains = new Domains();
+
+ ArrayReplacement rep1 = new ArrayReplacement("A", "class(POJO1)");
+ ArrayReplacement rep2 = new ArrayReplacement("B", "class(POJO2)");
+ ArrayReplacement rep3 = new ArrayReplacement("C", "class(POJO3)");
+
+ domains.getMain().addArrayReplacement(rep1);
+ domains.getMiddle().addArrayReplacement(rep2);
+ domains.getBottom().addArrayReplacement(rep3);
+
+ //Don't bother checking the order, it's irrelevant
+ Map<String, ArrayReplacement> reps = domains.getBottom().getArrayReplacements();
+ assertEquals(3, reps.size());
+ assertEquals(rep1, reps.get("A"));
+ assertEquals(rep2, reps.get("B"));
+ assertEquals(rep3, reps.get("C"));
+
+ domains.getMiddle().removeArrayReplacement("B");
+ reps = domains.getBottom().getArrayReplacements();
+ assertEquals(2, reps.size());
+ assertEquals(rep1, reps.get("A"));
+ assertEquals(rep3, reps.get("C"));
+ domains.getMiddle().addArrayReplacement(rep2);
+
+ domains.getMain().removeArrayReplacement("A");
+ reps = domains.getBottom().getArrayReplacements();
+ assertEquals(2, reps.size());
+ assertEquals(rep2, reps.get("B"));
+ assertEquals(rep3, reps.get("C"));
+
+ domains.getBottom().removeArrayReplacement("C");
+ reps = domains.getBottom().getArrayReplacements();
+ assertEquals(1, reps.size());
+ assertEquals(rep2, reps.get("B"));
+ }
+
+ public void testInterfaceIntroductions()
+ {
+ Domains domains = new Domains();
+
+ InterfaceIntroduction intro1 = new InterfaceIntroduction("A", "POJO", new String[] {"X"});
+ InterfaceIntroduction intro2 = new InterfaceIntroduction("B", "POJO", new String[] {"X"});
+ InterfaceIntroduction intro3 = new InterfaceIntroduction("C", "POJO", new String[] {"X"});
+
+ domains.getMain().addInterfaceIntroduction(intro1);
+ domains.getMiddle().addInterfaceIntroduction(intro2);
+ domains.getBottom().addInterfaceIntroduction(intro3);
+
+ Map<String, InterfaceIntroduction> intros = domains.getBottom().getInterfaceIntroductions();
+ assertEquals(3, intros.size());
+ assertEquals(intro1, intros.get("A"));
+ assertEquals(intro2, intros.get("B"));
+ assertEquals(intro3, intros.get("C"));
+
+ domains.getMiddle().removeInterfaceIntroduction("B");
+ intros = domains.getBottom().getInterfaceIntroductions();
+ assertEquals(2, intros.size());
+ assertEquals(intro1, intros.get("A"));
+ assertEquals(intro3, intros.get("C"));
+ domains.getMiddle().addInterfaceIntroduction(intro2);
+
+ domains.getMain().removeInterfaceIntroduction("A");
+ intros = domains.getBottom().getInterfaceIntroductions();
+ assertEquals(2, intros.size());
+ assertEquals(intro2, intros.get("B"));
+ assertEquals(intro3, intros.get("C"));
+
+ domains.getBottom().removeInterfaceIntroduction("C");
+ intros = domains.getBottom().getInterfaceIntroductions();
+ assertEquals(1, intros.size());
+ assertEquals(intro2, intros.get("B"));
+ }
+
+ public void testTypedefs() throws Exception
+ {
+ Domains domains = new Domains();
+
+ Typedef typedef1 = new TypedefExpression("A", "class(POJO)");
+ Typedef typedef2 = new TypedefExpression("B", "class(POJO)");
+ Typedef typedef3 = new TypedefExpression("C", "class(POJO)");
+
+ domains.getMain().addTypedef(typedef1);
+ domains.getMiddle().addTypedef(typedef2);
+ domains.getBottom().addTypedef(typedef3);
+
+ Map<String, Typedef> typedefs = domains.getBottom().getTypedefs();
+ assertEquals(3, typedefs.size());
+ assertEquals(typedef1, typedefs.get("A"));
+ assertEquals(typedef2, typedefs.get("B"));
+ assertEquals(typedef3, typedefs.get("C"));
+
+ assertEquals(typedef1, domains.getMain().getTypedef("A"));
+ assertNull(domains.getMain().getTypedef("B"));
+ assertNull(domains.getMain().getTypedef("C"));
+ assertEquals(typedef1, domains.getMiddle().getTypedef("A"));
+ assertEquals(typedef2, domains.getMiddle().getTypedef("B"));
+ assertNull(domains.getMiddle().getTypedef("C"));
+ assertEquals(typedef1, domains.getBottom().getTypedef("A"));
+ assertEquals(typedef2, domains.getBottom().getTypedef("B"));
+ assertEquals(typedef3, domains.getBottom().getTypedef("C"));
+
+ domains.getMiddle().removeTypedef("B");
+ typedefs = domains.getBottom().getTypedefs();
+ assertEquals(2, typedefs.size());
+ assertEquals(typedef1, typedefs.get("A"));
+ assertEquals(typedef3, typedefs.get("C"));
+ assertEquals(typedef1, domains.getMain().getTypedef("A"));
+ assertNull(domains.getMain().getTypedef("B"));
+ assertNull(domains.getMain().getTypedef("C"));
+ assertEquals(typedef1, domains.getMiddle().getTypedef("A"));
+ assertNull(domains.getMiddle().getTypedef("B"));
+ assertNull(domains.getMiddle().getTypedef("C"));
+ assertEquals(typedef1, domains.getBottom().getTypedef("A"));
+ assertNull(domains.getBottom().getTypedef("B"));
+ assertEquals(typedef3, domains.getBottom().getTypedef("C"));
+ domains.getMiddle().addTypedef(typedef2);
+
+ domains.getMain().removeTypedef("A");
+ typedefs = domains.getBottom().getTypedefs();
+ assertEquals(2, typedefs.size());
+ assertEquals(typedef2, typedefs.get("B"));
+ assertEquals(typedef3, typedefs.get("C"));
+
+ domains.getBottom().removeTypedef("C");
+ typedefs = domains.getBottom().getTypedefs();
+ assertEquals(1, typedefs.size());
+ assertEquals(typedef2, typedefs.get("B"));
+ }
+
+ public void testInterceptorStack()
+ {
+ Domains domains = new Domains();
+
+ AdviceStack stack1 = new AdviceStack("A", null);
+ AdviceStack stack2 = new AdviceStack("B", null);
+ AdviceStack stack3 = new AdviceStack("C", null);
+
+ domains.getMain().addAdviceStack(stack1);
+ domains.getMiddle().addAdviceStack(stack2);
+ domains.getBottom().addAdviceStack(stack3);
+
+ assertEquals(stack1, domains.getMain().getAdviceStack("A"));
+ assertNull(domains.getMain().getAdviceStack("B"));
+ assertNull(domains.getMain().getAdviceStack("C"));
+ assertEquals(stack1, domains.getMiddle().getAdviceStack("A"));
+ assertEquals(stack2, domains.getMiddle().getAdviceStack("B"));
+ assertNull(domains.getMiddle().getAdviceStack("C"));
+ assertEquals(stack1, domains.getBottom().getAdviceStack("A"));
+ assertEquals(stack2, domains.getBottom().getAdviceStack("B"));
+ assertEquals(stack3, domains.getBottom().getAdviceStack("C"));
+ Map<String, AdviceStack> stacks = domains.getBottom().getInterceptorStacks();
+ assertEquals(3, stacks.size());
+ assertEquals(stack1, stacks.get("A"));
+ assertEquals(stack2, stacks.get("B"));
+ assertEquals(stack3, stacks.get("C"));
+
+ domains.getMiddle().removeInterceptorStack("B");
+ assertEquals(stack1, domains.getMain().getAdviceStack("A"));
+ assertNull(domains.getMain().getAdviceStack("B"));
+ assertNull(domains.getMain().getAdviceStack("C"));
+ assertEquals(stack1, domains.getMiddle().getAdviceStack("A"));
+ assertNull(domains.getMiddle().getAdviceStack("B"));
+ assertNull(domains.getMiddle().getAdviceStack("C"));
+ assertEquals(stack1, domains.getBottom().getAdviceStack("A"));
+ assertNull(domains.getBottom().getAdviceStack("B"));
+ assertEquals(stack3, domains.getBottom().getAdviceStack("C"));
+ stacks = domains.getBottom().getInterceptorStacks();
+ assertEquals(2, stacks.size());
+ assertEquals(stack1, stacks.get("A"));
+ assertEquals(stack3, stacks.get("C"));
+ }
+
+ public void testClassMetaDataLoaders()
+ {
+ Domains domains = new Domains();
+
+ SimpleClassMetaDataLoader simple1 = new SimpleClassMetaDataLoader();
+ SimpleClassMetaDataLoader simple2 = new SimpleClassMetaDataLoader();
+ SimpleClassMetaDataLoader simple3 = new SimpleClassMetaDataLoader();
+
+ domains.getMain().addClassMetaDataLoader("A", simple1);
+ domains.getMiddle().addClassMetaDataLoader("B", simple2);
+ domains.getBottom().addClassMetaDataLoader("C", simple3);
+
+ assertEquals(simple1, domains.getBottom().getClassMetaDataLoaders().get("A"));
+ assertEquals(simple2, domains.getBottom().getClassMetaDataLoaders().get("B"));
+ assertEquals(simple3, domains.getBottom().getClassMetaDataLoaders().get("C"));
+ assertEquals(simple1, domains.getMiddle().getClassMetaDataLoaders().get("A"));
+ assertEquals(simple2, domains.getMiddle().getClassMetaDataLoaders().get("B"));
+ assertNull(domains.getMiddle().getClassMetaDataLoaders().get("C"));
+ assertEquals(simple1, domains.getMain().getClassMetaDataLoaders().get("A"));
+ assertNull(domains.getMain().getClassMetaDataLoaders().get("B"));
+ assertNull(domains.getMain().getClassMetaDataLoaders().get("C"));
+
+ domains.getMiddle().removeClassMetaDataLoader("B");
+ assertEquals(simple1, domains.getMain().getClassMetaDataLoaders().get("A"));
+ assertNull(domains.getMain().getClassMetaDataLoaders().get("B"));
+ assertNull(domains.getMain().getClassMetaDataLoaders().get("C"));
+ assertEquals(simple1, domains.getMiddle().getClassMetaDataLoaders().get("A"));
+ assertNull(domains.getMiddle().getClassMetaDataLoaders().get("B"));
+ assertNull(domains.getMiddle().getClassMetaDataLoaders().get("C"));
+ assertEquals(simple1, domains.getBottom().getClassMetaDataLoaders().get("A"));
+ assertNull(domains.getBottom().getClassMetaDataLoaders().get("B"));
+ assertEquals(simple3, domains.getBottom().getClassMetaDataLoaders().get("C"));
+ }
+
+ public void testCflowStacks()
+ {
+ Domains domains = new Domains();
+
+ CFlowStack stack1 = new CFlowStack("A");
+ CFlowStack stack2 = new CFlowStack("B");
+ CFlowStack stack3 = new CFlowStack("C");
+
+ domains.getMain().addCFlowStack(stack1);
+ domains.getMiddle().addCFlowStack(stack2);
+ domains.getBottom().addCFlowStack(stack3);
+
+ assertEquals(stack1, domains.getMain().getCflowStacks().get("A"));
+ assertNull(domains.getMain().getCflowStacks().get("B"));
+ assertNull(domains.getMain().getCflowStacks().get("C"));
+ assertEquals(stack1, domains.getMain().getCFlowStack("A"));
+ assertNull(domains.getMain().getCFlowStack("B"));
+ assertNull(domains.getMain().getCFlowStack("C"));
+ assertEquals(stack1, domains.getMiddle().getCflowStacks().get("A"));
+ assertEquals(stack2, domains.getMiddle().getCflowStacks().get("B"));
+ assertNull(domains.getMiddle().getCflowStacks().get("C"));
+ assertEquals(stack1, domains.getMiddle().getCFlowStack("A"));
+ assertEquals(stack2, domains.getMiddle().getCFlowStack("B"));
+ assertNull(domains.getMiddle().getCFlowStack("C"));
+ assertEquals(stack1, domains.getBottom().getCflowStacks().get("A"));
+ assertEquals(stack2, domains.getBottom().getCflowStacks().get("B"));
+ assertEquals(stack3, domains.getBottom().getCflowStacks().get("C"));
+ assertEquals(stack1, domains.getBottom().getCFlowStack("A"));
+ assertEquals(stack2, domains.getBottom().getCFlowStack("B"));
+ assertEquals(stack3, domains.getBottom().getCFlowStack("C"));
+
+ domains.getMiddle().removeCFlowStack("B");
+ assertEquals(stack1, domains.getMain().getCflowStacks().get("A"));
+ assertNull(domains.getMain().getCflowStacks().get("B"));
+ assertNull(domains.getMain().getCflowStacks().get("C"));
+ assertEquals(stack1, domains.getMain().getCFlowStack("A"));
+ assertNull(domains.getMain().getCFlowStack("B"));
+ assertNull(domains.getMain().getCFlowStack("C"));
+ assertEquals(stack1, domains.getMiddle().getCflowStacks().get("A"));
+ assertNull(domains.getMiddle().getCflowStacks().get("B"));
+ assertNull(domains.getMiddle().getCflowStacks().get("C"));
+ assertEquals(stack1, domains.getMiddle().getCFlowStack("A"));
+ assertNull(domains.getMiddle().getCFlowStack("B"));
+ assertNull(domains.getMiddle().getCFlowStack("C"));
+ assertEquals(stack1, domains.getBottom().getCflowStacks().get("A"));
+ assertNull(domains.getBottom().getCflowStacks().get("B"));
+ assertEquals(stack3, domains.getBottom().getCflowStacks().get("C"));
+ assertEquals(stack1, domains.getBottom().getCFlowStack("A"));
+ assertNull(domains.getBottom().getCFlowStack("B"));
+ assertEquals(stack3, domains.getBottom().getCFlowStack("C"));
+ }
+
+ public void testDynamicCflows()
+ {
+ Domains domains = new Domains();
+
+ DynamicCFlowDefinition stack1 = new DynamicCFlowDefinition(null, MockDynamicCFlowA.class.getName(), "A");
+ DynamicCFlowDefinition stack2 = new DynamicCFlowDefinition(null, MockDynamicCFlowB.class.getName(), "B");
+ DynamicCFlowDefinition stack3 = new DynamicCFlowDefinition(null, MockDynamicCFlowC.class.getName(), "C");
+
+ domains.getMain().addDynamicCFlow("A", stack1);
+ domains.getMiddle().addDynamicCFlow("B", stack2);
+ domains.getBottom().addDynamicCFlow("C", stack3);
+
+ assertEquals(MockDynamicCFlowA.class, domains.getMain().getDynamicCFlow("A").getClass());
+ assertNull(domains.getMain().getDynamicCFlow("B"));
+ assertNull(domains.getMain().getDynamicCFlow("C"));
+ assertEquals(stack1, domains.getMain().getDynamicCFlows().get("A"));
+ assertNull(domains.getMain().getDynamicCFlows().get("B"));
+ assertNull(domains.getMain().getDynamicCFlows().get("C"));
+ assertEquals(MockDynamicCFlowA.class, domains.getMiddle().getDynamicCFlow("A").getClass());
+ assertEquals(MockDynamicCFlowB.class, domains.getMiddle().getDynamicCFlow("B").getClass());
+ assertNull(domains.getMiddle().getDynamicCFlow("C"));
+ assertEquals(stack1, domains.getMiddle().getDynamicCFlows().get("A"));
+ assertEquals(stack2, domains.getMiddle().getDynamicCFlows().get("B"));
+ assertNull(domains.getMiddle().getDynamicCFlows().get("C"));
+ assertEquals(MockDynamicCFlowA.class, domains.getBottom().getDynamicCFlow("A").getClass());
+ assertEquals(MockDynamicCFlowB.class, domains.getBottom().getDynamicCFlow("B").getClass());
+ assertEquals(MockDynamicCFlowC.class, domains.getBottom().getDynamicCFlow("C").getClass());
+ assertEquals(stack1, domains.getBottom().getDynamicCFlows().get("A"));
+ assertEquals(stack2, domains.getBottom().getDynamicCFlows().get("B"));
+ assertEquals(stack3, domains.getBottom().getDynamicCFlows().get("C"));
+
+ domains.getMiddle().removeDynamicCFlow("B");
+ assertEquals(MockDynamicCFlowA.class, domains.getMain().getDynamicCFlow("A").getClass());
+ assertNull(domains.getMain().getDynamicCFlow("B"));
+ assertNull(domains.getMain().getDynamicCFlow("C"));
+ assertEquals(stack1, domains.getMain().getDynamicCFlows().get("A"));
+ assertNull(domains.getMain().getDynamicCFlows().get("B"));
+ assertNull(domains.getMain().getDynamicCFlows().get("C"));
+ assertEquals(MockDynamicCFlowA.class, domains.getMiddle().getDynamicCFlow("A").getClass());
+ assertNull(domains.getMiddle().getDynamicCFlow("B"));
+ assertNull(domains.getMiddle().getDynamicCFlow("C"));
+ assertEquals(stack1, domains.getMiddle().getDynamicCFlows().get("A"));
+ assertNull(domains.getMiddle().getDynamicCFlows().get("B"));
+ assertNull(domains.getMiddle().getDynamicCFlows().get("C"));
+ assertEquals(MockDynamicCFlowA.class, domains.getBottom().getDynamicCFlow("A").getClass());
+ assertNull(domains.getBottom().getDynamicCFlow("B"));
+ assertEquals(MockDynamicCFlowC.class, domains.getBottom().getDynamicCFlow("C").getClass());
+ assertEquals(stack1, domains.getBottom().getDynamicCFlows().get("A"));
+ assertNull(domains.getBottom().getDynamicCFlows().get("B"));
+ assertEquals(stack3, domains.getBottom().getDynamicCFlows().get("C"));
+ }
+
+ public void testPrecedenceDefs()
+ {
+ Domains domains = new Domains();
+
+ PrecedenceDef def1 = new PrecedenceDef("A", null);
+ PrecedenceDef def2 = new PrecedenceDef("B", null);
+ PrecedenceDef def3 = new PrecedenceDef("C", null);
+
+ domains.getMain().addPrecedence(def1);
+ domains.getMiddle().addPrecedence(def2);
+ domains.getBottom().addPrecedence(def3);
+
+ Map<String, PrecedenceDef> defs = domains.getBottom().getPrecedenceDefs();
+ assertEquals(3, defs.size());
+ assertEquals(def1, defs.get("A"));
+ assertEquals(def2, defs.get("B"));
+ assertEquals(def3, defs.get("C"));
+
+ domains.getMiddle().removePrecedence("B");
+ defs = domains.getBottom().getPrecedenceDefs();
+ assertEquals(2, defs.size());
+ assertEquals(def1, defs.get("A"));
+ assertEquals(def3, defs.get("C"));
+ domains.getMiddle().addPrecedence(def2);
+
+ domains.getMain().removePrecedence("A");
+ defs = domains.getBottom().getPrecedenceDefs();
+ assertEquals(2, defs.size());
+ assertEquals(def2, defs.get("B"));
+ assertEquals(def3, defs.get("C"));
+
+ domains.getBottom().removePrecedence("C");
+ defs = domains.getBottom().getPrecedenceDefs();
+ assertEquals(1, defs.size());
+ assertEquals(def2, defs.get("B"));
+ }
+
+ public void testClassMetaData()
+ {
+ Domains domains = new Domains();
+
+ ClassMetaDataBinding binding1 = new SimpleClassMetaDataBinding(new SimpleClassMetaDataLoader(), "A", "A", "A");
+ ClassMetaDataBinding binding2 = new SimpleClassMetaDataBinding(new SimpleClassMetaDataLoader(), "B", "B", "B");
+ ClassMetaDataBinding binding3 = new SimpleClassMetaDataBinding(new SimpleClassMetaDataLoader(), "C", "C", "C");
+
+ domains.getMain().addClassMetaData(binding1);
+ domains.getMiddle().addClassMetaData(binding2);
+ domains.getBottom().addClassMetaData(binding3);
+
+ Map<String, ClassMetaDataBinding> bindings = domains.getBottom().getClassMetaData();
+ assertEquals(3, bindings.size());
+ assertEquals(binding1, bindings.get("A"));
+ assertEquals(binding2, bindings.get("B"));
+ assertEquals(binding3, bindings.get("C"));
+
+ domains.getMiddle().removeClassMetaData("B");
+ bindings = domains.getBottom().getClassMetaData();
+ assertEquals(2, bindings.size());
+ assertEquals(binding1, bindings.get("A"));
+ assertEquals(binding3, bindings.get("C"));
+ domains.getMiddle().addClassMetaData(binding2);
+
+ domains.getMain().removeClassMetaData("A");
+ bindings = domains.getBottom().getClassMetaData();
+ assertEquals(2, bindings.size());
+ assertEquals(binding2, bindings.get("B"));
+ assertEquals(binding3, bindings.get("C"));
+
+ domains.getBottom().removeClassMetaData("C");
+ bindings = domains.getBottom().getClassMetaData();
+ assertEquals(1, bindings.size());
+ assertEquals(binding2, bindings.get("B"));
+ }
+
+ public void testInterceptorFactory()
+ {
+ Domains domains = new Domains();
+
+ InterceptorFactory fac1 = new ScopedInterceptorFactory(new AspectDefinition("A", Scope.PER_VM, new GenericAspectFactory("Foo", null)));
+ InterceptorFactory fac2 = new ScopedInterceptorFactory(new AspectDefinition("B", Scope.PER_VM, new GenericAspectFactory("Foo", null)));
+ InterceptorFactory fac3 = new ScopedInterceptorFactory(new AspectDefinition("C", Scope.PER_VM, new GenericAspectFactory("Foo", null)));
+
+ domains.getMain().addInterceptorFactory("A", fac1);
+ domains.getMiddle().addInterceptorFactory("B", fac2);
+ domains.getBottom().addInterceptorFactory("C", fac3);
+
+ assertEquals(fac1, domains.getMain().getInterceptorFactory("A"));
+ assertNull(domains.getMain().getInterceptorFactory("B"));
+ assertNull(domains.getMain().getInterceptorFactory("C"));
+ assertEquals(fac1, domains.getMiddle().getInterceptorFactory("A"));
+ assertEquals(fac2, domains.getMiddle().getInterceptorFactory("B"));
+ assertNull(domains.getMiddle().getInterceptorFactory("C"));
+ assertEquals(fac1, domains.getBottom().getInterceptorFactory("A"));
+ assertEquals(fac2, domains.getBottom().getInterceptorFactory("B"));
+ assertEquals(fac3, domains.getBottom().getInterceptorFactory("C"));
+
+ domains.getMiddle().removeInterceptorFactory("B");
+ assertEquals(fac1, domains.getMain().getInterceptorFactory("A"));
+ assertNull(domains.getMain().getInterceptorFactory("B"));
+ assertNull(domains.getMain().getInterceptorFactory("C"));
+ assertEquals(fac1, domains.getMiddle().getInterceptorFactory("A"));
+ assertNull(domains.getMiddle().getInterceptorFactory("B"));
+ assertNull(domains.getMiddle().getInterceptorFactory("C"));
+ assertEquals(fac1, domains.getBottom().getInterceptorFactory("A"));
+ assertNull(domains.getBottom().getInterceptorFactory("B"));
+ assertEquals(fac3, domains.getBottom().getInterceptorFactory("C"));
+ }
+
+ public void testAspectDefinition()
+ {
+ Domains domains = new Domains();
+
+ AspectDefinition def1 = new AspectDefinition("A", Scope.PER_VM, new GenericAspectFactory("Foo", null));
+ AspectDefinition def2 = new AspectDefinition("B", Scope.PER_VM, new GenericAspectFactory("Foo", null));
+ AspectDefinition def3 = new AspectDefinition("C", Scope.PER_VM, new GenericAspectFactory("Foo", null));
+
+ domains.getMain().addAspectDefinition(def1);
+ domains.getMiddle().addAspectDefinition(def2);
+ domains.getBottom().addAspectDefinition(def3);
+
+ assertEquals(def1, domains.getMain().getAspectDefinition("A"));
+ assertNull(domains.getMain().getAspectDefinition("B"));
+ assertNull(domains.getMain().getAspectDefinition("C"));
+ assertEquals(def1, domains.getMiddle().getAspectDefinition("A"));
+ assertEquals(def2, domains.getMiddle().getAspectDefinition("B"));
+ assertNull(domains.getMiddle().getAspectDefinition("C"));
+ assertEquals(def1, domains.getBottom().getAspectDefinition("A"));
+ assertEquals(def2, domains.getBottom().getAspectDefinition("B"));
+ assertEquals(def3, domains.getBottom().getAspectDefinition("C"));
+
+ domains.getMiddle().removeAspectDefinition("B");
+ assertEquals(def1, domains.getMain().getAspectDefinition("A"));
+ assertNull(domains.getMain().getAspectDefinition("B"));
+ assertNull(domains.getMain().getAspectDefinition("C"));
+ assertEquals(def1, domains.getMiddle().getAspectDefinition("A"));
+ assertNull(domains.getMiddle().getAspectDefinition("B"));
+ assertNull(domains.getMiddle().getAspectDefinition("C"));
+ assertEquals(def1, domains.getBottom().getAspectDefinition("A"));
+ assertNull(domains.getBottom().getAspectDefinition("B"));
+ assertEquals(def3, domains.getBottom().getAspectDefinition("C"));
+ }
+
+ public void testDomainDefinition()
+ {
+ Domains domains = new Domains();
+
+ DomainDefinition def1 = new DomainDefinition("A", domains.getMain(), true, true, true);
+ DomainDefinition def2 = new DomainDefinition("B", domains.getMiddle(), true, true, true);
+ DomainDefinition def3 = new DomainDefinition("C", domains.getBottom(), true, true, true);
+
+ domains.getMain().addContainer(def1);
+ domains.getMiddle().addContainer(def2);
+ domains.getBottom().addContainer(def3);
+
+ assertEquals(def1, domains.getMain().getContainer("A"));
+ assertNull(domains.getMain().getContainer("B"));
+ assertNull(domains.getMain().getContainer("C"));
+ assertEquals(def1, domains.getMiddle().getContainer("A"));
+ assertEquals(def2, domains.getMiddle().getContainer("B"));
+ assertNull(domains.getMiddle().getContainer("C"));
+ assertEquals(def1, domains.getBottom().getContainer("A"));
+ assertEquals(def2, domains.getBottom().getContainer("B"));
+ assertEquals(def3, domains.getBottom().getContainer("C"));
+
+ domains.getMiddle().removeContainer("B");
+ assertEquals(def1, domains.getMain().getContainer("A"));
+ assertNull(domains.getMain().getContainer("B"));
+ assertNull(domains.getMain().getContainer("C"));
+ assertEquals(def1, domains.getMiddle().getContainer("A"));
+ assertNull(domains.getMiddle().getContainer("B"));
+ assertNull(domains.getMiddle().getContainer("C"));
+ assertEquals(def1, domains.getBottom().getContainer("A"));
+ assertNull(domains.getBottom().getContainer("B"));
+ assertEquals(def3, domains.getBottom().getContainer("C"));
+ }
+
+ public void testLifecycleCallbacks() throws Exception
+ {
+ Domains domains = new Domains();
+
+ LifecycleCallbackBinding binding1 = new LifecycleCallbackBinding("A", "x", null, null);
+ LifecycleCallbackBinding binding2 = new LifecycleCallbackBinding("B", "x", null, null);
+ LifecycleCallbackBinding binding3 = new LifecycleCallbackBinding("C", "x", null, null);
+
+ domains.getMain().addLifecycleBinding(binding1);
+ domains.getMiddle().addLifecycleBinding(binding2);
+ domains.getBottom().addLifecycleBinding(binding3);
+
+ assertEquals(binding1, domains.getMain().getLifecycleBindings().get("A"));
+ assertNull(domains.getMain().getLifecycleBindings().get("B"));
+ assertNull(domains.getMain().getLifecycleBindings().get("C"));
+ assertEquals(binding1, domains.getMiddle().getLifecycleBindings().get("A"));
+ assertEquals(binding2, domains.getMiddle().getLifecycleBindings().get("B"));
+ assertNull(domains.getMiddle().getLifecycleBindings().get("C"));
+ assertEquals(binding1, domains.getBottom().getLifecycleBindings().get("A"));
+ assertEquals(binding2, domains.getBottom().getLifecycleBindings().get("B"));
+ assertEquals(binding3, domains.getBottom().getLifecycleBindings().get("C"));
+
+ domains.getMiddle().removeLifecycleBinding("B");
+ assertEquals(binding1, domains.getMain().getLifecycleBindings().get("A"));
+ assertNull(domains.getMain().getLifecycleBindings().get("B"));
+ assertNull(domains.getMain().getLifecycleBindings().get("C"));
+ assertEquals(binding1, domains.getMiddle().getLifecycleBindings().get("A"));
+ assertNull(domains.getMiddle().getLifecycleBindings().get("B"));
+ assertNull(domains.getMiddle().getLifecycleBindings().get("C"));
+ assertEquals(binding1, domains.getBottom().getLifecycleBindings().get("A"));
+ assertNull(domains.getBottom().getLifecycleBindings().get("B"));
+ assertEquals(binding3, domains.getBottom().getLifecycleBindings().get("C"));
+ }
+
+ public void testPerVmAspects()
+ {
+ Domains domains = new Domains();
+
+ AspectDefinition defA1 = new AspectDefinition("A", Scope.PER_VM, new GenericAspectFactory(AspectA1.class.getName(), null));
+ AspectDefinition defA2 = new AspectDefinition("A", Scope.PER_VM, new GenericAspectFactory(AspectA2.class.getName(), null));
+ AspectDefinition defA3 = new AspectDefinition("A", Scope.PER_VM, new GenericAspectFactory(AspectA3.class.getName(), null));
+ AspectDefinition defB = new AspectDefinition("B", Scope.PER_VM, new GenericAspectFactory(AspectB.class.getName(), null));
+ AspectDefinition defC = new AspectDefinition("C", Scope.PER_VM, new GenericAspectFactory(AspectC.class.getName(), null));
+
+ domains.getMain().addAspectDefinition(defA1);
+ domains.getMiddle().addAspectDefinition(defA2);
+ domains.getMiddle().addAspectDefinition(defB);
+ domains.getBottom().addAspectDefinition(defA3);
+ domains.getBottom().addAspectDefinition(defC);
+
+ assertPerVmAspect(AspectA1.class, domains.getMain().getPerVMAspect("A", null));
+ assertNull(domains.getMain().getPerVMAspect("B", null));
+ assertNull(domains.getMain().getPerVMAspect("C", null));
+ assertPerVmAspect(AspectA1.class, domains.getMiddle().getPerVMAspect("A", null));
+ assertPerVmAspect(AspectB.class, domains.getMiddle().getPerVMAspect("B", null));
+ assertNull(domains.getMiddle().getPerVMAspect("C", null));
+ assertPerVmAspect(AspectA3.class, domains.getBottom().getPerVMAspect("A", null));
+ assertPerVmAspect(AspectB.class, domains.getBottom().getPerVMAspect("B", null));
+ assertPerVmAspect(AspectC.class, domains.getBottom().getPerVMAspect("C", null));
+
+ Map<String, Object> perVmAspects = domains.getMain().getPerVMAspects();
+ assertEquals(1, perVmAspects.size());
+ assertPerVmAspect(AspectA1.class, perVmAspects.get("A"));
+ perVmAspects = domains.getMiddle().getPerVMAspects();
+ assertEquals(2, perVmAspects.size());
+ assertPerVmAspect(AspectA1.class, perVmAspects.get("A"));
+ assertPerVmAspect(AspectB.class, perVmAspects.get("B"));
+ perVmAspects = domains.getBottom().getPerVMAspects();
+ assertEquals(3, perVmAspects.size());
+ assertPerVmAspect(AspectA3.class, perVmAspects.get("A"));
+ assertPerVmAspect(AspectB.class, perVmAspects.get("B"));
+ assertPerVmAspect(AspectC.class, perVmAspects.get("C"));
+
+ domains.getMiddle().removeAspectDefinition("A");
+ domains.getMiddle().removeAspectDefinition("B");
+
+ assertPerVmAspect(AspectA1.class, domains.getMain().getPerVMAspect("A", null));
+ assertNull(domains.getMain().getPerVMAspect("B", null));
+ assertNull(domains.getMain().getPerVMAspect("C", null));
+ assertPerVmAspect(AspectA1.class, domains.getMiddle().getPerVMAspect("A", null));
+ assertNull(domains.getMiddle().getPerVMAspect("B", null));
+ assertNull(domains.getMiddle().getPerVMAspect("C", null));
+ assertPerVmAspect(AspectA3.class, domains.getBottom().getPerVMAspect("A", null));
+ assertNull(domains.getBottom().getPerVMAspect("B", null));
+ assertPerVmAspect(AspectC.class, domains.getBottom().getPerVMAspect("C", null));
+
+ perVmAspects = domains.getMain().getPerVMAspects();
+ assertEquals(1, perVmAspects.size());
+ assertPerVmAspect(AspectA1.class, perVmAspects.get("A"));
+ perVmAspects = domains.getMiddle().getPerVMAspects();
+ assertEquals(1, perVmAspects.size());
+ assertPerVmAspect(AspectA1.class, perVmAspects.get("A"));
+ perVmAspects = domains.getBottom().getPerVMAspects();
+ assertEquals(2, perVmAspects.size());
+ assertPerVmAspect(AspectA3.class, perVmAspects.get("A"));
+ assertPerVmAspect(AspectC.class, perVmAspects.get("C"));
+
+ domains.getBottom().removeAspectDefinition("A");
+ domains.getBottom().removeAspectDefinition("C");
+
+ assertPerVmAspect(AspectA1.class, domains.getMain().getPerVMAspect("A", null));
+ assertNull(domains.getMain().getPerVMAspect("B", null));
+ assertNull(domains.getMain().getPerVMAspect("C", null));
+ assertPerVmAspect(AspectA1.class, domains.getMiddle().getPerVMAspect("A", null));
+ assertNull(domains.getMiddle().getPerVMAspect("B", null));
+ assertNull(domains.getMiddle().getPerVMAspect("C", null));
+ assertPerVmAspect(AspectA1.class, domains.getBottom().getPerVMAspect("A", null));
+ assertNull(domains.getBottom().getPerVMAspect("B", null));
+ assertNull(domains.getBottom().getPerVMAspect("C", null));
+ }
+
+ private void assertPerVmAspect(Class<?> expected, Object aspect)
+ {
+ assertNotNull(aspect);
+ assertEquals(expected, aspect.getClass());
+ }
+
+ private static class Domains
+ {
+ Domain main;
+ Domain middle;
+ Domain bottom;
+
+ Domains()
+ {
+ main = new Domain(AspectManager.instance(), "Main", true);
+ middle = new Domain(main, "middle", true);
+ middle.setInheritsBindings(true);
+ middle.setInheritsBindings(true);
+ bottom = new Domain(middle, "bottom", false);
+ bottom.setInheritsBindings(true);
+ bottom.setInheritsBindings(true);
+ }
+
+ AspectManager getMain()
+ {
+ return main;
+ }
+
+ Domain getMiddle()
+ {
+ return middle;
+ }
+
+ Domain getBottom()
+ {
+ return bottom;
+ }
+
+ }
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowA.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowA.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowA.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.pointcut.DynamicCFlow;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockDynamicCFlowA implements DynamicCFlow
+{
+ public boolean shouldExecute(Invocation invocation)
+ {
+ return false;
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowB.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowB.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowB.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.pointcut.DynamicCFlow;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockDynamicCFlowB implements DynamicCFlow
+{
+
+ public boolean shouldExecute(Invocation invocation)
+ {
+ return false;
+ }
+
+}
Added: projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowC.java
===================================================================
--- projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowC.java (rev 0)
+++ projects/aop/trunk/aop/src/test/java/org/jboss/test/aop/unit/domain/MockDynamicCFlowC.java 2009-05-06 15:03:54 UTC (rev 88267)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.unit.domain;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.pointcut.DynamicCFlow;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockDynamicCFlowC implements DynamicCFlow
+{
+
+ public boolean shouldExecute(Invocation invocation)
+ {
+ return false;
+ }
+
+}
More information about the jboss-cvs-commits
mailing list