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 接口代理 类代理的更多相关文章

  1. 如何获取hibernate代理类代理的实际对象实例?

    在hibernate中,通过sql语句查询带clob字段的记录,查出来的结果集是List<HashMap<String,Object>>类型,在调用jackson的接口转为js ...

  2. AOP 代理类的创建

    AOP 代理类的创建 入口:AnnotationAwareAspectJAutoProxyCreator#postProcessAfterInitialization 和 AnnotationAwar ...

  3. Spring学习之动态代理的简单实现

    先说一下代理模式的好处 1.可以使真实角色的操作更加纯粹,不用去关注一些公共的业务 2.公共的交给代理角色,实现了业务的分工 3.公共业务发生扩展的时候,方便集中管理 静态代理模式的缺点 1.一个真实 ...

  4. .net 代理类(WebService代理类的详解 )

    http://hi.baidu.com/654085966/item/53ee8c0f108ad78202ce1b1d   -----------转自 客户端调用Web Service的方式我现在知道 ...

  5. 啰里吧嗦式讲解java静态代理动态代理模式

    一.为啥写这个 文章写的比较啰嗦,有些东西可以不看,因为想看懂框架, 想了解SSH或者SSM框架的设计原理和设计思路, 又去重新看了一遍反射和注解, 然后看别人的博客说想要看懂框架得先看懂设计模式,于 ...

  6. Spring只定义接口自动代理接口实现类

    能够扫描到包 @ComponentScan("org.zxp.esclientrhl") ESCRegistrar类主要实现ImportBeanDefinitionRegistra ...

  7. 在spring中获取代理对象代理的目标对象工具类

    昨天晚上一哥们需要获取代理对象的目标对象,查找了文档发现没有相应的工具类,因此自己写了一个分享给大家.能获取JDK动态代理/CGLIB代理对象代理的目标对象. 问题描述:: 我现在遇到个棘手的问题,要 ...

  8. spring 依赖注入时,什么时候会创建代理类

    问题来源 以前一直有个疑惑,为什么我创建的controller中注入的service类有时候是代理类,有时候是普通javabean,当时能力不够,现在已经有了点经验就大胆跟了跟源码,看看到底咋回事. ...

  9. spring AbstractBeanDefinition创建bean类型是动态代理类的方式

    1.接口 Class<?> resourceClass 2.获取builder BeanDefinitionBuilder builder = BeanDefinitionBuilder. ...

随机推荐

  1. CHECK MEMBER TYPE

    检查类里是否存在某种类型的几种方法,以检查xxx类型为例:方法1: template<class T> class has_member_type_Type { ]; }; templat ...

  2. postgresql 获取刚刚插入的数据主键id

    postgresql不支持last_insert_id()方法,恶心到啦: 不过还好它有其他的解决方案: 创建一个测试数据表: CREATE TABLE test.test18 ( id serial ...

  3. iOS开发之时间格式的转化

    在开发iOS程序时,有时候需要将时间格式调整成自己希望的格式,这个时候我们可以用NSDateFormatter类来处理. 例如:如何将格式为“12-May-14 05.08.02.000000 PM” ...

  4. 提高Java代码质量:使用枚举定义常量(转)

    一.分析  常量的声明是每一个项目中不可或缺的,在Java1.5之前,我们只有两种方式的声明:类常量和接口常量.不过,在1.5版之后有了改进,即新增了一种常量声明方式,枚举常量.代码如下: enum ...

  5. Ubuntu桌面版本和服务器版本之间的区别(转载)

    转载自:http://blog.csdn.net/fangaoxin/article/details/6335992 http://www.linuxidc.com/Linux/2010-11/297 ...

  6. .NET面试必备(整理)

    1.简述 private. protected. public. internal 修饰符的访问权限. private : 私有成员, 在类的内部才可以访问.public : 公共成员,完全公开,没有 ...

  7. [转]c#截取指定长度的字符串

    /// <summary> /// 截取指定長度的字符串 /// </summary> /// <param name="s"></par ...

  8. 【JAVA】"骗人"的“replaceAll”

    Java String类中有个方法叫:replaceAll,从表面上看,他的意思是把所有的regex替换成replacement. public String replaceAll(String re ...

  9. log4net各种Filter使用

    log4net里面的filter类常用的为: 1.DenyAllFilter 拒绝所用的日志输出 <filter type="log4net.Filter.LevelMatchFilt ...

  10. 充实你的素材库!10款免费的 PSD 素材下载

    由于网页设计师没有时间来自己从零开始设计,所以在设计项目中使用网络上已有的设计素材是常见的方式.这就是为什么我们经常会到网上搜索可以免费下载的素材. 今天,我们这里有几套不同的免费的 PSD 素材分享 ...