Schema-based AOP support

本文參考至:spring-framework-reference.pdf的7.3 章節java

【Schema-based AOP support】spring

  If you are unable to use Java 5, or simply prefer an XML-based format, then Spring 2.0 also offers
support for defining aspects using the new "aop" namespace tags. The exact same pointcut expressions
and advice kinds are supported as when using the @AspectJ style, hence in this section we will focus on
the new syntax and refer the reader to the discussion in the previous section (Section 7.2, 「@AspectJ
support」) for an understanding of writing pointcut expressions and the binding of advice parameters.express

  To use the aop namespace tags described in this section, you need to import the spring-aop schema as
described in Appendix C, XML Schema-based configuration. See the section called 「The aop schema」 for
how to import the tags in the aop namespace.app

  Within your Spring configurations, all aspect and advisor elements must be placed within an
<aop:config> element (you can have more than one <aop:config> element in an application
context configuration). An <aop:config> element can contain pointcut, advisor, and aspect elements
(note these must be declared in that order).this

  若是,你不能使用java5,或者更傾向於使用XML格式的配置文件,Spring2.0引入了支持使用配置文件配置Aop,使用【aop】的命名空間,相同的pointCut表spa

答式和各類advice(before、after、around、after returning)也能夠像@AspectJ中同樣的使用。於是在本節中,咱們將主要介紹新的語義,而且涉及到orm

前面的章節,更好的理解如何編寫pointCut表達式和綁定advice的參數。element

  要使用在本節使用aop的命名空間標籤,須要參考附錄C引入spring-aop的schema即-XML Schema-based configuration。it

     在本身的Spring配置文件中,全部的aspect和advisor標籤必須至於<aop:config>標籤範圍內【在一個配置文件中,能夠有多個<aop:config>標籤】,一個io

【<aop:config>】標籤能夠包含point、advisor、和asect元素,特別強調:元素的命名,必需要按照上述的順序

相關文章
相關標籤/搜索