We need to perform some operations just before any transactional method invocation (insert*, update*, ...), BUT - it's important - after the transaction begin. We used to do it for years in that way:
public class CustomBeginChangeAdvice implements MethodBeforeAdvice {
@Override
public void before(Method method, Object[] params, Object target) throws Throwable {
(...)
}
}
<bean id="beginChangeAdvice"
class="some.package.CustomBeginChangeAdvice" />
<bean id="transactionProxyBase" abstract="true">
<property name="postInterceptors">
<list>
<ref bean="beginChangeAdvice" />
</list>
</property>
</bean>
<bean id="transactionProxy"
parent="transactionProxyBase"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager" ref="txManager" />
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
but now, for some reason, we had to rewrite our XML configuration (we don't use annotations, it's an old system) in that way:
<tx:advice id="txAdvice" transaction-manager="integrationTxManager">
<tx:attributes>
<tx:method name="insert*" />
<tx:method name="update*" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config proxy-target-class="true">
<aop:pointcut id="beans" expression="(
bean(firstLogic) || bean(secondLogic) || ...
)" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="beans" />
</aop:config>
and now we face the problem: how to make our beginChangeAdvice work as before, but without creating a custom proxy?
We've spent last few days on it, but couldn't find any working solution in Internet. The worst, there is very few info on an XML-like configuration. Of course, most people use annotations today, but this is too much work for us to rewrite a whole system for now. It's pretty huge thing. Is there anybody who could help us? Thanks in advance, Peter.