|
From: Hunter K. <re...@ei...> - 2004-12-08 15:13:25
|
Hi, in our app we have the following TransactionInterceptor defined:
<bean id="txnInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager"><ref local="transactionManager"/></property>
<property name="transactionAttributeSource">
<!-- I think this uses the spiffy TransactionAttributeSourceEditor, obviating the need for a seperate
TransactionAttributeSource definition in simple cases - but you have to register it as a
custom editor - which I've done (towards top of file). The thing that parses it only
takes one "value", but you can have multiple entries as long as each is on it's own line.
Don't forget to add the bean names you want this applied to to the autoProxyCreator below. -->
<value>
com.newbay.mixxe.command.AbstractCommand.executeInTransaction=PROPAGATION_REQUIRED
com.newbay.callbacks.ICallbackManager.noteDelivered=PROPAGATION_REQUIRED
</value>
</property>
</bean>
Now, I know that I've used the TransactionAttributeSourceEditor, but this would still apply if
a bean defined the TransactionAttributeSource seperately.
It seems to me like it would make sense for this class (or possibly, a subclass) to also
implement the Advisor interface (or PointcutAdvisor), since the TxnAttrSource guys pretty much define
pointcuts. Now, I don't know what other people do, but it seems like I have two options:
A) Take the performance hit if I just use the interceptor directly, like in a beanNameAutoProxyCreator or something.
This is obviously not good, and could potentially lead to obscure bugs where the txn seems to be in place, but isn't
started, or something.
B) Define advisors for all the relevant class+method guys. While this has the most desireable effect, it duplicates the DRY
principle and could lead to lots of extra configuration.
Now, it's possible that I'm approaching this whole thing incorrectly, or my understanding is whacked out, or I've missed a better
way to share things like advisors, etc, etc...
H
|