问题描述:

I have abstract class of an interface to be backward compatible and reduce redundency.

abstract class EventHandlerAdapter implements EventHandler;

class ImplClass extends EventHandlerAdapter;

class Impl2Class extends EventHandlerAdapter;

I have AOP setting for transaction for any impl class inheriting from abstract class only.

<aop:config proxy-target-class="true">

<aop:pointcut id="EventTXOperation" expression="execution(* EventHandlerAdapter.*(..))"/>

<aop:advisor advice-ref="txAdvice" pointcut-ref="EventTXOperation"/>

</aop:config>

When I try to refer ImplClass in Impl2Class, even I specify proxy-target-class="true", it seems spring will always use original interface EventHandler and I cannot cast to abstract class or concrete impl.

Is this normal behavior of spring AOP with proxy-target-class? I saw I can dive deep to use Advisor class to get target class of auto proxyed bean but seems it's invasive. So what kind of better option can I have?

相关阅读:
Top