【sping揭秘】15、afterreturning
@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的更多相关文章
- 【sping揭秘】16、@After(finally) 但是这个实在afterturning之前执行
package cn.cutter.start.bean; import org.apache.commons.logging.Log; import org.apache.commons.loggi ...
- 【sping揭秘】13、Spring AOP一世&二世
Spring AOP一世 Spring AOP中的advice Before advice 这个就是在方法执行之前执行,也就是在对应的joinpoint之前 spring AOP二世 开启aspect ...
- 【sping揭秘】25、Spring远程方案
分化:RMI,EJB,Hessian Spring有 Rmi,http,hessian,burlap 基于rmi的remoting方案 RMI要求远程类对象包路径和本地一致 基于HTTP的轻量级rem ...
- 【sping揭秘】24、Spring框架对JMS的集成(无环境版,以后学MQ的时候再隆重介绍)& 任务调度和线程池
这个我也不是很了解,那么这个需要好好学习一下了 JMS有2种消息域类型 1. point to point 点对点模式 2.发布订阅模式 publish/subscribe Pub/Sub 模式 传 ...
- 【sping揭秘】23、Spring框架内的JNDI支持
JndiTemplate 经过jdbctemplate,transactionTemplate...的洗礼,想必大家看到template就知道是个什么尿性了吧 一样的,我们只需要调用jnditempl ...
- 【sping揭秘】22、事务管理
有关事务的楔子 什么是事务??? 事务就是以可控的方式对数据资源进行访问的一组操作. 事务本身持有四个限定属性 原子性,一致性,隔离性,持久性 事务家族 Resource Manager RM,负责 ...
- 【sping揭秘】21、Spring动态数据源的切换
对于多个数据源的时候,我们如何切换不同的数据源进行数据库的操作呢? 当然我们可以直接定义2个DataSource,然后在每次获取connection的时候,从不同的DataSource中获取conne ...
- 【sping揭秘】20、spring的orm
面向对象的操作方式,spring统一定义在org.springframework.jdbc.object以RdbmsOperation作为顶层抽象定义 Spring对各种ORM的集成 Spring的集 ...
- 【sping揭秘】19、关于spring中jdbctemplate中的DataSource怎么来呢
我们这是可以正好借助之前学的factorybean类,自己吧jdbctemplate加载到spring容器中,我们可以封装多个这种对象,那么可以实现针对不同的数据库的jdbctemplate 首先我们 ...
随机推荐
- Cobbler安装CentOS7系统时报错 line 286: No space left on device
原因分析: 此报错并不是说磁盘空间不足,而是内存太小了. CentOS7安装系统时最小要2G以上内存,而当时我只给了1G. 所有报错,把内存加大到2G后可以正常安装系统.
- dede织梦动态页面通过手机模板实现wap浏览
https://jingyan.baidu.com/article/a948d6517be0eb0a2dcd2ebc.html
- HDU 5723 Abandoned country(kruskal+dp树上任意两点距离和)
Problem DescriptionAn abandoned country has n(n≤100000) villages which are numbered from 1 to n. Sin ...
- 366. Find Leaves of Binary Tree输出层数相同的叶子节点
[抄题]: Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all ...
- Java并发集合(一)-CopyOnWriteArrayList分析与使用
CopyOnWriteArrayList分析与使用 原文链接: http://ifeve.com/java-copy-on-write/ 一.Copy-On-Write Copy-On-Write简称 ...
- 图片利用 new Image()预加载原理 和懒加载的实现原理
二:预加载和懒加载的区别 预加载与懒加载,我们经常经常用到,这些技术不仅仅限于图片加载,我们今天讨论的是图片加载: 图片预加载:顾名思义,图片预加载就是在网页全部加载之前,提前加载图片.当用户需要查看 ...
- centos 网卡自动连接
/etc/sysconfig/network-scripts/目录下ifcfg-eth0这个文件,把ONBOOT="no"改为yes,
- 《C#从现象到本质》读书笔记(九)第11章C#的数据结构
<C#从现象到本质>读书笔记(九)第11章C#的数据结构 C#中的数据结构可以分为两类:非泛型数据结构和泛型数据结构. 通常迭代器接口需要实现的方法有:1)hasNext,是否还有下一个元 ...
- 《Miracle-House团队》第三次作业:团队项目的原型设计与开发
一.实验目的与要求 1.掌握软件原型开发技术 2.学习使用软件原型开发工具 二.实验内容与步骤 1.开发工具: 使用的工具:墨刀(APP端开发原型) 工具简介: 墨刀(MockingBot)是一款简单 ...
- 学习爬虫Scrapy遇到的错误
1. 这个问题是由于路径中含有中文,导致编码格式出错的问题, 查看错误方法,进入到ntpath.py文件中去,找到85行,然后,print 一下result_path,因为后面报出的错误,就是因为这段 ...