简体   繁体   中英

Aspectj default constructor pointcut

Im working with some AspectJ code and i want to catch all the executions for none private pointcuts.

@Pointcut("execution(public * *(..))")//Public
public void publicMethod(){};
@Pointcut("execution(protected * *(..))"//Protected
public void protectedMethod(){}

@Pointcut("@annotation(mypackage.name.annotationName")
public void annotationPointcut(){}

@Around("annotationPointcut() && (protectedMethod() || publicMethod())")
public Object test(){ System.out.println("Should not print private"); }

I read about using ! (not) but could not get it to work. Something like

@Pointcut("!execution(private * *(..))"

But without getting it to work.

I could not find a modifier name for default class modifier in the aspectJ, have I missed it or do i need to try and solve it by using ! not sign in some sort of way?

Regards a new dev that are learning aspectJ

试试这个来捕获所有非私有方法。

@Pointcut("execution(!private * *(..))")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM