1

How I can enable the full featured aspectj in a spring project to be able to use conditional pointcuts?

Right now I have in config file:

 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">

....

  <aop:aspectj-autoproxy />

but when i want to create a pointcut like this:

    @Pointcut(value = "execution(public * *(..)) && if() ")
    public static boolean  anyPrivateMethod() {
     return enabled>0;
    }

there is a compilation exception saying: Pointcut expression 'execution(public * *(..)) && if() ' contains unsupported pointcut primitive 'if' basically because there is spring AOP acting and not Aspecj.

So how i can use aspectj AOP and not Spring AOP?

DanutClapa
  • 592
  • 2
  • 7
  • 23
  • If it is compilation (i.e. during compilation of your code) then it has nothing to do with Spring AOP but the use of an AspectJ version that isn't supporting this, if it is during startup then it is because you are indeed using Springs proxy based AOP mechanism. Remove the `` because, as the name implies, uses proxies. Use `` instead or configure your project to use compile time weaving and have the aspects woven in at compilation time. – M. Deinum Jul 17 '15 at 08:24
  • ok, replaced with but now i have a compilation validation problem The matching wildcard is strict, but no declaration can be found for element 'context:load-time-weaving... – DanutClapa Jul 17 '15 at 09:24
  • Typo. should be `load-time-weaver`. – M. Deinum Jul 17 '15 at 09:36
  • and i need spring instrument for that right? – DanutClapa Jul 17 '15 at 11:46
  • That depends on your environment. – M. Deinum Jul 17 '15 at 11:50
  • then, can I start the application like a usual application without using spring instrument or any other tool? – DanutClapa Jul 23 '15 at 09:50

0 Answers0