[jboss-user] [JBoss AOP] - How do you get the superclass from the Invocation object?

DerMas do-not-reply at jboss.com
Tue Aug 18 07:50:58 EDT 2009


I think I should show you a simple example code:


  | 
  | public class A{
  | 	@InterceptMe
  | 	public void sayHello(){
  | 		System.out.println("hello");
  | 	}
  | }
  | 
  | public class B extends A{
  | 	@InterceptMe
  | 	public void sayHello(){
  | 		super.sayHello();
  | 		System.out.println("foo");
  | 	}
  | }
  | 
  | jboss-aop.xml
  | 
  | <aop>
  |     <bind pointcut="execution(* *->@aop.InterceptMe(..))">
  |        <interceptor class="aop.TheInterceptor" scope="PER_VM"/>  
  |     </bind>  
  | </aop>
  | 
  | 

Ok, so basically every method with the InterceptMe Annotation ist intercepted by TheInterceptor (great name isnt it? ^^).

In this Interceptor every method ist called again with reflection (doesnt make much sense in this example, but for my project). Now the problem is, that if super.sayHello() is called, the Invocation class does still give me class B if I call myInvocation.getTargetObject(). This is a problem when invoking the method with reflection (method is invoked on the wrong class B instead of class A).

Any idea how I can get the superclass?

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250145#4250145

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250145



More information about the jboss-user mailing list