[jboss-cvs] JBossAS SVN: r69532 - in projects/aop/trunk: aop/src/main/org/jboss/aop/advice and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 1 07:06:29 EST 2008
Author: kabir.khan at jboss.com
Date: 2008-02-01 07:06:29 -0500 (Fri, 01 Feb 2008)
New Revision: 69532
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PrecedenceSorter.java
projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java
Log:
Comment System.out.printlns so that it is easier to see that they are commented out when doing a text search
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java 2008-02-01 12:01:16 UTC (rev 69531)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java 2008-02-01 12:06:29 UTC (rev 69532)
@@ -106,16 +106,16 @@
implements Translator
{
private static final Logger logger = AOPLogger.getLogger(AspectManager.class);
-
+
/** Read/Write lock to be used when lazy creating the collections */
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
/** Advisors registered with this manager/domain */
protected final WeakHashMap advisors = new WeakHashMap();
-
+
/** A map of domains by class, maintaned by the top level AspectManager */
protected volatile WeakHashMap subDomainsPerClass = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
-
+
/** A map of domains by name */
protected volatile WeakValueHashMap subDomainsByName = UnmodifiableEmptyCollections.EMPTY_WEAK_VALUE_HASHMAP;
@@ -177,14 +177,14 @@
protected DynamicAOPStrategy dynamicStrategy = new LoadInterceptedClassesStrategy();
// indicates that the transformation process has begun
protected boolean transformationStarted = false;
-
+
/** The classloader scoping policy */
// This shouldn't really be static (artifact of singleton and self-bootstrap design)
private static AOPClassLoaderScopingPolicy classLoaderScopingPolicy;
-
+
//Keeps track of if we need to convert references etc for a given class. Domains for scoped classloaders will have their own version of this
protected static InterceptionMarkers interceptionMarkers = new InterceptionMarkers();
-
+
// Static -------------------------------------------------------
protected static AspectManager manager;
@@ -199,17 +199,17 @@
* logging switch. We don't use log4j to avoid another heavy library
*/
public static boolean verbose = false;
-
+
/**
* Whether or not we should maintain the deprecated Advisor.methodInterceptors field
* This is required in jboss 4.x for backwards compatibility with EJB 3
- * See JBAOP-517
+ * See JBAOP-517
*/
public static boolean maintainAdvisorMethodInterceptors;
/**
* Get the top level aspect manager
- *
+ *
* @return the top level aspect manager
*/
public static synchronized AspectManager getTopLevelAspectManager()
@@ -231,10 +231,10 @@
{
return instance(SecurityActions.getContextClassLoader());
}
-
+
/**
* Get the aspect manager for a classloader
- *
+ *
* @param loadingClassLoader the classloader
* @return the aspect manager
*/
@@ -252,9 +252,9 @@
/**
* Initialise the manager if not already dones so<p>
- *
+ *
* This method should be invoked in a synchronized block
- *
+ *
* @return the manager
*/
private static AspectManager initManager()
@@ -339,7 +339,7 @@
{
classicOrder = (new Boolean(classic)).booleanValue();
}
-
+
maintainAdvisorMethodInterceptors = (new Boolean(System.getProperty("jboss.aop.advisor.methodInterceptors", "false"))).booleanValue();
@@ -353,7 +353,7 @@
/**
* Get the classLoaderScopingPolicy.
- *
+ *
* @return the classLoaderScopingPolicy.
*/
public static AOPClassLoaderScopingPolicy getClassLoaderScopingPolicy()
@@ -363,7 +363,7 @@
/**
* Set the classLoaderScopingPolicy.
- *
+ *
* TODO does it make sense for this to be modified once it has been set?
* @param classLoaderScopingPolicy the classLoaderScopingPolicy.
*/
@@ -549,11 +549,11 @@
return (Advisor) ref.get();
}
}
-
+
/**
* Takes a string of the form /sub1/sub2/sub3 of subdomains by name, where the leading "/" is the main AspectManager.
* The main user of the naming of domains is (un)serialization of advisors/containers
- *
+ *
* @param The FQN of the domain
* @return the domain referenced by the FQN or null if it does not exist
*/
@@ -562,7 +562,7 @@
String[] nameparts = fqn.split("/");
return findManagerByName(nameparts);
}
-
+
private AspectManager findManagerByName(String[] nameparts)
{
AspectManager found = this;
@@ -580,18 +580,18 @@
}
return found;
}
-
+
private AspectManager findManagerByNameInternal(String name)
{
return (Domain)subDomainsByName.get(name);
}
-
+
protected void addSubDomainByName(Domain domain)
{
initSubDomainsByNameMap();
subDomainsByName.put(domain.getDomainName(), domain);
}
-
+
public String getManagerFQN()
{
return "/";
@@ -907,9 +907,9 @@
/**
* This is to be backward compatible with JBoss 3.2.3 Translator interface
* TODO: stalep, added a synchronized block for the entire method to prevent
- * a deadlock. its not optimal and should be further reviewed.
+ * a deadlock. its not optimal and should be further reviewed.
* (commented out sync block inside the method)
- *
+ *
* @param className
* @param loader
* @return
@@ -960,7 +960,7 @@
interceptorFactories.put(name, factory);
}
}
-
+
/**
* Remove an interceptor factory that can be referenced by name.
*/
@@ -1397,7 +1397,7 @@
{
bindings.put(binding.getName(), binding);
}
-
+
initPointcutsMap();
initPointcutInfosMap();
synchronized (pointcuts)
@@ -1491,7 +1491,7 @@
{
internalRemoveClassMetaData(meta.getName());
- //Add the metadata before we update the advisors. Important for the generated instance advisors
+ //Add the metadata before we update the advisors. Important for the generated instance advisors
initClassMetaDataMap();
synchronized (classMetaData)
{
@@ -1592,7 +1592,7 @@
pointcut.clearAdvisors();
}
}
-
+
/**
* Retrieve an introduction pointcut of a certain name
*/
@@ -1852,7 +1852,7 @@
}
return aspect;
}
-
+
protected Object createPerVmAspect(String def, AspectDefinition adef, ClassLoader scopedClassLoader)
{
Object instance = null;
@@ -1891,7 +1891,7 @@
{
internalRemoveAspectDefintion(name);
}
-
+
protected AspectDefinition internalRemoveAspectDefintion(String name)
{
AspectDefinition def = (AspectDefinition) aspectDefinitions.remove(name);
@@ -1943,7 +1943,7 @@
{
return interfaceIntroductions;
}
-
+
public Map getArrayReplacements()
{
return arrayReplacements;
@@ -2062,7 +2062,7 @@
subscribedSubDomains.remove(domain);
}
}
-
+
public Map getSubscribedSubDomains()
{
return subscribedSubDomains;
@@ -2115,12 +2115,12 @@
{
lifecycleManager.addLifecycleDefinition(def);
}
-
+
public void removeLifecycleDefinition(String name)
{
lifecycleManager.removeLifecycleDefinition(name);
}
-
+
public void addLifecycleBinding(LifecycleCallbackBinding lifecycleBinding)
{
lifecycleManager.addLifecycleBinding(lifecycleBinding);
@@ -2135,52 +2135,52 @@
{
lifecycleManager.removeLifecycleBinding(name);
}
-
-
-/*
- public void dumpSubDomainsAndAdvisors(int indent)
- {
- indent(indent);
- System.out.println("Manager: " + this);
- indent++;
- indent(indent);
- System.out.println("<Advisors>");
- //indent(indent);
- for (Iterator it = advisors.keySet().iterator() ; it.hasNext() ; )
- {
- Class clazz = (Class) it.next();
- Advisor advisor = null;
- WeakReference ref = (WeakReference) advisors.get(clazz);
- if (ref != null) advisor = (Advisor) ref.get();
- indent(indent);
- System.out.println(System.identityHashCode(advisor) + " " + advisor);
- indent(indent);
- }
- indent--;
- indent(indent);
- System.out.println("</Advisors>");
- indent(indent);
- System.out.println("<Sub domains>");
- indent++;
- for (Iterator it = subscribedSubDomains.keySet().iterator(); it.hasNext() ; )
- {
- AspectManager manager = (AspectManager)it.next();
- manager.dumpSubDomainsAndAdvisors(indent);
- }
- indent--;
- indent(indent);
- System.out.println("</Sub domains>");
- indent--;
- }
+// public void dumpSubDomainsAndAdvisors(int indent)
+// {
+// indent(indent);
+// System.out.println("Manager: " + this);
+// indent++;
+// indent(indent);
+// System.out.println("<Advisors>");
+// //indent(indent);
+//
+// for (Iterator it = advisors.keySet().iterator() ; it.hasNext() ; )
+// {
+// Class clazz = (Class) it.next();
+// Advisor advisor = null;
+// WeakReference ref = (WeakReference) advisors.get(clazz);
+// if (ref != null) advisor = (Advisor) ref.get();
+// indent(indent);
+// System.out.println(System.identityHashCode(advisor) + " " + advisor);
+// indent(indent);
+// }
+// indent--;
+// indent(indent);
+// System.out.println("</Advisors>");
+//
+// indent(indent);
+// System.out.println("<Sub domains>");
+// indent++;
+// for (Iterator it = subscribedSubDomains.keySet().iterator(); it.hasNext() ; )
+// {
+// AspectManager manager = (AspectManager)it.next();
+// manager.dumpSubDomainsAndAdvisors(indent);
+// }
+// indent--;
+// indent(indent);
+// System.out.println("</Sub domains>");
+// indent--;
+//
+// }
+//
+// private void indent(int indent)
+// {
+// for (int i = 0 ; i < indent ; i++) System.out.print(" ");
+// }
- private void indent(int indent)
- {
- for (int i = 0 ; i < indent ; i++) System.out.print(" ");
- }
-*/
/**
* Lock for write
*/
@@ -2215,7 +2215,7 @@
}
}
}
-
+
protected void initSubscribedSubDomainsMap()
{
if (subscribedSubDomains == UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP)
@@ -2232,9 +2232,9 @@
{
unlockWrite();
}
- }
+ }
}
-
+
protected void initSubscribedSubDomainsQueueMap()
{
if (subscribedSubDomainsQueue == UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP)
@@ -2253,7 +2253,7 @@
}
}
}
-
+
protected void initInterfaceIntroductionsMap()
{
if (interfaceIntroductions == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2272,7 +2272,7 @@
}
}
}
-
+
protected void initArrayReplacementMap()
{
if (arrayReplacements == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2291,7 +2291,7 @@
}
}
}
-
+
protected void initArrayBindingMap()
{
if (arrayBindings == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2310,8 +2310,8 @@
}
}
}
-
-
+
+
protected void initAnnotationIntroductionsMap()
{
if (annotationIntroductions == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2330,7 +2330,7 @@
}
}
}
-
+
protected void initAnnotationOverridesMap()
{
if (annotationOverrides == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2406,7 +2406,7 @@
}
}
}
-
+
protected void initClassMetaDataLoadersMap()
{
if (classMetaDataLoaders == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
@@ -2425,7 +2425,7 @@
}
}
}
-
+
protected void initInerceptorStacksMap()
{
if (interceptorStacks == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
@@ -2444,8 +2444,8 @@
}
}
}
-
-
+
+
protected void initDeclaresMap()
{
if (declares == UnmodifiableEmptyCollections.EMPTY_HASHMAP)
@@ -2464,7 +2464,7 @@
}
}
}
-
+
protected void initCflowStacksMap()
{
if (cflowStacks == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
@@ -2483,7 +2483,7 @@
}
}
}
-
+
protected void initDynamicCflowsMap()
{
if (dynamicCFlows == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
@@ -2502,7 +2502,7 @@
}
}
}
-
+
protected void initAspectDefintitionsMap()
{
if (aspectDefinitions == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
@@ -2521,7 +2521,7 @@
}
}
}
-
+
protected void initPerVMAspectsMap()
{
if (perVMAspects == UnmodifiableEmptyCollections.EMPTY_CONCURRENT_HASHMAP)
@@ -2540,7 +2540,7 @@
}
}
}
-
+
protected void initPointcutsMap()
{
if (pointcuts == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2559,7 +2559,7 @@
}
}
}
-
+
protected void initPointcutInfosMap()
{
if (pointcutInfos == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2578,8 +2578,8 @@
}
}
}
-
-
+
+
protected void initClassMetaDataMap()
{
if (classMetaData == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
@@ -2616,7 +2616,7 @@
}
}
}
-
+
protected void initPrecedenceDefsMap()
{
if (precedenceDefs == UnmodifiableEmptyCollections.EMPTY_LINKED_HASHMAP)
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java 2008-02-01 12:01:16 UTC (rev 69531)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/ClassAdvisor.java 2008-02-01 12:06:29 UTC (rev 69532)
@@ -86,7 +86,7 @@
public class ClassAdvisor extends Advisor
{
private static final Logger logger = AOPLogger.getLogger(ClassAdvisor.class);
-
+
/**
* Suffix added to unadvised methods.
*/
@@ -254,8 +254,8 @@
{
return methodInfos.infos;
}
-
+
/**
* Constructs a new helper.
*/
@@ -306,9 +306,9 @@
}
});
/*
- System.out.println("******************");
- System.out.println("attachClass: " + clazz.getName() + " took " + (System.currentTimeMillis() - start));
- System.out.println("******************");
+// System.out.println("******************");
+// System.out.println("attachClass: " + clazz.getName() + " took " + (System.currentTimeMillis() - start));
+// System.out.println("******************");
*/
}
catch (PrivilegedActionException e)
@@ -444,7 +444,7 @@
}
}
}
-
+
protected void initializeMethodChain()
{
long[] keys = advisedMethods.keys();
@@ -572,7 +572,7 @@
// info.setInterceptors(interceptors);
// }
// }
-
+
protected void createInterceptorChains() throws Exception
{
if (AspectManager.verbose && logger.isDebugEnabled()) logger.debug("Creating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));
@@ -586,7 +586,7 @@
initializeFieldWriteChain();
initializeMethodChain();
}
-
+
initializeConstructorChain();
initializeConstructionChain();
@@ -616,14 +616,14 @@
constructorInterceptors, methodInfos);
}
}
-
+
protected void updateInterceptorChains() throws Exception
{
if (AspectManager.verbose && logger.isDebugEnabled())
{
- logger.debug("Updating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));
+ logger.debug("Updating chains for " + clazz + " " + ((clazz != null) ? clazz.getClassLoader() : null ));
}
-
+
lockWriteChain(methodInfos);
lockWriteChain(fieldReadInfos);
lockWriteChain(fieldWriteInfos);
@@ -636,7 +636,7 @@
resetChain(fieldWriteInfos);
resetChain(constructorInfos);
resetChain(constructionInfos);
-
+
synchronized (manager.getBindings())
{
Iterator it = manager.getBindings().values().iterator();
@@ -651,7 +651,7 @@
resolveConstructionPointcut(binding);
}
}
-
+
finalizeChains();
populateInterceptorsFromInfos();
}
@@ -663,7 +663,7 @@
unlockWriteChain(constructorInfos);
unlockWriteChain(constructionInfos);
}
-
+
doesHaveAspects = adviceBindings.size() > 0;
// Notify observer about this change
if (this.interceptorChainObserver != null)
@@ -681,7 +681,7 @@
finalizeChain(constructorInfos);
finalizeChain(constructionInfos);
}
-
+
private MethodByConInfo initializeConstructorCallerInterceptorsMap(Class callingClass, int callingIndex, String calledClass, long calledMethodHash, Method calledMethod) throws Exception
{
HashMap calledClassesMap = methodCalledByConInterceptors[callingIndex];
@@ -1296,7 +1296,7 @@
{
return resolveConstructorCallerMethodInfo(this.getClazz(), callingIndex, calledClass, calledMethodHash);
}
-
+
public MethodByConInfo resolveConstructorCallerMethodInfo(Class callingClass, int callingIndex, String calledClass, long calledMethodHash)
{
if (System.getSecurityManager() == null)
@@ -1364,7 +1364,7 @@
{
return resolveConstructorCallerConstructorInfo(this.getClazz(), callingIndex, calledClass, calledConHash);
}
-
+
public ConByConInfo resolveConstructorCallerConstructorInfo(Class callingClass, int callingIndex, String calledClass, long calledConHash)
{
if (System.getSecurityManager() == null)
@@ -1420,13 +1420,13 @@
//Javassist doesn't like this in a field initialiser hence this method
return new WeakReference(resolveConstructorCallerConstructorInfo(callingIndex, calledClass, calledConHash));
}
-
+
public WeakReference resolveConstructorCallerConstructorInfoAsWeakReference(Class callingClass, int callingIndex, String calledClass, long calledConHash)
{
//Javassist doesn't like this in a field initialiser hence this method
return new WeakReference(resolveConstructorCallerConstructorInfo(callingClass, callingIndex, calledClass, calledConHash));
}
-
+
/////////////////////////
// Invoking
@@ -1740,7 +1740,7 @@
}
throw new IllegalStateException("Unknown Invocation type: " + invocation.getClass().getName());
}
-
+
@Override
public void cleanup()
{
@@ -1756,7 +1756,7 @@
conByMethodData = null;
}
}
-
+
// interceptor chain observer
private InterceptorChainObserver interceptorChainObserver;
@@ -1801,7 +1801,7 @@
{
constructionInterceptors[i] = constructionInfos[i].getInterceptors();
}
-
+
}
protected MethodByMethodData getMethodByMethodData()
@@ -2038,7 +2038,7 @@
}
};
}
-
+
private class MethodByMethodData
{
private volatile TLongObjectHashMap methodCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
@@ -2098,8 +2098,8 @@
public MethodByMethodInfo resolveCallerMethodInfo(long callingMethodHash, String calledClass, long calledMethodHash)
{
//The main entry point for adding data to the maps, let us initialise them here.
- if (methodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP ||
- backrefMethodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP ||
+ if (methodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP ||
+ backrefMethodCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP ||
methodCalledByMethodInterceptors == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
{
lockWrite();
@@ -2123,7 +2123,7 @@
unlockWrite();
}
}
-
+
if (System.getSecurityManager() == null)
{
return ResolveCallerMethodInfoAction.NON_PRIVILEGED.resolveInfo(this, callingMethodHash, calledClass, calledMethodHash);
@@ -2196,7 +2196,7 @@
createdBindings = true;
}
if (!bindings.contains(binding)) bindings.add(binding);
-
+
// this is so that we can undeploy a caller
ArrayList backrefs = (ArrayList) backrefMethodCalledByMethodBindings.get(binding.getName());
if (backrefs == null)
@@ -2294,14 +2294,14 @@
methodCalledByMethodInterceptors.clear();
}
}
-
+
private class ConByMethodData
{
// constructor caller pointcut support for methods calling constructors only
private volatile TLongObjectHashMap conCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
private volatile HashMap backrefConCalledByMethodBindings = UnmodifiableEmptyCollections.EMPTY_HASHMAP;
private volatile TLongObjectHashMap conCalledByMethodInterceptors = UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP;
-
+
public TLongObjectHashMap getConCalledByMethodInterceptors()
{
return conCalledByMethodInterceptors;
@@ -2337,12 +2337,12 @@
}
}
}
-
+
public ConByMethodInfo resolveCallerConstructorInfo(long callingMethodHash, String calledClass, long calledConHash)
{
//The main entry point for adding data to the maps, let us initialise them here.
- if (conCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP ||
- backrefConCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP ||
+ if (conCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP ||
+ backrefConCalledByMethodBindings == UnmodifiableEmptyCollections.EMPTY_HASHMAP ||
conCalledByMethodInterceptors == UnmodifiableEmptyCollections.EMPTY_TLONG_OBJECT_HASHMAP)
{
lockWrite();
@@ -2366,7 +2366,7 @@
unlockWrite();
}
}
-
+
if (System.getSecurityManager() == null)
{
return ResolveCallerConstuctorInfoAction.NON_PRIVILEGED.resolveInfo(this, callingMethodHash, calledClass, calledConHash);
@@ -2440,7 +2440,7 @@
createdBindings = true;
}
if (!bindings.contains(binding)) bindings.add(binding);
-
+
// this is so that we can undeploy a caller
ArrayList backrefs = (ArrayList) backrefConCalledByMethodBindings.get(binding.getName());
if (backrefs == null)
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PrecedenceSorter.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PrecedenceSorter.java 2008-02-01 12:01:16 UTC (rev 69531)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PrecedenceSorter.java 2008-02-01 12:06:29 UTC (rev 69532)
@@ -42,11 +42,11 @@
{
InterceptorEntry entryA = (InterceptorEntry)objA;
InterceptorEntry entryB = (InterceptorEntry)objB;
-
+
return entryA.precedenceOrder - entryB.precedenceOrder;
}
};
-
+
static class InterceptorEntry
{
Interceptor interceptor;
@@ -55,32 +55,32 @@
int precedenceOrder = -1;
String classname;
String method;
-
+
InterceptorEntry(GeneratedAdvisorInterceptor factoryWrapper)
{
this.factoryWrapper = factoryWrapper;
classname = factoryWrapper.getName();
-
+
InterceptorFactory ifac = factoryWrapper.getDelegate();
-
+
if (ifac instanceof GenericInterceptorFactory)
{
//Dynamically added interceptors
classname = ((GenericInterceptorFactory)ifac).getClassName();
}
- else
+ else
{
AspectFactory af = factoryWrapper.getAspect().getFactory();
classname = af.getName();
}
-
+
if (ifac instanceof AdviceFactory)
{
method = ((AdviceFactory)ifac).getAdvice();
}
}
-
-
+
+
InterceptorEntry(Interceptor interceptor)
{
this.interceptor = interceptor;
@@ -105,7 +105,7 @@
{
interceptorName = interceptor.getClass().getName();
}
-
+
try
{
boolean isAdvice = interceptorName.startsWith("org.jboss.aop.advice.");
@@ -120,21 +120,21 @@
{
classname = interceptorName;
}
- }
+ }
catch (RuntimeException e)
{
System.err.print(interceptor.getName());
throw e;
}
}
-
+
public String toString()
{
return "Entry: " + precedenceOrder + " (" + originalOrder + ")interceptorClass=" + classname + "; adviceMethod=" + method;
}
-
+
}
-
+
private static boolean matches(InterceptorEntry ientry, PrecedenceDefEntry pentry)
{
if (ientry.classname.equals(pentry.interceptorClass))
@@ -155,12 +155,12 @@
}
return false;
}
-
-
+
+
public static PrecedenceDefEntry[] createOverallPrecedence(AspectManager manager)
{
ArrayList overall = new ArrayList();
-
+
LinkedHashMap precedenceDefs = manager.getPrecedenceDefs();
boolean first = true;
for (Iterator it = precedenceDefs.values().iterator() ; it.hasNext(); )
@@ -178,13 +178,13 @@
first = false;
continue;
}
-
+
overall = mergePrecedenceDef(overall, precedenceDef);
}
//System.out.println("OVERALL PRECEDENCE: " + overall);
return (PrecedenceDefEntry[])overall.toArray(new PrecedenceDefEntry[overall.size()]);
}
-
+
public static ArrayList mergePrecedenceDef(ArrayList overall, PrecedenceDef precedenceDef)
{
//TODO This can be improved. If you have the precedences
@@ -195,11 +195,11 @@
// i) A, D, C, E
//After adding 3) to i) you end up with an overall precedence of
// ii) A, C, D, C, E,
- //In practice this should be fine, since the applyPrecedence() looks for the
+ //In practice this should be fine, since the applyPrecedence() looks for the
//first matching entry, so the second (duplicate) occurrence of C is ignored.
PrecedenceDefEntry[] entries = precedenceDef.getEntries();
int start = 0, end = 0;
- int size = overall.size();
+ int size = overall.size();
for (int i = 0 ; i < size ; i++)
{
PrecedenceDefEntry global = (PrecedenceDefEntry)overall.get(i);
@@ -209,7 +209,7 @@
for (int j = start ; j < entries.length ; j++)
{
PrecedenceDefEntry cur = entries[j];
-
+
if (cur.equals(global))
{
found = true;
@@ -217,8 +217,8 @@
break;
}
}
-
- //We found it. Now insert everything until this into global and
+
+ //We found it. Now insert everything until this into global and
//reset the counters
if (found)
{
@@ -236,19 +236,19 @@
{
overall.add(entries[j]);
}
-
+
return overall;
}
-
+
public static Interceptor[] applyPrecedence(Interceptor[] interceptors, AspectManager manager)
{
if (interceptors.length == 0)
return interceptors;
-
+
ArrayList all = new ArrayList(interceptors.length);
ArrayList precedence = new ArrayList(interceptors.length);
PrecedenceDefEntry[] precedenceEntries = manager.getSortedPrecedenceDefEntries();
-
+
//Figure out what interceptors have precedence
for (int i = 0 ; i < interceptors.length ; i++)
{
@@ -266,36 +266,36 @@
}
}
}
-
+
//Sort the interceptors having precedence
Collections.sort(precedence, interceptorComparator);
Interceptor[] sortedInterceptors = new Interceptor[interceptors.length];
-
- //Build up new array of interceptors depending on their precedence
+
+ //Build up new array of interceptors depending on their precedence
int prec = 0;
int allSize = all.size();
int precedenceSize = precedence.size();
-
+
for (int i = 0 ; i < allSize ; i++)
{
InterceptorEntry entry = (InterceptorEntry)all.get(i);
-
+
if (entry.precedenceOrder >= 0 && prec < precedenceSize)
{
entry = (InterceptorEntry)precedence.get(prec++);
}
sortedInterceptors[i] = entry.interceptor;
}
-
+
return sortedInterceptors;
}
-
+
public static GeneratedAdvisorInterceptor[] applyPrecedence(GeneratedAdvisorInterceptor[] interceptors, AspectManager manager)
{
ArrayList all = new ArrayList(interceptors.length);
ArrayList precedence = new ArrayList(interceptors.length);
PrecedenceDefEntry[] precedenceEntries = manager.getSortedPrecedenceDefEntries();
-
+
//Figure out what interceptors have precedence
for (int i = 0 ; i < interceptors.length ; i++)
{
@@ -313,33 +313,33 @@
}
}
}
-
+
//Sort the interceptors having precedence
Collections.sort(precedence, interceptorComparator);
GeneratedAdvisorInterceptor[] sortedInterceptors = new GeneratedAdvisorInterceptor[interceptors.length];
-
- //Build up new array of interceptors depending on their precedence
+
+ //Build up new array of interceptors depending on their precedence
int prec = 0;
int allSize = all.size();
int precedenceSize = precedence.size();
-
+
for (int i = 0 ; i < allSize ; i++)
{
InterceptorEntry entry = (InterceptorEntry)all.get(i);
-
+
if (entry.precedenceOrder >= 0 && prec < precedenceSize)
{
entry = (InterceptorEntry)precedence.get(prec++);
}
sortedInterceptors[i] = entry.factoryWrapper;
}
-
+
return sortedInterceptors;
}
-
+
/* public static void main(String[] args)
{
- System.out.println("Hello");
+// System.out.println("Hello");
AspectManager manager = new AspectManager();
PrecedenceDef def = new PrecedenceDef("3",new PrecedenceDefEntry[]{
new PrecedenceDefEntry("A", null),
@@ -360,15 +360,15 @@
outputOverAll(manager);
}
-
+
private static void outputOverAll(AspectManager manager)
{
PrecedenceDefEntry[] entries = manager.getSortedPrecedenceDefEntries();
for (int i = 0 ; i < entries.length ; i++)
{
- System.out.println("\t" + entries[i]);
+// System.out.println("\t" + entries[i]);
}
- System.out.println("==================================");
+// System.out.println("==================================");
}
-*/
+*/
}
Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java 2008-02-01 12:01:16 UTC (rev 69531)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java 2008-02-01 12:06:29 UTC (rev 69532)
@@ -76,7 +76,7 @@
/**
* Set the suffixes and relative order attributes.
- *
+ *
* Those are read at subdeployer registration time by the MainDeployer
* to update its SuffixOrder list.
*/
@@ -162,9 +162,9 @@
if (scl != null)
{
- log.info("AOP deployment is scoped using classloader " + scl);
+ log.info("AOP deployment is scoped using classloader " + scl);
}
-
+
Thread.currentThread().setContextClassLoader(di.ucl);
AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
if (!di.isXML)
@@ -174,7 +174,7 @@
loader.setClassLoader(scl);
loader.deployInputStreamIterator(it);
}
-
+
AspectXmlLoader.deployXML(docURL, scl, manager);
Notification msg = new Notification("AOP Deploy", this, getNextNotificationSequenceNumber());
sendNotification(msg);
@@ -223,7 +223,7 @@
log.debug("Ignoring request to stop '" + di.url + "', current state: " + di.state);
return;
}
-
+
log.debug("undeploying document " + di.url);
ClassLoader old = Thread.currentThread().getContextClassLoader();
try
@@ -243,9 +243,9 @@
AspectManager.instance().unregisterClassLoader(di.ucl);
/*
- System.out.println("************************");
- System.out.println("undeploy took: " + (System.currentTimeMillis() - start));
- System.out.println("************************");
+// System.out.println("************************");
+// System.out.println("undeploy took: " + (System.currentTimeMillis() - start));
+// System.out.println("************************");
*/
Notification msg = new Notification("AOP Undeploy", this, getNextNotificationSequenceNumber());
sendNotification(msg);
@@ -298,7 +298,7 @@
throw new DeploymentException("Failed to find META-INF/jboss-aop.xml");
return docURL;
}
-
+
private ClassLoader getScopedClassLoader(DeploymentInfo di, URL docUrl) throws Exception
{
//Scoped AOP deployments are only available when deployed as part of a scoped sar, ear etc.
@@ -308,7 +308,7 @@
{
return di.ucl;
}
-
+
LoaderRepository attachToRepository = getLoaderRepositoryIfAttaching(di, docUrl);
if (attachToRepository != null)
{
@@ -318,23 +318,23 @@
}
return null;
}
-
+
private LoaderRepository getLoaderRepositoryIfAttaching(DeploymentInfo di, URL docUrl) throws Exception
{
if (di.parent == null)
{
//We are a top-level deployment, check if we are meant to be attaching to a scoped repository
-
+
Document doc = AspectXmlLoader.loadURL(docUrl);
Element top = doc.getDocumentElement();
NodeList children = top.getChildNodes();
int childlength = children.getLength();
for (int i = 0; i < childlength ; i++)
{
- Node child = children.item(i);
+ Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE)
{
- Element element = (Element)child;
+ Element element = (Element)child;
if (element.getTagName().equals("loader-repository"))
{
String repositoryName = null;
@@ -359,7 +359,7 @@
{
throw new RuntimeException("loader-repository='" + repositoryName + "' is not a valid object name", e);
}
-
+
try
{
MBeanInfo info = server.getMBeanInfo(on);
@@ -368,7 +368,7 @@
{
log.warn("No scoped loader repository exists with the name " + on);
}
-
+
LoaderRepository repository = (LoaderRepository)server.getAttribute(on, "Instance");
if (repository instanceof HeirarchicalLoaderRepository3)
{
@@ -379,10 +379,10 @@
log.warn("Loader repository " + on + " is not a isolated loader repository. Deploying aspects in default domain.");
}
}
- }
+ }
}
}
-
+
return null;
}
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list