finshope
6/18/2019 - 1:20 AM

Spring aop xml config

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

	<context:component-scan
		base-package="com.finshope.aspect"></context:component-scan>

	<aop:aspectj-autoproxy>
	</aop:aspectj-autoproxy>

	<bean id="userDao" class="com.finshope.dao.UserDaoImpl"></bean>
	<bean id="orderDao" class="com.finshope.dao.OrderDaoImpl"></bean>
	<bean class="com.finshope.dao.AopDao"></bean>
	
	<bean id="xmlAspect" class="com.finshope.aspect.XmlAspect"></bean>
	<bean id="generalAspect"
		class="com.finshope.aspect.GeneralAopAspect"></bean>
	<aop:config>
		<aop:pointcut
			expression="execution(* com.finshope.dao.OrderDao.insertOrder(..))"
			id="insertPointcut" />
		<aop:aspect ref="xmlAspect">
			<aop:before method="before" pointcut-ref="insertPointcut" />
		</aop:aspect>
		<aop:aspect ref="generalAspect">
			<aop:pointcut expression="execution(* com.finshope.dao.AopDao.*(..))" id="all"/>
			<aop:before method="before"
				pointcut="execution(* beforeMethod(..))" />
			<aop:after method="after"
				pointcut="execution(* afterMethod(..))" />
			<aop:after-returning method="afterReturn"
				pointcut="execution(* afterReturnMethod(..))" returning="retVal" />
			<aop:after-throwing method="afterThrowing"
				pointcut="execution(* afterThrowingMethod(..))" throwing="ex" />
			<aop:around method="trace" pointcut-ref="all" />
			<aop:around method="around" pointcut="execution(* aroundMethod(*,*))"/>
		</aop:aspect>
	</aop:config>
</beans>