I am not sure if this is actually the same problem or similar to the problem
"eprst" encountered, but anyway, here's what I found out.
The following annotation is provided for dynamic AOP:
<?xml version="1.0" encoding="UTF-8" ?>
| <aop>
| <prepare expr="field([EMAIL PROTECTED]>*)" />
| </aop>
and
| package com.mycompany;
|
| import java.lang.annotation.ElementType;
| import java.lang.annotation.Target;
|
| @Target({ElementType.TYPE})
| public @interface MyAnnotation { }
|
I have two classes A and B, and B is inheriting A, like:
| @com.mycompany.MyAnnotation
| class A {
| private int a;
|
| public int getA() {
| return this.a;
| }
|
| public void setA(int a) {
| this.a = a;
| }
| }
|
|
| class B extends A {
| private int b;
|
| public int getB() {
| return this.b;
| }
|
| public void setB(int b) {
| this.b = b;
| }
| }
|
So B gets also advised as it extends class A that is annotated for dynamic AOP.
Now, if I inspect an Advised instance of class B, there are two
_instanceAdvisor fields, one for the super class A and one for class B. When I
execute the following code:
| B b = new B();
| InstanceAdvisor advisor = ((Advised) b)._getInstanceAdvisor();
| advisor.appendInterceptor(new SomeInterceptor(...));
|
only the _instanceAdvisor for class B gets an advisor (_instanceAdvisor of
class A remains null). Accessing field "a" in class A won't get intercepted,
but accessing field "b" in class B will.
--
If I understand the code in org.jboss.aop.instrument.Instrumentor, only base
class of Advised hierarchy should get _instanceadvisor field:
| if (isBaseClass(clazz))
| {
| addBaseElements(clazz); // In this method a protected
_instanceAdvisor is added
| }
|
However, if I run the code mentioned above and then inspect an instance of
class B, I see two _instanceAdvisor fields at the same time, one for class A
(which is always null) and one for class B (which gets ClassInstanceAdvisor
when I call _getInstanceAdvisor() ).
If I create an instance of class A, everything works OK (accessing the field
"a" gets intercepted). I believe this is because there is only one
_instanceAdvisor field (because of the class is not inherited) so the
interceptor gets added to the right Advisor.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3940724#3940724
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3940724
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user