Spring ProxyFactory
来源:互联网 发布:java软件工程培训 编辑:程序博客网 时间:2024/06/05 09:01
ProxyFactory 是 Spring AOP的实现方式之一。下面介绍下ProxyFactory的用法。
1、接口定义
public interface UserReadService { public UserInfo getUserInfoById(Long id);}
2、接口实现
public class UserReadServiceImpl implements UserReadService { @Override public UserInfo getUserInfoById(Long id) { System.out.println("获取用户信息"); return null; }}
3、拦截器定义
public class UserInterceptor implements MethodInterceptor { @Override public Object invoke(MethodInvocation invocation) throws Throwable { System.out.println("start"); Object obj = invocation.proceed(); System.out.println("end"); return obj; } }
4、测试
public static void main(String[] args) { ProxyFactory factory = new ProxyFactory(new UserReadServiceImpl()); factory.addAdvice(new UserInterceptor()); UserReadService userReadService = (UserReadService) factory.getProxy(); userReadService.getUserInfoById(null); }
结果:
start获取用户信息end
0 0
- Spring ProxyFactory
- Spring ProxyFactory
- Spring中的AOP-ProxyFactory
- ProxyFactory
- ProxyFactory
- Spring aop编程ProxyFactory切入点运行原理。
- 在Eclipse RCP中使用Spring AOP/ProxyFactory的问题
- 浅析Spring AOP源码(十六) 分析ProxyFactory
- 剖析ProxyFactory
- 做一个合格的程序猿之浅析Spring AOP源码(十六) 分析ProxyFactory
- 理解Spring AOP 原理(二)JDK,CGLIB动态代理以及ProxyFactory
- Spring Aop(十一)—— 编程式的创建Aop代理之ProxyFactory
- JDK、CGLIB、Sring 三种实现代理的区别(三)Spring的ProxyFactory
- springAOP之ProxyFactory
- ProxyFactory的xml配置方式
- ProxyFactory的xml配置方式
- jboss resteasy client ProxyFactory 自动化测试架构
- SpringAPI手动创建代理对象——ProxyFactory
- &12-2 查找二叉搜索树
- 搭建maven+spring+mybatis工程
- lca最近公共祖先(st表/倍增)
- Ajax实现xml文件数据插入数据库(二)--- ajax实现与jsp的数据交互
- 我们这样
- Spring ProxyFactory
- 文件属性的宏定义
- 背包dp
- Spring ApplicationContextAware获取上下文
- 用opencv的traincascade训练检测器
- 世界以痛吻我,我要报之以歌
- spring aop 的一个demo(未完,待完善)
- nginx日常维护常用命令
- 批量修改string中的字符