一般我们可以使用ProxyBeanFactory,并配置proxyInterfaces,target和interceptorNames实现,但如果需要代理的bean很多,无疑会对spring配置文件的编写带来繁重的工作,这时就该BeanNameAutoProxyCreator出场了。

(一)ProxyFactoryBean属性介绍 

target:代理的目标类
proxyInterfaces:代理类应该实现的接口列表
interceptorNames:需要应用到目标对象上的通知Bean的名字.可以是拦截器,advisor和其他通知类型的名字。这个属性必须按照在BeanFactory中的顺序设置
singleton:单例
aopProxyFactory:使用的ProxyFactoryBean实现。Spring带有两种实现(JDK动态代理和CGLIB)。通常不需要使用这个属性
exposeProxy:目标对象是否需要得到当前的代理。通过调用AopContext.getCurrentProxy实现。
frozen:一旦工厂被创建,是否可以修改代理的通知。当设置为true时,在运行时就不能修改ProxyFactoryBean了。通常不需要使用这个属性。
optimize:是否对创建的代理进行优化(只适用于CGLIB)
ProxyTargetClass:是否代理目标类,而不是实现接口。只能在使用CGLIB时使用

现在说下ProxyBeanFactory的用法以及配置:

ITest.class

public interface ITest {
    void tst();
    void tst(int status,String name);
}

TestProxyFactoryBean.class


public class TestProxyFactoryBean implements ITest {

    @Override
    public void tst() {
        // TODO Auto-generated method stub
        System.out.println("执行方法.");
    }     @Override
    public void tst(int status, String name) {
        System.out.println("tst(int status, String name)" );
        
    } }

LoggerAdvice.class


/**
 * 日志代理
 * @author Administrator
 *
 */
public class LoggerAdvice implements MethodBeforeAdvice, AfterReturningAdvice {     @Override
    public void afterReturning(Object returnValue, Method method,
            Object[] args, Object target) throws Throwable {
         Logger logger = Logger.getLogger(target.getClass());
          if(returnValue != null){
              logger.debug("+-------Return : " + returnValue.toString());
          }
        
    }     @Override
    public void before(Method method, Object[] args, Object target)
            throws Throwable {
        // TODO Auto-generated method stub
          Logger logger = Logger.getLogger(target.getClass());
          logger.debug("+Class : "+ target.getClass().getName());
          logger.debug("+-------Method : "+ method.getName());
          for(int i=0; i<args.length; i++){
           logger.debug(" +-arg"+ i + " : " + args[i].toString());
          }
        
    } }

Xml配置:


<bean class="spring.aop.TestProxyFactoryBean" id="testproxyfactorybean"/> 

<bean class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="proxyInterfaces" value="spring.aop.ITest"></property>
    <property name="interceptorNames" >      <list>
      <value>loggerAdvice</value>
     </list>     </property>     <property name="target" ref="testproxyfactorybean"></property>
    </bean>
 
Program.class
public static void main(String[] args){
        context.getBean("proxyBean",ITest.class).tst();
        context.getBean("proxyBean",ITest.class).tst(1,"123");
    }

执行结果:


2012-08-14 14:57:30 [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Returning cached instance of singleton bean 'proxyBean'
2012-08-14 14:57:30 [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Returning cached instance of singleton bean 'loggerAdvice'
2012-08-14 14:57:30 [org.springframework.aop.framework.ProxyFactoryBean]-[DEBUG] Advice has changed; recaching singleton instance
2012-08-14 14:57:30 [org.springframework.aop.framework.JdkDynamicAopProxy]-[DEBUG] Creating JDK dynamic proxy: target source is SingletonTargetSource for target object [spring.aop.TestProxyFactoryBean@11978b]
2012-08-14 14:57:30 [spring.aop.TestProxyFactoryBean]-[DEBUG] +Class : spring.aop.TestProxyFactoryBean
2012-08-14 14:57:30 [spring.aop.TestProxyFactoryBean]-[DEBUG] +-------Method : tst
执行方法.
2012-08-14 14:57:30 [org.springframework.beans.factory.support.DefaultListableBeanFactory]-[DEBUG] Returning cached instance of singleton bean 'proxyBean'
2012-08-14 14:57:30 [spring.aop.TestProxyFactoryBean]-[DEBUG] +Class : spring.aop.TestProxyFactoryBean
2012-08-14 14:57:30 [spring.aop.TestProxyFactoryBean]-[DEBUG] +-------Method : tst
2012-08-14 14:57:30 [spring.aop.TestProxyFactoryBean]-[DEBUG]  +-arg0 : 1
2012-08-14 14:57:30 [spring.aop.TestProxyFactoryBean]-[DEBUG]  +-arg1 : 123
tst(int status, String name)
 
(二)BeanNameAutoProxyCreator属性介绍 

target:代理的目标类

beanNames:需要代理的bean的列表

interceptorNames:需要应用到目标对象上的通知Bean的名字.可以是拦截器,advisor和其他通知类型的名字。这个属性必须按照在BeanFactory中的顺序设置


<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  <property name="interceptorNames">
   <list>
    <value>loggerAdvice</value>
   </list>
  </property>
  <property name="beanNames">
   <list>
    <idref local="testproxyfactorybean" />
   </list>
  </property>
 </bean>

调用代码:

public static void main(String[] args){
        
        context.getBean("testfunc",TestFunc.class).test("project", 100);
        context.getBean("testfunc",TestFunc.class).test1("project1");
    }
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAn4AAACiCAIAAABQ0VdKAAAgAElEQVR4nO1dwbnzKrJ0MBOFA9J2UtF2di+I+ymDF8CsncTLwG9xbAnoqqYRkizZVZt7f1tAddN0ATqG23/++e//CYIgCIJwFG7/+ee//yMIgiAIwlG4/eef/z4FQRAEQTgKkl5BEARBOBSS3svhMd5vfximT3Px8RjvXSQXS+/jY0Ne2+Ex3oMGTsPnu+v8/vxWrPf8NHQP9t5haBmByjbg+WWYPUK6PJdeGCE4bF6fZo6OBxh8cuZa70DUevJFrftt8YVQvfVO8txLYfIXyZydY34aTi8Rl5LeLn/GLb00Ymamgz3ild5ItqwAT5oXosMw2MVOJEdqaPVdCFmla2rdLbx5tk6l9zHeX60/xvs7VqZhNmWh9xdKBV1YHILVOVfmhypsff5mGCpOZOSDrmdeipO3tsfJP68kvX24QrK/kvT2+fMKvbEBwtL7HoIRXev2XZ/0rm8Fol96348kubAT3aPrw9KbYHZKGWQxufJ9iuvMhaweRLZ1Lsn14r4tVTM5+aI49WecPOrMZNGeTgGG0WxO5/NDz81Jne/HsirnsrAhtAGFi1tK+RZEVqfT0C3pjPs4Drfb7fWfdK6TPmm8PfdO1J9LDbUdi2m4DdOb62I7achM4InrQB/5PVlxnSEwTKB4HsE1L+UT8dq0nETdtHy7zNSNQ+peqvCEZlpkYzyxyDTU4nloJvg34wmTPN4HNk5mdVKeNpIRb+T5XHrn8n0DAUrvKcK7VXpnF87/Mw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ldzuk3CpLH/XTmvBt0JEal0MwU4ZyYhvyaf0Ob92+C+uk93icgMILuwQYa2mTqNMiVVgJSe/lcBLpjez9BSv90twl6W3FLgHGWtooeL81eoWdIem9HJaNqtq++uZJIdvI3Shdf6P0JhusAen93AZjA89jsEeAQfRFXULz62JXOAiSXkEQBEE4FJJeQRAEQTgUkl5BEARBOBRXkN7w74UFQRAE4fz4bumFf/r/wIcMCoIgCMIhyKV3GpKzD8j5Z8NJ/hgyAiu9k27mEgRBED6LRXr/Tkkbh9ttmB7jOD0f88W0z+esyo9xfJ3eNNala9LNXIIgCIJQIF31TtM0DcP0GO/vu7mSo1+n8XWqbZv06mYuQRAEQciQr3r/lof3YRiG+zhN0zQrrFlERqRrh+tBSh66mUsQBEG4GIo/s5rGv+tjb7fbME3jOL2l97XoXVa7j8dL6hwZ081cgiAIglACrHqHYRwfj3HMpXcY8o3myI6zbuYSBEEQhBL/DyP46qUndcdzAAAAAElFTkSuQmCC" alt="" />
 
出处:http://www.cnblogs.com/65702708/archive/2012/08/14/2638043.html

【Spring】25、Spring代理。 BeanNameAutoProxyCreator 与 ProxyFactoryBean的更多相关文章

  1. Spring BeanNameAutoProxyCreator 与 ProxyFactoryBean区别

    一般我们可以使用ProxyBeanFactory,并配置proxyInterfaces,target和interceptorNames实现,但如果需要代理的bean很多,无疑会对spring配置文件的 ...

  2. 使用BeanNameAutoProxyCreator实现spring的自动代理

    提到代理,我们可以使用ProxyBeanFactory,并配置proxyInterfaces,target和interceptorNames实现,但如果需要代理的bean很多,无疑会对spring配置 ...

  3. Spring中的代理模式

    代理模式 所谓代理,就是一个人或者一个机构代表另一个人或者另一个机构采取行动.在一些情况下,一个客户不想或者不能够直接引用一个对象,而代理对象可以在客户端和目标对象之间起到中介的作用. 代理模式是一种 ...

  4. Spring框架_代理模式(静态代理,动态代理,cglib代理)

    共性问题: 1. 服务器启动报错,什么原因? * jar包缺少.jar包冲突 1) 先检查项目中是否缺少jar包引用 2) 服务器: 检查jar包有没有发布到服务器下:                 ...

  5. spring设计模式_代理模式

    代理模式应该是Spring核心设计模式之一了 先说下代理模式特性: 1.有代理人和被代理人 2.对于被代理的人来说,这件事情是一定要做的,但是我又不想做,所有就找代理人来做. 3.需要获取到被代理人的 ...

  6. spring aop 的代理工厂

    参考 https://docs.spring.io/spring/docs/4.3.11.RELEASE/spring-framework-reference/htmlsingle/#aop-unde ...

  7. spring AOP 动态代理和静态代理以及事务

    AOP(Aspect Oriented Programming),即面向切面编程 AOP技术,它利用一种称为"横切"的技术,剖解开封装的对象内部,并将那些影响了多个类的公共行为封装 ...

  8. Hibernate 延迟加载的代理模式 和 Spring AOP的代理模式

    Hibernate 延迟加载的代理模式 和 Spring AOP的代理模式 主题 概念 Hibernate 延迟加载的代理模式 Spring AOP的代理模式 区别和联系 静态代理和动态代理 概念 代 ...

  9. 解决spring使用动态代理

    解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ... 转 ...

  10. 死磕Spring之AOP篇 - Spring AOP自动代理(一)入口

    该系列文章是本人在学习 Spring 的过程中总结下来的,里面涉及到相关源码,可能对读者不太友好,请结合我的源码注释 Spring 源码分析 GitHub 地址 进行阅读. Spring 版本:5.1 ...

随机推荐

  1. swiper,一个页面使用多个轮播

    代码示例: <html> <head> <link href="https://cdn.bootcss.com/Swiper/4.3.0/css/swiper. ...

  2. ubuntu上vsftpd服务配置

    Ubuntu上提供两种常用的ftp服务应用:vsftpd 和 tftpd,区别如下: 1)vsftpd 支持客户端上下传文件,支持浏览器显示及下载,支持用户名密码认证,支持匿名访问,默认端口TCP:2 ...

  3. 移植U-Boot时遇到的问题

    1. 在lowlevel_init过程中,本来想实现一个串口直接打印字符串的过程,编译的时候出现了问题,说是发现代码执行段没有对齐:“unaligned opcodes detected in exe ...

  4. Mysql中比较常用的两种存储引擎和事务

    存储引擎:引擎(类似汽车上的发动机)决定了数据库的快慢,MySql中有20多个引擎,不同的存储引擎提供不同的存储机制.索引技巧.锁定水平.MYISAM存储引擎,INNODB存储引擎最出名.数据库的核心 ...

  5. Alpha冲刺-(9/10)

    Part.1 开篇 队名:彳艮彳亍团队 组长博客:戳我进入 作业博客:班级博客本次作业的链接 Part.2 成员汇报 组员1(组长)柯奇豪 过去两天完成了哪些任务 进一步优化代码,结合自己负责的部分修 ...

  6. 《mysql必知必会》学习_第22章_20180809_欢

    第22章:使用视图,视图是虚拟的表,以表形式呈现的是你查询的结果.并不是说在数据库里面真的存在这个表,但是是真的存在这些数据. select cust_name,cust_contact from c ...

  7. jzoj3156. 【GDOI2013模拟1】病毒传播

    题意: 村庄里有m个人,初始有一些人感染了病毒.如果第i个人的编号i满足,有一对(a,b)(a是初始病毒感染者编号,b为前一天的感染者编号)使\(a*b mod m =i\),则第i个人会感染病毒.每 ...

  8. PICE(4):MongoDBStreaming - gRPC Protobuf conversion

    前两篇我们介绍了JDBC和Cassandra的gRPC streaming实现.相对MongoDB来说,JDBC和Cassandra支持字符类型的query语句SQL,CQL,所以把query指令转换 ...

  9. 关于No mapping found for HTTP request with URI...

    当你看到这篇博客,说明你已经像我一样快疯了!但是还好..找到了!!! 网上的那些东西真心看了更闹心,因为还没解决... 原因一.访问路径确实错了,导致Dispatcher找不到给你传达的地方,修改下领 ...

  10. mybatis-plus代码生成器

    public class MyBatisPlusGenerator { public static void main(String[] args) throws SQLException { //1 ...