@afterreturning

我们同理写几个测试类

package cn.cutter.start.bean;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component; @Component
public class AterReturningTestBean { private static final Log logger = LogFactory.getLog(AterReturningTestBean.class); public void aterReturningTest() {
logger.info("aterReturningTest sds");
} public int aterReturningTestInt() {
logger.info("aterReturningTestInt"); return 666;
} }

写几个测试的拦截器

package cn.cutter.start.aop;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component; /**
*
* @author xiaof
*
*/
@Component
@Aspect
public class AterReturningAspect { private static final Log logger = LogFactory.getLog(AterReturningAspect.class); //execution(* cn.cutter.start.bean.BeofreTestBean.*(..))
@Pointcut("execution(* cn.cutter.start.bean.AterReturningTestBean.*(..))")
private void pointCut1() {} @AfterReturning(pointcut="pointCut1()", returning="value1")
public void testReturn1(int value1) { logger.info("返回拦截:" + value1); } @AfterReturning(pointcut="pointCut1()")
public void testReturn2() { logger.info("返回拦截:没有参数"); } }

结果:

@Test
public void testAop4() {
ApplicationContext ctx = this.before(); AterReturningTestBean att = (AterReturningTestBean) ctx.getBean("aterReturningTestBean"); // att.aterReturningTest(); att.aterReturningTestInt(); }

【sping揭秘】15、afterreturning的更多相关文章

  1. 【sping揭秘】16、@After(finally) 但是这个实在afterturning之前执行

    package cn.cutter.start.bean; import org.apache.commons.logging.Log; import org.apache.commons.loggi ...

  2. 【sping揭秘】13、Spring AOP一世&二世

    Spring AOP一世 Spring AOP中的advice Before advice 这个就是在方法执行之前执行,也就是在对应的joinpoint之前 spring AOP二世 开启aspect ...

  3. 【sping揭秘】25、Spring远程方案

    分化:RMI,EJB,Hessian Spring有 Rmi,http,hessian,burlap 基于rmi的remoting方案 RMI要求远程类对象包路径和本地一致 基于HTTP的轻量级rem ...

  4. 【sping揭秘】24、Spring框架对JMS的集成(无环境版,以后学MQ的时候再隆重介绍)& 任务调度和线程池

    这个我也不是很了解,那么这个需要好好学习一下了 JMS有2种消息域类型 1. point to point 点对点模式 2.发布订阅模式  publish/subscribe Pub/Sub 模式 传 ...

  5. 【sping揭秘】23、Spring框架内的JNDI支持

    JndiTemplate 经过jdbctemplate,transactionTemplate...的洗礼,想必大家看到template就知道是个什么尿性了吧 一样的,我们只需要调用jnditempl ...

  6. 【sping揭秘】22、事务管理

    有关事务的楔子 什么是事务??? 事务就是以可控的方式对数据资源进行访问的一组操作. 事务本身持有四个限定属性 原子性,一致性,隔离性,持久性 事务家族 Resource Manager  RM,负责 ...

  7. 【sping揭秘】21、Spring动态数据源的切换

    对于多个数据源的时候,我们如何切换不同的数据源进行数据库的操作呢? 当然我们可以直接定义2个DataSource,然后在每次获取connection的时候,从不同的DataSource中获取conne ...

  8. 【sping揭秘】20、spring的orm

    面向对象的操作方式,spring统一定义在org.springframework.jdbc.object以RdbmsOperation作为顶层抽象定义 Spring对各种ORM的集成 Spring的集 ...

  9. 【sping揭秘】19、关于spring中jdbctemplate中的DataSource怎么来呢

    我们这是可以正好借助之前学的factorybean类,自己吧jdbctemplate加载到spring容器中,我们可以封装多个这种对象,那么可以实现针对不同的数据库的jdbctemplate 首先我们 ...

随机推荐

  1. mysql case when then else end 写法

    今天改SQL用到了就搜了搜,现在记下来. case when tableName.type in (1,2,3,4) and tableName.state  in (5,6) then 1 when ...

  2. mysql数据库字段内容替换

    UPDATE 表名 SET 字段名= replace(字段名, '查找内容', '替换成内容') ; UPDATE car_articles SET article_title = replace(a ...

  3. Linux firewalld使用教程+rhce课程实验

    --timeout= 设置规则生效300秒 调试阶段使用,防止规则设置错误导致无法远程连接 实验:在server0机器上部署httpd服务,通过添加富规则,只允许172.25.0.10/32访问,并且 ...

  4. MAC shell ps 命令详解(转)

    ps命令为我们提供了一次性的查看进程结果,它所提供的查看结果不是动态连续的:如果想对进程时间监控,应该用top工具 Linux中的ps命令是Process Status的缩写.ps命令用来列出系统中当 ...

  5. [leetcode]97. Interleaving String能否构成交错字符串

    Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Input: s1 = "aabc ...

  6. [leetcode]39. Combination Sum组合之和

    Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), fin ...

  7. Linux系统中的tar命令

    时间一长什么东西都容易忘记,尤其是一些不常用的东西忘记的更快,所以避免忘记,就记录下来,可以方面使用的时候查询.Tar命令在linux系统中算是一个比较重要的命令,今天就针对该命令进行总结一下. 1. ...

  8. python加密解密算法

    https://www.cnblogs.com/xiao-apple36/p/8744408.html

  9. android 去掉activity的切换动画

    在styles.xml文件中增加样式代码: <style name="AppTheme" parent="Theme.AppCompat.Light.NoActio ...

  10. 【APP测试(Android)】--交叉事件