Spring 接口代理 类代理
1.Question Description :
when you use @Transactional annotation and @RequiresPermissions annotation (about shiro) together,
you will find the @RequiresPermissions annotation donot work, why?
2. Explain:
It's caused by the Proxy Mechanism of Spring, because the Spring framework preference for Interface Proxy than Class Proxy,
the method of the class ExampleServiceImpl was agented several times.
Let's look the two kinds of Interface.
2.1 @Transactional Annotation:
It was based on the Interface Proxy default, so it will produce Proxy Object One just like ExampleServiceImpl$$;
2.2 @RequiresPermissions :
It was based on the Interface Proxy default too, but it produces Proxy Object Two based on Proxy Object One just like ExampleServiceImpl$$$$,
that is a really Class Proxy.
2.3 when the two kinds of Proxy way exist together, the Classs Proxy will out of action.
3. Solution:
we should change its Proxy Way, as follows:

and the same time, change the Proxy Way of Spring, as follows:

then @RequiresPermissions Annotation works!
Spring 接口代理 类代理的更多相关文章
- 如何获取hibernate代理类代理的实际对象实例?
在hibernate中,通过sql语句查询带clob字段的记录,查出来的结果集是List<HashMap<String,Object>>类型,在调用jackson的接口转为js ...
- AOP 代理类的创建
AOP 代理类的创建 入口:AnnotationAwareAspectJAutoProxyCreator#postProcessAfterInitialization 和 AnnotationAwar ...
- Spring学习之动态代理的简单实现
先说一下代理模式的好处 1.可以使真实角色的操作更加纯粹,不用去关注一些公共的业务 2.公共的交给代理角色,实现了业务的分工 3.公共业务发生扩展的时候,方便集中管理 静态代理模式的缺点 1.一个真实 ...
- .net 代理类(WebService代理类的详解 )
http://hi.baidu.com/654085966/item/53ee8c0f108ad78202ce1b1d -----------转自 客户端调用Web Service的方式我现在知道 ...
- 啰里吧嗦式讲解java静态代理动态代理模式
一.为啥写这个 文章写的比较啰嗦,有些东西可以不看,因为想看懂框架, 想了解SSH或者SSM框架的设计原理和设计思路, 又去重新看了一遍反射和注解, 然后看别人的博客说想要看懂框架得先看懂设计模式,于 ...
- Spring只定义接口自动代理接口实现类
能够扫描到包 @ComponentScan("org.zxp.esclientrhl") ESCRegistrar类主要实现ImportBeanDefinitionRegistra ...
- 在spring中获取代理对象代理的目标对象工具类
昨天晚上一哥们需要获取代理对象的目标对象,查找了文档发现没有相应的工具类,因此自己写了一个分享给大家.能获取JDK动态代理/CGLIB代理对象代理的目标对象. 问题描述:: 我现在遇到个棘手的问题,要 ...
- spring 依赖注入时,什么时候会创建代理类
问题来源 以前一直有个疑惑,为什么我创建的controller中注入的service类有时候是代理类,有时候是普通javabean,当时能力不够,现在已经有了点经验就大胆跟了跟源码,看看到底咋回事. ...
- spring AbstractBeanDefinition创建bean类型是动态代理类的方式
1.接口 Class<?> resourceClass 2.获取builder BeanDefinitionBuilder builder = BeanDefinitionBuilder. ...
随机推荐
- mac安装 配置 ant
转自:http://blog.sina.com.cn/s/blog_877e9c3c0101qs87.html 1.下载ant 官网下载 http://ant.apache.org/bindownlo ...
- Apache配置多个网站的方法
Apache的虚拟主机是一种允许在同一台机器上,运行超过一个网站的解决方案.虚拟主机有两种,一种叫基于IP的(IP-based),另一种叫基于名字的(name-based).虚拟主机的存在,对用户来说 ...
- JAVA 多线程编程之一(基础)
1.原子变量(java.util.concurrent.atomic) 原子状态,变化不会被打断,如 AtomicLong , AtomicInteger 2.内部锁 synchronized 块 ...
- angularjs + seajs构建Web Form前端(一)
简介 Bootstrap是Twitter推出的一个用于前端开发的开源工具包,它由Twitter的设计师Mark Otto和Jacob Thornton合作开,是一个CSS/HTML框架. Angula ...
- HTML5[7]: 实现网页版的加载更多
理所当然,jQuery出场: $(function() { $(window).scroll(function() { if($(this).scrollTop() + $(this).innerHe ...
- sublime text 3安装package console
打开Packages目录,Preferences > Browse Packages 就可以进入这个目录. $ cd Packages/$ git clone https://github.co ...
- `cocos2dx非完整` 日志模块 增量更新
在上一篇文章中,说到了"流程"的由来,以及我对流程的使用. 这一片就是对流程的应用.前一篇文章中说到了三条流程 check_log_measure, check_env_measu ...
- ubuntu remove mysql
ubuntu 彻底删除 mysql 然后重装 mysql 删除 mysql sudo apt-get autoremove --purge mysql-server-5.0sudo apt-get r ...
- ruby -- 基础学习(三)设置中国时区时间
Rails连接MYSQL数据库,默认显示UTC时间.如果想要改成中国时区时间,按照下面修改: 在config/application.rb中找到 class Application < Rail ...
- 关于全局唯一ID生成方法
引:最近业务开发过程中需要涉及到全局唯一ID生成.之前零零总总的收集过一些相关资料,特此整理以便后用 本博客已经迁移至:http://cenalulu.github.io/ 本篇博文已经迁移,阅读全文 ...