ITeye博客

Spring采用CGLIB增强时要注意的一个问题

duooluu · 2009-05-29 16:58 · Markdown

代码如下


public interface IXService{
	public void doAdd();
}

抽象类


public abstract class AbstractXService{
	public void doAdd(){
		//do something
		innerMethod();
	}

	protected abstract void innerMethod();
}

具体实现


public class DXService{
	protected void innerMethod(){...}
}

事务配置,采用cglib来增强


<aop:config proxy-target-class="true">
	<aop:advisor pointcut="execution(* DXService.*(..))" advice-ref="txAdvice"/>
</aop:config>
<tx:advice id="txAdvice">
	<tx:attributes>
	<tx:method name="doAdd" propagation="REQUIRED" rollback-for="java.lang.Throwable"/>
	</tx:attributes>
</tx:advice>

期望是在doAdd方法上加事务管理,但实际调用的时候doAdd上并没有事务管理。原因是cglib不会对父类方法做增强

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。