简单来说,spring中的AOP就是实现“横切”的工具,通过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"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- 这里是自定义的拦截器的实现,在Spring的ProxyFactoryBean类中必须指定的interceptorNames的值 -->
<bean name="transactionInterceptor" class="com.mooza.spring.aop.TransactionInterceptor"></bean>
<!-- 这里的subInterface为自己的业务处理实现类 -->
<bean name="subInterface" class="com.mooza.spring.aop.SubInterface"/>
<bean name="invocation" class="org.springframework.aop.framework.ProxyFactoryBean">
<!-- 这里必须要指定接口 -->
<property name="proxyInterfaces">
<value>com.mooza.spring.aop.FatherInterface</value>
<!-- 业务处理节点名称和拦截器名称必须都要定义,必须将拦截器的对象transactionInterceptor放在第一个位置 -->
</property>
<property name="interceptorNames">
<list>
<!-- 下面的两个value中,拦截器对象必须放在业务处理对象前面 -->
<value>transactionInterceptor</value>
<value>subInterface</value>
</list>
</property>
</bean>
</beans>
这几天正在学习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"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<!-- 这里是自定义的拦截器的实现,在Spring的ProxyFactoryBean类中必须指定的interceptorNames的值 -->
<bean name="transactionInterceptor" class="com.mooza.spring.aop.TransactionInterceptor"></bean>
<!-- 这里的subInterface为自己的业务处理实现类 -->
<bean name="subInterface" class="com.mooza.spring.aop.SubInterface"/>
<bean name="invocation" class="org.springframework.aop.framework.ProxyFactoryBean">
<!-- 这里必须要指定接口 -->
<property name="proxyInterfaces">
<value>com.mooza.spring.aop.FatherInterface</value>
<!-- 业务处理节点名称和拦截器名称必须都要定义,必须将拦截器的对象transactionInterceptor放在第一个位置 -->
</property>
<property name="interceptorNames">
<list>
<!-- 下面的两个value中,拦截器对象必须放在业务处理对象前面 -->
<value>transactionInterceptor</value>
<value>subInterface</value>
</list>
</property>
</bean>
</beans>