Spring 切面 AOP基础 之三
来源:互联网 发布:知乎公司地址邮编 编辑:程序博客网 时间:2024/05/30 13:41
螃蟹在剥我的壳,脚往杯上落,茶叶煮着温泉,而代码在撸我。看见一手动人的小诗,仿写了一手,上回说到锋利的切面AOP,这里对他进行自动代理,灰常的powerfull。
1、通常手写对Service的代理十分繁琐,可以用BeanNameAutoProxyCreator去根据名字自动代理,还有个DefaultAdvisorAutoProxyCreator更具Advicer匹配成功自动创建代理。
Spring-Customer.xml
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="customerService" class="com.mkyong.customer.services.CustomerService" > <property name="name" value="Yong Mook Kim" /> <property name="url" value="http://www.mkyong.com" /> </bean> <bean id="hijackAroundMethodBeanAdvice" class="com.mkyong.aop.HijackAroundMethod" /> <!--<bean id="customerServiceProxy"class="org.springframework.aop.framework.ProxyFactoryBean"><property name="target" ref="customerService" /><property name="interceptorNames"><list><value>customerAdvisor</value></list></property></bean>--><bean id="customerAdvisor"class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor"><property name="mappedName" value="printName" /><property name="advice" ref="hijackAroundMethodBeanAdvice" /></bean><!--<bean id="customerAdvisor"class="org.springframework.aop.support.RegexpMethodPointcutAdvisor"><property name="patterns"><list><value>.*URL.*</value></list></property><property name="advice" ref="hijackAroundMethodBeanAdvice" /></bean>--><!-- auto proxy creator --><bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"><property name="beanNames"><list><value>*Service</value></list></property><property name="interceptorNames"><list><value>customerAdvisor</value></list></property></bean><!-- <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" /> --></beans>
0 0
- Spring 切面 AOP基础 之三
- Spring之面向切面编程AOP(三)
- Spring 切面 AOP基础 之二
- Spring 切面 AOP基础 之四
- Spring AOP之切面
- Spring 切面 AOP基础 之一
- JAVAEE之Spring学习(三)---aop切面(一)
- JAVAEE之Spring学习(三)---通过aop切面实现事务处理
- spring之Aop面向切面
- spring系列(三):切面编程(aop)1
- spring aop切面编程基础实例
- Spring基础 导入AOP+自定义标签切面
- Spring AOP---切面编程基础(动态代理)
- Spring AOP切面基于注解基础学习
- Spring之AOP实现面向切面编程
- 循序渐进之Spring AOP(5) - 创建切面
- Spring AOP 之 实现切点、切面
- Spring之AOP,面向切面编程
- 树莓派拍照上传yeelink
- 黑马程序员_C语言指针
- day14/HashSetTest.java
- Cocos2d-x helloworld执行分析
- JSP_通过表格显示数据库的信息
- Spring 切面 AOP基础 之三
- 网站架构模式
- CSU1613: Elephants(分组背包)
- iOS 知识树参考
- android线程相关
- day14/LinkedListDemo.java
- 今日收获 --- 场景中大量集合体的优化
- 归并排序
- 自定义ProgressDialog(无遮罩效果)