Announcement Announcement Module
Collapse
No announcement yet.
Wish to have access of caller method's param in advisor of methods being called Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wish to have access of caller method's param in advisor of methods being called

    Sorry if the title doesn't make any sense. I am trying to describe what I am trying to achieve:

    Suppose I have 2 classes : Foo and Goo, they look like

    #Foo
    package org.abc.pkg1;
    Foo{
    private Goo goo;
    public void method1(x, y){
    ...
    int z=1;
    goo.method2(z);
    ...
    }
    }

    #Goo
    package org.abc.pkg2;
    Goo{
    public void method2(z){
    ...
    }
    }

    I am going to put around advice on all public methods in objects in package org.abc.pkg2 (obviously Goo's method2 will be matched). There is no question in the adviser body I can get access of information related on method2, such as method name, args ... through ProceedingJoinPoint, but is there any way I can get access to parameter value of the caller 'method1' (in this case value of x)? I need the value of x and the name of method2 to determine if method2 should be executed as normal or not.

    I understand that if I change the signature of method2 to include x as parameter, it will meet my need. However x is really not a parameter meaningful to method2. I have looked into AOP introductions, seems not helpful.

    I am not sure if what I had described it clear enough. Is what I am trying to do something reasonable? or there is alternative way to achieve this.

    Thank you!
Working...
X