【发布时间】:2014-02-04 10:09:01
【问题描述】:
我开始在一个项目中使用 Spring AOP,我对编织有点困惑。我知道 Spring AOP 依赖于 AspectJweaver.jar,但正如文档所说,这不是用于编织,而只是它使用了这个 jar 中的一些类。
但我的问题是,如果不使用 AspectJ 进行编织,Spring AOP 是否有自己的编织,是在加载时执行还是在编译时执行?
我的 Spring Configuration XML 文件的相关部分是:
<context:annotation-config />
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="myaop" expression="execution(* my.package.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="myaop" />
</aop:config>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
【问题讨论】:
-
很确定我现在已经弄清楚了,但很高兴听到回复确认。 Spring 也不这样做,它使用将在运行时创建的代理。听起来对吗?