使用Adivisor配置增强处理
使用Adivisor配置增强处理
实现步骤:
1、通过MethodBeforeAdivice接口实现前置增强处理
public class ServiceBeforeAdvisor implements MethodBeforeAdvice {
private Logger logger = Logger.getLogger(ServiceBeforeAdvisor.class);
@Override
public void before(Method method, Object[] args, Object target)
throws Throwable {
logger.info("启动事务");
logger.info("连接点对象:"+target.getClass().getSimpleName());
logger.info("连接点方法:"+method.getName());
logger.info("连接点方法参数:"+args[0]);
}
}
2、使用<aop:advisor>标签织入增强处理
//注意:advisor要放在aspect前面
<bean id="userService" class="com.pb.service.UserService"></bean>
<bean id="serviceBeforeAdvisor" class="com.pb.aop.ServiceBeforeAdvisor"></bean>
<aop:config>
<aop:pointcut expression="execution(public * com.pb.service.*.*(..))"
id="servicePointcut"/>
<aop:advisor advice-ref="serviceBeforeAdvisor" pointcut-ref="servicePointcut"/>
</aop:config>
测试类
public class Test {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext
("applicationContext.xml");
UserService service = (UserService)context.getBean("userService");
service.addUser(new User());
}
}
使用Adivisor配置增强处理的更多相关文章
- 使用Adivisor配置增强处理,来实现数据库读写分离
一.先写一个demo来概述Adivisor的简单使用步骤 实现步骤: 1.通过MethodBeforeAdivice接口实现前置增强处理 public class ServiceBeforeAdvis ...
- springmvc-servlet.xml(springmvc-servlet.xml 配置 增强配置)
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- 关于xml配置实现AOP的小知识
除了前面介绍的基于JDK1.5的注解方式来定义切面,切入点和增强处理外,Spring AOP也允许直接使用XML配置文件来管理它们.在JDK1.5之前,只能使用配置文件的方式来管理,在Spring2. ...
- 【转】Gvim开发环境配置笔记--Windows篇
配置文件(vimrc) set nocompatible set nu! set cursorline colorscheme murphy " vim 自身命令行模式智能补全 set wi ...
- SAP 增强-出口选找方法-全部
■ SAP 中如何寻找增强 方法一:利用TCODE寻找增强(第二代的增强) 执行一个程序(源代码后附),在选择屏幕处输入你所需要增强的程序TCODE,执行後,就会出现一个列表,那里就有关于如何增强这个 ...
- spring配置详解
1.前言 公司老项目的后台,均是基于spring框架搭建,其中还用到了log4j.jar等开源架包.在新项目中,则是spring和hibernate框架均有使用,利用了hibernate框架,来实现持 ...
- BTE 增强
BTE的设计思路还是比较简单,和BADI有点类似.在标准程序中留有OPEN_FI的出口(以函数OPEN_FI_PERFORM_event id_type的形式存在),然后提供一个可配置的TABLE,可 ...
- spring,springmvc,mybatis基本整合(一)--xml文件配置方式(1)
**这个整合.仅仅是最主要的整合,而且是xml配置文件的方式之中的一个,即当中的mybatis是採用非mapper接口的方式.(第二遍採用mapper接口方式.第三遍採用注解的方式:第四篇採用注解基于 ...
- Spring事物管理--相关要点及配置事物管理器
事务的四大特征 1.原子性:一个事务中所有对数据库的操作是一个不可分割的操作序列,要么全做要么全不做 2.一致性:数据不会因为事务的执行而遭到破坏 3.隔离性:一个事物的执行,不受其他事务的干扰,即并 ...
随机推荐
- DataTable数据集转换为List非泛型以及泛型方式
前言 DataTable是断开式的数据集合,所以一旦从数据库获取,就会在内存中创建一个数据的副本,以便使用.由于在实际项目中,经常会将DataTable中的每行数据转换为Model,然后放到List集 ...
- Tomcat中部署后JspFactory报异常的解决方案
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory的异常的原因及解决办法原 ...
- [CareerCup] 5.3 Next Binary Representation 下一个二进制表达
5.3 Given a positive integer, print the next smallest and the next largest number that have the same ...
- Lisp简明教程
此教程是我花了一点时间和功夫整理出来的,希望能够帮到喜欢Lisp(Common Lisp)的朋友们.本人排版很烂还望多多海涵! <Lisp简明教程>PDF格式下载 <Lisp简明教程 ...
- 类似IOS的滑动返回上一级,SwipeBackLayout-android的滑动返回类库
最近,公司在开发App的需求中增加了一个新的需求,要在android的页面中增加向右滑动的时候返回上一级页面.我刚知道这个需求的时候,感觉有点坑,可能设计那边最近接触到知乎的客户端或者是IOS的滑动可 ...
- Orchard内置特性(以模块来说的)
本文链接:http://www.cnblogs.com/souther/p/4539169.html 主目录 Orchard中有很多可以直接和多次使用的特性,这些东西在官方的Gallery中可以找到. ...
- [codevs1283]等差子序列(二进制)
题目:http://codevs.cn/problem/1283/ 分析: 主要就是在每个判定上节省时间.一般的做法是开个数组记录每个数字出没出现,然后每次读入一个数字就以他为中间向两边扩展直到两个对 ...
- [bzoj 1503][NOI 2004]郁闷的出纳员(平衡树)
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1503 分析: 经典的平衡树题,我用Treap做的 下面有几点注意的: 1.可能出现新加入的人的 ...
- WeisEditor 3.2.1B 使用说明 [源码下载]
WeisEditor 使用说明 1. 首先打开(Weiseditor)编辑器文件夹下js/config.js 如果此时你的项目是一个虚拟目录项目 WeisConfig.isVirtualPath = ...
- please tell me the error about java Graphics
this is the code: public class paint extends JFrame{ public paint(){ setLayout(new FlowLayout()); se ...