[jboss-cvs] JBossAS SVN: r58191 - projects/aop/trunk/aop/src/main/org/jboss/aop/advice
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Nov 7 15:37:53 EST 2006
Author: kabir.khan at jboss.com
Date: 2006-11-07 15:37:49 -0500 (Tue, 07 Nov 2006)
New Revision: 58191
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
Log:
Take into account (for AOP/MC integration) that aspects might be deployed in the lib folder, in which case they will be generated using a child ucl
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2006-11-07 20:35:54 UTC (rev 58190)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/advice/PerVmAdvice.java 2006-11-07 20:37:49 UTC (rev 58191)
@@ -59,7 +59,7 @@
ClassLoader cl = aspect.getClass().getClassLoader();
String name = "org.jboss.aop.advice." + aspect.getClass().getName() + "_z_" + adviceName + "_" + System.identityHashCode(cl);
Class iclass = null;
-
+
if (cl == null)
{
//The classloader will be null if loader by the booststrap classloader
@@ -67,7 +67,7 @@
}
synchronized (PerVmAdvice.class)
{
- try
+ try
{
iclass = cl.loadClass(name);
}
@@ -88,13 +88,27 @@
if (iclass == null)
{
+ //Aspects deployed in the lib folder, such as the AOP/MC integration aspects like the JMXIntroduction
+ //will be deployed in the root classloader, but created in a pool for a child ucl due to the nature of AspectManager.findClassPool()
+ try
+ {
+ ClassLoader pcl = pool.getClassLoader();
+ iclass = pcl.loadClass(name);
+ }
+ catch(Exception e)
+ {
+ }
+ }
+
+ if (iclass == null)
+ {
Method[] methods = aspect.getClass().getMethods();
ArrayList matches = new ArrayList();
for (int i = 0; i < methods.length; i++)
{
if (methods[i].getName().equals(adviceName)) matches.add(methods[i]);
}
-
+
// todo: Need to have checks on whether the advice is overloaded and it is an argument type interception
if (matches.size() == 1)
{
@@ -107,15 +121,15 @@
}
}
}
-
+
// ClassPool pool = AspectManager.instance().findClassPool(cl);
CtClass clazz = TransformerCommon.makeClass(pool, name);
-
+
// We need to know whether this Interceptor is actually advice.
CtClass interceptorInterface = pool.get("org.jboss.aop.advice.Interceptor");
CtClass abstractAdviceClass = pool.get("org.jboss.aop.advice.AbstractAdvice");
clazz.setSuperclass(abstractAdviceClass);
-
+
// aspect field
CtClass aspectClass = pool.get(aspect.getClass().getName());
CtField field = new CtField(aspectClass, "aspectField", clazz);
@@ -130,7 +144,7 @@
CtMethod getName = CtNewMethod.make(getNameTemplate.getReturnType(), "getName", getNameTemplate.getParameterTypes(), getNameTemplate.getExceptionTypes(), getNameBody, clazz);
getName.setModifiers(javassist.Modifier.PUBLIC);
clazz.addMethod(getName);
-
+
// invoke
CtMethod invokeTemplate = interceptorInterface.getDeclaredMethod("invoke");
StringBuffer invokeBody = new StringBuffer();
@@ -155,7 +169,7 @@
CtMethod invoke = CtNewMethod.make(invokeTemplate.getReturnType(), "invoke", invokeTemplate.getParameterTypes(), invokeTemplate.getExceptionTypes(), invokeBody.toString(), clazz);
invoke.setModifiers(javassist.Modifier.PUBLIC);
clazz.addMethod(invoke);
-
+
iclass = TransformerCommon.toClass(clazz, cl);
}
}
More information about the jboss-cvs-commits
mailing list