Может быть, вам нужно что-то вроде следующего:
public privileged aspect LocalMethodCallAspect {
private pointcut localMethodExecution() : withincode(public CustomerDto TargetClass.getCustomer(Integer)) &&
call(private String TargetClass.getEmailAddress());
after() returning(String email) : localMethodExecution()
{
System.out.println(email);
}
}
Где TargetClass
- класс, содержащий методы getCustomer()
и getEmailAddress()
.
Или то же самое, используя @AspectJ:
@Aspect
public class LocalMethodCallAnnotationDrivenAspect {
@Pointcut("withincode(public CustomerDto TargetClass.getCustomer(Integer)) && " +
"call(private String TargetClass.getEmailAddress())")
private void localMethodExecution() {
}
@AfterReturning(pointcut="localMethodExecution()",returning="email")
public void printingEmail(String email) {
System.out.println(email);
}
}