ProxyFactory的xml配置方式
来源:互联网 发布:软件开发毕业论文题目 编辑:程序博客网 时间:2024/05/29 08:47
在spring中配置,将所有的xml贴出来了,以及proxyFactory 所使用的一些属性解释:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
<bean id="greetingAdvice" class="com.web.spring.aop.example.beforadvice.GreetingBeforAdvice"/>
<bean id="target" class="com.web.spring.aop.example.beforadvice.NaiveWaiter"/>
<!--ProxyFactoryBean 是FactoryBean接口的实现类 -->
<bean id="waiter" class="org.springframework.aop.framework.ProxyFactoryBean"
p:proxyInterfaces="com.web.spring.aop.example.beforadvice.Waiter"
p:interceptorNames="greetingAdvice"
p:target-ref="target"
p:proxyTargetClass="true"
/>
<!--
1.proxyInterfaces代理所要实现的接口,可以是多个接口。该属性还有一个别名interfaces
2.interceptorNames需要织入目标对象的bean列表,采用Bean的名称指定。这些Bean必须实现了
org.aopalliance.intercept.MethodInterceptor或
org.springframework.aop.Advisor 的Bean,配置中的顺序对应调用的顺序。
3.singleton 返回的代理是否是简单实例,默认为单实例;
4.optimize 当设置成true 时,强制使用Cglib代理。
5.proxyTargetClass 是否对类进行代理(而不是对接口进行代理),设置为true时,使用CGLib代理。
-->
</beans>
此外,在xml配置文件中proxyTargetClass 设置为true后,无需再设置proxyInterfaces属性,即使设置也会被ProxyFactoryBean忽略。
main方法测试:
public static void main(String[] args) {
ApplicationContext applicationContext=new ClassPathXmlApplicationContext("proxyFcatory.xml");
Waiter waiter = (Waiter) applicationContext.getBean("waiter");
waiter.greetTo("John");
}
0 0
- ProxyFactory的xml配置方式
- ProxyFactory的xml配置方式
- ProxyFactory
- ProxyFactory
- SpringMVC的XML配置方式
- Log4J的XML格式配置方式例子
- dwr整合ssh的xml配置方式
- 配置xml方式实现Spring的aop
- 使用XML Schema的简化配置方式
- springmvc基于xml文件的配置方式
- 基于XML schema的简化配置方式
- 基于xml方式配置aop的配置文件
- Log4j2的XML和properties配置方式
- 十五Spring Aop的xml配置方式
- Spring 基于xml配置方式的事务
- spring-mvc.xml文件的配置方式
- web.xml文件的一种配置方式
- 基于XML Schema的简化配置方式
- 病毒—Win32/Gamarue
- -------------------Android代码优化——使用Android lint工具
- 携程编程大赛决赛-1004-最短路径的代价
- ant 打包android应用
- Linker Use static Libraries
- ProxyFactory的xml配置方式
- C语言里面的栈和堆
- Makefile文件变量的定义规则
- Python __new__与__init__说明
- struct 字节对齐详解
- android开发笔记之一些有用资料的汇总
- ACM中java的使用
- 上午9时15分许,习近平来到空军机关指挥楼
- Spring MVC框架