Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring aop, unbound pointcut parameter

Tags:

spring

aop

Im getting this error taht i dont really understand:

unbound pointcut parameter auditable

following code:

@Aspect
public class TestAspect {

    @Before(value = "@annotation(Action)")
    public void audit(JoinPoint joinPoint, Action auditable) {
        System.out.println(auditable);
    }
}

 @Action(ActionType.FAST)
    public static void resolveFast(String name){
        System.out.println(name);
    }

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Action {

    ActionType value();
    boolean withArgs() default false;
}

public enum ActionType {
    FAST, SLOW
}

the problem occurs on @Before annotation, these are my first steps in aop...

like image 912
filemonczyk Avatar asked Jul 04 '17 17:07

filemonczyk


People also ask

How do I declare a pointcut in Spring AOP?

In Spring AOP, a join point always represents a method execution. A pointcut is a predicate that matches the join points, and the pointcut expression language is a way of describing pointcuts programmatically.

What is the difference between a join point and a pointcut?

A Joinpoint is a point in the control flow of a program where the control flow can arrive via two different paths(IMO : that's why call joint). A Pointcut is a matching Pattern of Joinpoint i.e. set of join points.

What is pointcut expression in spring?

Pointcut: Pointcut is expressions that are matched with join points to determine whether advice needs to be executed or not. Pointcut uses different kinds of expressions that are matched with the join points and Spring framework uses the AspectJ pointcut expression language.

What is pointcut in AspectJ?

AspectJ provides primitive pointcuts that capture join points at these times. These pointcuts use the dynamic types of their objects to pick out join points. They may also be used to expose the objects used for discrimination. this(Type or Id) target(Type or Id)


1 Answers

In this statement:

 @Before(value = "@annotation(Action)")

You should replace Action with auditable.

like image 145
屎蒂芬大叔 Avatar answered Oct 03 '22 05:10

屎蒂芬大叔