首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Spring 3.x企业应用开发实战(十)-AOP切面

2013-09-28 
Spring 3.x企业应用开发实战(10)----AOP切面1、静态普通方法名匹配切面StaticMethodMatcherPointcutAdvisor

Spring 3.x企业应用开发实战(10)----AOP切面

1、静态普通方法名匹配切面

StaticMethodMatcherPointcutAdvisor代表一个静态方法匹配切面。

package com.smart.advisor;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;public class SpringAdvisorTest {@Testpublic void testAdvisor(){String configPath="com/smart/advisor/beans4.xml";ApplicationContext ctx=new ClassPathXmlApplicationContext(configPath);Waiter waiter=(Waiter)ctx.getBean("waiterTarget");Seller seller=(Seller)ctx.getBean("sellerTarget");waiter.serveTo("John");waiter.greetTo("John");seller.greetTo("Tom");}}

得到的结果是:

Waiter serving John...
com.smart.advisor.Waiter.greetTo
How are you ! Mr.John.
Waiter greet to John...
com.smart.advisor.Seller.greetTo
How are you ! Mr.Tom.
Seller greet to Tom...


热点排行