Spring-AOP解析

Spring.xml配置文件

<bean id="helloWorldService" class="cn.javass.spring.chapter6.service.impl.HelloWorldService"/>
<bean id="aspect" class="cn.javass.spring.chapter6.aop.HelloWorldAspect"/> <aop:config> <aop:pointcut id="pointcut" expression="execution(* cn.javass..*.*(..))"/> <aop:aspect ref="aspect"> <aop:before pointcut-ref="pointcut" method="beforeAdvice"/> <aop:after pointcut="execution(* cn.javass..*.*(..))" method="afterFinallyAdvice"/> </aop:aspect> </aop:config>

test測試類

@Test  
    public void testHelloworld() {  
        ApplicationContext ctx =  new ClassPathXmlApplicationContext("chapter6/helloworld.xml");  
        IHelloWorldService helloworldService =  
        ctx.getBean("helloWorldService", IHelloWorldService.class);  
        helloworldService.sayHello();  
    } 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章