I am using AspectJ (AOP) for logging purpose. I have following package structure:
com.company.base
com.company.base.common.Result.java
(its a POJO containing 3 fields and their setters and getters and implements Serialize)
com.company.base.feature1.User.java
(its a POJO containing 5 fields and their setters and getters and implements Serialize)
com.company.base.feature2.Customer.java
(its a POJO containing 2 fields and their setters and getters and implements Serialize)
my requirement is: 1) log entry and exit messages when any method executes from any class except from POJO's setter and getter 2) minimum line of code should be there
I am using following pointcut definition but its also calling the advise at setters and getters time as well.
@Pointcut("execution(* com.company.base..*(..))")
void allMethodExcution() {}
Please suggest as soon as possible.
I think I got partial answer to my question (may be not the exact one).
1] All the POJOs are annotated with @XmlRootElement
so I created one more pointcut and following advise
// join points created by following point cuts
@Pointcut("within(@javax...XmlRootElement *)")
public void beanAnnotatedWithSpecificAnnotation()
@Pointcut("execution(* com.company.base..*(..))")
public void allMethods()
// this is advise
@Before("!beanAnnotatedWithSpecificAnnotation() && allMethods()")
public void applyAdvise(JoinPoint jp) {
// TODO: advise code ...
}
2] But, what if POJO does not contain @XmlRootElement
and only implements java.io.Serialize
interface?