Perfect!  Works as described.

Thanks,

Eric



On Fri, Apr 4, 2014 at 2:21 PM, Andy Clement <andrew.clem...@gmail.com>wrote:

> Try the "Aspects" class, I can't find the javadoc for it right now online
> but see this for Aspects14 (
> http://eclipse.org/aspectj/doc/released/runtime-api/index.html) that was
> the pre java5 form of the class. Those helper methods just call the real
> aspectOf() under the covers which should have been added via LTW by the
> time you make the invocation.
>
> cheers,
> Andy
>
>
> On 3 April 2014 21:16, Eric B <ebenza...@gmail.com> wrote:
>
>> 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
>>
>>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to