-
Aug 16th, 2012, 05:17 AM
#1
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){
//...
}
}
-----------------------------------------------------------------
-
Sep 5th, 2012, 04:50 PM
#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).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules