Spring AOP Maven依赖,拦截加注解的方法参数
2014-03-24 12:58
986 查看
<!-- Spring AOP + AspectJ by shipengzhi --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>3.0.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>3.0.6.RELEASE</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjrt</artifactId> <version>1.6.11</version> </dependency> <dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.6.11</version> </dependency> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>2.1_3</version> </dependency> <!-- end -->
@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());}}}}
相关文章推荐
- Spring AOP获取拦截方法的参数名称跟参数值
- 使用Spring注解AOP(基于自定义注解和包下拦截方法)
- springboot Aop 方法拦截、注解拦截
- 通过spring aop去反射目标类方法参数的注解值
- spring MVC AOP 拦截方法参数并根据业务逻辑处理参数
- Spring AOP获取拦截方法的参数名称跟参数值
- Spring 代理对象,cglib,jdk的问题思考,AOP 配置注解拦截 的一些问题.为什么不要注解在接口,以及抽象方法.
- AOP实现拦截对象以及获取切入目标方法和注解
- Spring_4_注解的方法依赖注入
- spring-AOP通过注解@DeclareParents引入新的方法
- spring aop获取目标对象的方法对象(包括方法上的注解)
- Spring3系列10- Spring AOP——Pointcut,Advisor拦截指定方法
- spring中的多线程aop方法拦截
- SpringAOP拦截Controller,Service实现日志管理(自定义注解的方式)
- 从头认识Spring-3.6 简单的AOP日志实现(注解版)-需要记录方法的运行时间
- 使用spring的aop实现拦截action后出现依赖注入为空的问题
- spring aop 获取方法的参数
- 关于spring中aop的注解实现方法实例详解
- 自己试验在spring的环绕通知里获取目标对象的类名和目标方法的参数类名,用于根据自定义注解判断访问权限,有没有更好的办法,高手指点一下
- AOP实现拦截对象以及获取切入目标方法和注解