读书人

AOP剖面编程(不必写接口代理实现)

发布时间: 2013-04-07 12:50:11 作者: rapoo

AOP切面编程(不必写接口,代理实现),spring中的配置示例

?

?<?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:aop="http://www.springframework.org/schema/aop"

? ? ? ? ? ? ?xmlns:tx="http://www.springframework.org/schema/tx"

? ? ? ? ? ? ?xsi:schemaLocation="http://www.springframework.org/schema/beans

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/context

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/context/spring-context-3.0.xsd

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/aop

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/mvc

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/tx

? ? ? ? ? ? ? ? ? ? ?http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

? ? ? <!-- 配置AOP -->

? ? ? <aop:config>

? ? ? <aop:aspect id="door" ref="door">

? ? ?<aop:pointcut expression="execution(* com.Solder.pass*(..))" id="caixen"/>

? ? ? <aop:after-returning method="addBlood" pointcut-ref="caixen"/>

? ? ? </aop:aspect>

? ? ? </aop:config>

? ? ? ?

? ? ? ?<!-- 设置注解方式管理bean -->

? ? ? ?<context:annotation-config></context:annotation-config>

? ? ? ?<context:component-scan base-package="com"></context:component-scan>

</beans>

读书人网 >编程

热点推荐