Spring ProxyFactory
来源:互联网 发布:游戏俱乐部书生数据 编辑:程序博客网 时间:2024/06/05 15:32
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
- java注解
- chrome插件
- spring jdbcTemplate源码剖析
- 求最大公约数最小公倍数
- 搭建maven+spring+mybatis工程
- Spring ProxyFactory
- Spring ApplicationContextAware获取上下文
- operator重写
- 第三十一、Java面向对象三大特征之多态
- spring aop 的一个demo(未完,待完善)
- spring InitializingBean接口
- java定时任务接口ScheduledExecutorService
- ThymeLeaf通过模板转换对象(根据模板和map生成)
- svn 常用命令