This is both a Spring and AspectJ question.  I'm having trouble configuring
AspectJ aspects with Spring and JavaConfig.  According to Spring's
Documentation (
http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/aop.html#aop-aj-configure)
in order to configure an aspect for Spring IOC, the following has to be
added to the xml configuration:

    <bean id="profiler" class="com.xyz.profiler.Profiler"
          factory-method="aspectOf">
      <property name="profilingStrategy" ref="jamonProfilingStrategy"/>
    </bean>


An equivalent in JavaConfig would be:

    @Bean
    public com.xyz.profiler.Profiler profiler() {
        com.xyz.profiler.Profiler profiler =
com.xyz.profiler.Profiler.aspectOf();
        profiler.setProfilingStrategy(jamonProfilingStrategy());
        return profiler;
    }


However, this only seems to work if the `Profiler` aspect is written in
native aspectj `.aj` syntax.  If it is written in Java and annotated with
`@Aspect`, I get the following error message:

    The method aspectOf() is undefined for the type Profiler


Is there an equivalent way of writing this using JavaConfig for aspects
written with @AspectJ syntax?

I suspect that there is some conflict between the java compiler and ajc
where it is not seeing the properly compiled version of the aspect.  But I
have checked the .class file for the aspect and see that the `aspectOf`
method is indeed present.

Any ideas what this is happening with the @AspectJ coding style?

Thanks,

Eric
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to