peekay
peekay

Reputation: 1271

Combining AOP pointcuts in aop.xml without spring

Below is the aspect I am trying to create. I would like to combine two pointcut expressions into one. I have seen that this can be done using annotated pointcuts but the same syntax in the xml fails. can anyone help me?

<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>

Thanks in advance

Upvotes: 2

Views: 2533

Answers (1)

K.C.
K.C.

Reputation: 2112

It's not possible with Spring 2.0.x in xml:

XML style is more limited in what in can express than the @AspectJ style: only the "singleton" aspect instantiation model is supported, and it is not possible to combine named pointcuts declared in XML

6.4.2. @AspectJ or XML for Spring AOP

It is however possible in Spring 3.0.x:

When combining pointcut sub-expressions, '&&' is awkward within an XML document, and so the keywords 'and', 'or' and 'not' can be used in place of '&&', '||' and '!' respectively. For example, the previous pointcut may be better written as:

<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>

Spring 3 aop

Upvotes: 1

Related Questions