[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] joinpoint in interface
|
All!
My question:
In the following example, how do I write my pointcut to trigger on any
implementing classes annotation, i.e. so BOTH A) and B) are adviced (without
having to annotate the interface)
I have the following pointcut defined:
/**
any method call to facade package returning a subclass of StatusResult and
annotated with TranslateExceptionToInternal
from within the client package
*/
pointcut annotatedFacadeCall(TranslateExceptionToInternal
translateExceptionToInternal) :
@annotation(translateExceptionToInternal)
&& within(com.salestool.client..*)
&& call(@TranslateExceptionToInternal StatusResult+
com.salestool.facade.*.*(..));
a method of a class in facade package is annotated...
public class UserServiceFacadeImpl implements UserServiceFacade {
@TranslateExceptionToInternal()
public StatusResult saveUpdateUser(user) {
}
}
...but NOT its corresponding method in the interface
public interface UserServiceFacade {
public StatusResult saveUpdateUser(user);
}
The following works fine, A):
package com.salestool.client;
public class MyController {
public void myMethod() {
UserServiceFacadeImpl userFacadeImpl = new UserServiceFacadeImpl();
userFacadeImpl.saveUpdateUser(user); //is adviced
}
BUT since programming against interfaces is good manners I changed the code
to, B)
public void myMethod2() {
UserServiceFacade userFacade = new UserServiceFacadeImpl();
userFacade.saveUpdateUser(user); //is NOT adviced
}
}
--
View this message in context: http://www.nabble.com/joinpoint-in-interface-tf3213307.html#a8923314
Sent from the AspectJ - users mailing list archive at Nabble.com.