-
1. Re: How to apply aspects to javax.* classes
analogue Aug 30, 2003 12:23 AM (in response to analogue)Ooops..posted too soon. Heres the rest of the message:
====================================
<?xml version="1.0" encoding="UTF-8"?>
<interceptor-pointcut class="POJO">
</interceptor-pointcut>
<interceptor-pointcut class="javax.swing.JLabel">
</interceptor-pointcut>
==================================
No signs of JLabel invocations in the output:
Entering method: main
Entering constructor: POJO
Leaving constructor: POJO
Entering method: helloWorld
Hello World!
Leaving method: helloWorld
Leaving method: main
Any thoughts? -
2. Re: How to apply aspects to javax.* classes
adegbile Aug 30, 2003 2:48 PM (in response to analogue)Hi,
First, the design of the Jboss AOP Framework will not allow the instrumentation of the classes from the following packages that start with
java.
javax.
sun.
com.sun.
org.apache.xerces.
org.xml.sax.
org.w3c.dom.
based on the method protected Class loadClassByDelegation(String name) in org.jboss.aop.standalone.SystemClassLoader.
Secondly, the mignt be a simple work around
as illustrated with this example
public class Vector {
java.util.Vector delegate ;
public Vector(java.util.Vector deco)
{
delegate = deco;
}
public void add(Object test) {
delegate.add(test);
}
public void remove(Object test) {
delegate.remove(test);
}
}
// Changes in POJO
public static void main(String[] args) throws Exception
{
POJO pojo = new POJO();
Vector vec = new Vector(new java.util.Vector());
vec.add(pojo);
vec.remove(pojo);
jboss-aop.xml changes
<interceptor-pointcut class="Vector">
</interceptor-pointcut>
the output are
Entering TracingInterceptor Calling constructor: public Vector(java.util.Vector)
Leaving TracingInterceptorCalling constructor: public Vector(java.util.Vector)
Entering TracingInterceptor Calling method: add
Leaving TracingInterceptorCalling method: add
Entering TracingInterceptor Calling method: remove
Leaving TracingInterceptorCalling method: remove
Hope this helps
Adeyemi E Adegbile -
3. Re: How to apply aspects to javax.* classes
analogue Sep 1, 2003 12:49 AM (in response to analogue)Thats a solution, but it kind of defeats the purpose of AOP. Do any of the existing AOP java implementation allow for aspectizing system classes?
-
4. Re: How to apply aspects to javax.* classes
adrian.brock Sep 1, 2003 5:36 AM (in response to analogue)AspectJ will let you do it using a caller pointcut.
It will only apply to places in your code, not internal uses
by Swing classes.
You can't modify Sun code it is against their license.
Read the javassist docs on how to do it
if you are not breaking Sun's license.
Regards,
Adrian