Spring AOP Maven 의존, 주 해 를 차단 하 는 방법 파라미터

32143 단어 자바

        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-aopartifactId>
            <version>3.0.6.RELEASEversion>
        dependency>
        <dependency>
            <groupId>org.springframeworkgroupId>
            <artifactId>spring-aspectsartifactId>
            <version>3.0.6.RELEASEversion>
        dependency>
        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjrtartifactId>
            <version>1.6.11version>
        dependency>
        <dependency>
            <groupId>org.aspectjgroupId>
            <artifactId>aspectjweaverartifactId>
            <version>1.6.11version>
        dependency>
        <dependency>
            <groupId>cglibgroupId>
            <artifactId>cglibartifactId>
            <version>2.1_3version>
        dependency>
        

@Standardized(type = StandardizedData.CLIPON)
public class Main{...}

@Before("execution (* org.xx.xx.xx..*.*(@org.xx.xx.xx.xx.xx.Standardized (*),..))")
public void standardize(JoinPoint jp) throws Throwable {
    Object[] args = jp.getArgs();
    MethodSignature ms = (MethodSignature) jp.getSignature();
    Method m = ms.getMethod();

    Annotation[][] parameterAnnotations = m.getParameterAnnotations();

    for (int i = 0; i < parameterAnnotations.length; i++) {
        Annotation[] annotations = parameterAnnotations[i];
        System.out.println("I am checking parameter: " + args[i]);
        for (Annotation annotation : annotations) {
            System.out.println(annotation);

            if (annotation.annotationType() == Standardized.class) {
                System.out.println("we have a Standardized Parameter with type = "
                        + ((Standardized) annotation).type());
            }
        }
    }
}

좋은 웹페이지 즐겨찾기