Spring_AOP

src 下的 bean.xml

<?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: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-2.5.xsd
			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
           
 
	<bean  id="userDAO"  class="com.aowin.dao.impl.UserDAOImpl"></bean> 
 	<bean  id="loginDAO"  class="com.aowin.dao.impl.LoginDAOImpl"></bean> 
 	
 	<bean  id="userService" class="com.aowin.service.UserService">
 		<property name="userDAO" ref="userDAO"></property>  
 		<property name="loginDAO" ref="loginDAO"></property>
 	</bean>
 	
 	<bean  id="loginAspect" class="com.aowin.interceptor.LoginAspect"></bean>
 	
 	<aop:config>
 		<!-- 配置切面类 -->
 		<aop:aspect id="loginaspectj" ref="loginAspect">
	 			<!-- aop:pointcut : 切入点  save.     
	 				execution(public  * com.aowin.service..add(..))
	 				 public:public开头的方法 
	 				 *:表示任何返回值 
	 				 com.aowin.service.. 包及其子包 
	 				 add:add方法
	 			 	(..) 任何参数                
	 		 	-->
 				<aop:pointcut expression="execution(public * com.aowin.service..save*(..))" id="servicepointcut"/>
 				<!--  aop:before: 在save方法前执行 -->
 				<aop:before method="before" pointcut-ref="servicepointcut"/>
 				<!-- aop:after:在save方法后面执行 -->
 				<aop:after method="after" pointcut-ref="servicepointcut"/>
 		</aop:aspect>
 	</aop:config>
	 	
 	
</beans>
 

你可能感兴趣的:(spring,AOP)