`
Luob.
  • 浏览: 1571843 次
  • 来自: 上海
社区版块
存档分类
最新评论

Spring AspectJ Aop Annotation

 
阅读更多
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;


@Component
@Aspect
public class PermissionAspect {
    //@Pointcut("execution(* cn.mwee.wpos.service..*(..))")
    @Pointcut("execution(@cn.test.annotation.Permission * *(..))")
    public void permissionPointcut() {}

    @Around("permissionPointcut()")
    public CommonResponse checkPermission(ProceedingJoinPoint joinPoint){ //ProceedingJoinPoint joinPoint
        CommonResponse response=new CommonResponse();
        try {
            // 执行的类
            String exeType = null;
            // 执行的方法
            String exeMethod = null;

            response.getErr().setErrNo(ErrorCode.NO_PERMISSION).setErrMsg(ErrorDesc.NO_PERMISSION);

            MethodSignature signature = (MethodSignature) joinPoint.getSignature();
            exeType = signature.getDeclaringType().getCanonicalName();
            exeMethod = signature.getMethod().getName();

            System.out.println(exeType + " " + exeMethod);
            return response;

            //return (CommonResponse)joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return response;
    }
}
分享到:
评论

相关推荐

    Spring用AspectJ开发AOP(基于Annotation)

    主要介绍了Spring用AspectJ开发AOP(基于Annotation),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

    Spring AOP + AspectJ annotation example

    NULL 博文链接:https://tuoxinquyu.iteye.com/blog/1465187

    spring-aop-annotation-log-all

    spring-aop-4.0.4.RELEASE.jar com.springsource.net.sf.cglib-2.2.0.jar com.springsource.org.aopalliance-1.0.0.jar com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar spring-aspects-4.1.2.RELEASE.jar ...

    springAOP demo 带错误解决文档

    nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator]: ...

    org.aspectj.lang.annotation.Around所需要的包

    java错误-java.lang.ClassNotFoundException: org.aspectj.lang.annotation.Around Spring的AOP需要上述三个jar包

    Aspectj in Action: Enterprise AOP with Spring Applications (2nd Edition)

    You'll master key features including annotation-based syntax, load-time weaver, annotation-based crosscutting, and Spring-AspectJ integration. Building on familiar technologies such as JDBC, ...

    详解Spring Aop实例之AspectJ注解配置

    本篇文章主要介绍了详解Spring Aop实例之AspectJ注解配置,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧

    编程式创建Aspect代理源码

    编程式创建Aspect代理源码 You can use the org.springframework.aop.aspectj.annotation.AspectJProxyFactory class to create a proxy for a target object that is advised by one or more @AspectJ aspects.

    【Spring AOP】@Aspect结合案例详解(二): @Pointcut使用@within和within

    上文我们已讲完五种通知Advice注解,所以从本文开始介绍@Pointcut切点表达式,虽然Spring AOP的切点表达式尚未 全部实现 @AspectJ 的切点指示符,但是也已经足够多和灵活,本文主要介绍@Pointcut切点表达式中的@...

    利用AOP来变更工作线程的名字,来快速过滤出一次请求的所有日志.docx

    import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.springframework....

    开发者突击·精通AOP整合应用开发 源码

    《开发者突击:精通AOP整合应用开发(AspectWerkz+Aspectl+Spring)》以AOP基础理论为主线,首先讲解AOP的产生与发展、为什么要应用AOP、AOP的核心概念,然后再详细讲解AspectWerkz、AspectJ、Spdng框架的AOP应用开发...

    Spring的学习笔记

    一、 开始使用annotation配置Spring 16 二、 @Autowired、@Qualifier 16 (一) @Autowired 16 (二) @Qualifier 17 三、 @Resource(重要、推荐) 17 (一) JSR-250 17 (二) @Resource 17 四、 @Componet 18 五、 @Scope...

    Spring 3.x 中文开发手册.pdf

    Spring 3.x 新特性全部介绍 ...我自己也曾经仿造者,并且基于aspectj山寨过过aop annotation cache 在大部分简单的cache场景都是非常好用的 少部分需要精确evict key的场景还不适合 具体可以参考 ...

    aop-annotation-logging

    aop注释日志结合Java注释日志实现AOP。 要执行此项目,请在AOPLoggerTest.java中运行main方法请确保为项目启用了AspectJ Tooling,以得到正确的结果。 要在Spring Tool Suite中执行此操作, 将适当的项目导入STS, ...

    spring2.5 学习笔记

    一、 开始使用annotation配置Spring 16 二、 @Autowired、@Qualifier 16 (一) @Autowired 16 (二) @Qualifier 17 三、 @Resource(重要、推荐) 17 (一) JSR-250 17 (二) @Resource 17 四、 @Componet 18 五、 @Scope...

    spring2.5.chm帮助文档(中文版)

    Spring Framework 开发参考手册 目录 1. 简介 1.1. 概览 1.1.1. 使用场景 2. Spring 2.0和 2.5的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 新的bean作用域 2.2.2. 更简单的XML配置 2.2.3. 可扩展的...

    Spring Framewor开发手册

    2. Spring 2.0和 2.5的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 新的bean作用域 2.2.2. 更简单的XML配置 2.2.3. 可扩展的XML编写 2.2.4. Annotation(注解)驱动配置 2.2.5. 在classpath中自动搜索组件 2.3. ...

    aspectj-1.8.5.jar

    jdk1.7 spring aop报错 请下载aspectj-1.8.5.jar 更换低版本程序,再不行下载最新的aspectjweaver.jar

    SSM三大框架整合所需jar包+日志/缓存/验证码/ajax/数据校验全部jar包

    spring-aop-4.0.0.RELEASE.jar spring-beans-4.0.0.RELEASE.jar spring-context-4.0.0.RELEASE.jar spring-core-4.0.0.RELEASE.jar spring-expression-4.0.0.RELEASE.jar 【jdbc核心】 spring-jdbc-4.0.0....

Global site tag (gtag.js) - Google Analytics