繁体   English   中英

在没有Spring的情况下在aop.xml中合并AOP切入点

[英]Combining AOP pointcuts in aop.xml without spring

以下是我尝试创建的方面。 我想将两个切入点表达式合并为一个。 我已经看到可以使用带注释的切入点来完成此操作,但是xml中的相同语法失败。 谁能帮我?

<aspects>
  <concrete-aspect name="com.logger.aspect.InjectionLoggerImpl" 
                   extends="com.logger.aspect.InjectionLogger">
    <pointcut name="loggingInterceptor" 
              expression="execution(* com.*..*.next(..)) || execution(* com.*..*.read(..))"/>
    <pointcut name="methExecInterceptor="some expression"/>
  </concrete-aspect>
</aspects>

提前致谢

xml中的Spring 2.0.x是不可能的:

与@AspectJ样式相比,XML样式在可表示内容方面受到更多限制:仅支持“单例”方面实例化模型,并且无法组合以XML声明的命名切入点

6.4.2。 用于Spring AOP的@AspectJ或XML

但是在Spring 3.0.x中是可能的:

在组合切入点子表达式时,XML文档中的“ &&”很尴尬,因此可以使用关键字“ and”,“ or”和“ not”代替“ &&”,“ ||” 和'!' 分别。 例如,上一个切入点可能更好地写为:

<aop:config>
   <aop:aspect id="myAspect" ref="aBean">

    <aop:pointcut id="businessService" 
      expression="execution(* com.xyz.myapp.service.*.*(..)) and this(service)"/>
    <aop:before pointcut-ref="businessService" method="monitor"/>
   ...

    </aop:aspect>
</aop:config>

春季3 aop

暂无
暂无

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

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