程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA綜合教程 >> Spring 接口代理 類代理,spring接口代理

Spring 接口代理 類代理,spring接口代理

編輯:JAVA綜合教程

Spring 接口代理 類代理,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!

 

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved