简体   繁体   English

Legacy Spring应用程序 - 切入点值是什么意思?

[英]Legacy Spring application - what does the pointcut value mean?

I have "inherited" an old legacy Spring application. 我已经“继承”了旧的Spring应用程序。 Currently it is using Spring 2.5 (just upgraded it once), and am looking to further upgrade it to Spring 3. 目前它正在使用Spring 2.5(只升级一次),我希望进一步升级到Spring 3。

I understand most of the application configuration. 我理解大多数应用程序配置。 There is just one part that I am "not 100%" about. 只有一部分我“不是100%”。 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) “执行(* ..ProductManager。 (..))”是什么意思(我理解切入点的说法)
  • In the attributes section of the advice we are saying apply transaction to all save* related methods, and for everything read-only is false. 在建议的属性部分,我们说将事务应用于所有与save *相关的​​方法,并且对于所有内容,只读是假的。 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. 请,没有一般性的答案 - 我需要一个具体的解释。

As tx:method has attribute read-only with default value as false, means transaction is read/write. 由于tx:method具有read-only属性,默认值为false,表示事务是读/写。

So in my opinion, 所以在我看来,

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

is equivalent to 相当于

<tx:method name="*" />

execution(* *..ProductManager.*(..)) means that, "for all the methods in the ProductManager class" execution(* *..ProductManager.*(..))表示“对于ProductManager类中的所有方法”

tx:advice settings are not additive. tx:建议设置不是附加的。 It says that for all methods beginning with save use the default transaction settings. 它表示对于以save开头的所有方法都使用默认的事务设置。 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="*" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM