I want to define my pointcut to match two kinds of methods:
org.mypackage.Foo
with names starting with "update"I tried the following:
@Before("execution (* org.mypackage.Foo.update*(..) ) && execution(* org.mypackage.Foo.delete*(..) )")
public void verify()
{
//verify if user has permission to modify...
}
It doesn't work. When I call either a Foo.update*() method or a Foo.delete*() method, verify() is not invoked.
How should I change it?
There are 2 option to match patterns in pointcut expression. The pointcut expression may be either a simple reference to a named pointcut, or a pointcut expression declared in place.
@Pointcut("execution(* org.mypackage.Foo.update*(..))")
private void fooUpdate() {}
@Pointcut("execution(* org.mypackage.Foo.delete*(..))")
private void fooDelete() {}
@Before("fooUpdate() || fooDelete()")
public void verify() {
// verify if user has permission to modify...
}
@Before("execution(* org.mypackage.Foo.update*(..)) || execution(* org.mypackage.Foo.delete*(..))")
public void verify() {
// verify if user has permission to modify...
}