Announcement Announcement Module
Collapse
No announcement yet.
Need to apply an advice to method of interface regardless implementing class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need to apply an advice to method of interface regardless implementing class

    Hi Guys...

    just want to put an advice to a method of an interface, not class. I mean, whenever the one method e.g. addName() of an interface "MyInterface" invoked through some implementing class object, an advice on that method will run.
    If this is possible then we can minimize no. of proxy object on every implementing class.


    --------------------------------------------------------------------------------
    e.g:

    interface myInterface{ public void addMyName(String name); }

    class SomeMyClass implements myInterface {
    public void addName(String name){

    //.....

    }
    }

    @Aspect
    class myInterfaceProxy implements BeforeAdvice{

    @Before("execute(* com.myInterface.addName(..))")
    public void before(Method arg0, Object[] arg1, Object arg2){

    //...
    }
    }


    -----------------------------------------------------------------

  • #2
    You can do pointcut matching to interface methods. All beans implementing the interface will be proxied. I don't understand what do you mean by minimizing proxy objects. Intefaces cannot be proxied, class instances are. Pointcut matching to interfaces is just a way to make configuration simple (you don't have to list all implementations in a pointcut).

    Comment

    Working...
    X