Question

I have "inherited" an old legacy Spring application. Currently it is using Spring 2.5 (just upgraded it once), and am looking to further upgrade it to Spring 3.

I understand most of the application configuration. There is just one part that I am "not 100%" about. I can guess roughly what it might mean but I need to be absolutely sure hence posting this question:

Here is the configuration snippet (depends on an annotation driven transaction manager not shown here):

<aop:config>
    <aop:advisor pointcut="execution(* *..ProductManager.*(..))"
        advice-ref="txAdvice" />
</aop:config>

<tx:advice id="txAdvice">
    <tx:attributes>
        <tx:method name="save*" />
        <tx:method name="*" read-only="false" />
    </tx:attributes>
</tx:advice>

My specific two questions are:

  • What does "execution(* ..ProductManager.(..))" mean (I understand pointcut parlance)
  • In the attributes section of the advice we are saying apply transaction to all save* related methods, and for everything read-only is false. Can anyone explain why that setting makes sense? Is it additive and effectively saying, for all methods with transaction support (ie. just save* methods) I also want those methods to NOT be read-only transactions. Or is it applying something different (ie. some form of transaction support) to every method of inclusive transacion filter (defined in pointcut).

Thanks for any clarifications. Please, no general answers - I need a concrete explanation for this.

Was it helpful?

Solution 2

execution(* *..ProductManager.*(..)) means that, "for all the methods in the ProductManager class"

tx:advice settings are not additive. It says that for all methods beginning with save use the default transaction settings. For the others, this setting means they are NOT read-only transactions.

For the common sense, one would expect

<tx:method name="save*" read-only="false" />
<tx:method name="*" />

OTHER TIPS

As tx:method has attribute read-only with default value as false, means transaction is read/write.

So in my opinion,

<tx:method name="save*" read-only="false" /> <tx:method name="*" />

is equivalent to

<tx:method name="*" />

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top