Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] R: Using Aspects.aspectOf for Spring DI

Thanks Andy for your swift reply.
I've used AspectJ Maven plugin to compile the aspect library and it has solved the problem.

Cheers,
Andrea

-----Messaggio originale-----
Da: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] Per conto di Andy Clement
Inviato: venerdì 10 agosto 2012 17:36
A: aspectj-users@xxxxxxxxxxx
Oggetto: Re: [aspectj-users] Using Aspects.aspectOf for Spring DI

I'm afraid the Aspects type will still make calls to aspectOf/hasAspect methods in the aspect.  The Aspects class is provided so that you can develop in pure java and not get compile time errors when attempting to call aspectOf()/etc. So you can call
Aspects.aspectOf(Foo.class) and javac will let it through, but the system will only work at runtime if the annotation style aspect has been finished off by getting an aspectOf/hasAspect/etc generated into it (because Aspects.aspectOf(Foo.class) reflectively calls Foo.aspectOf()).

After compilation with javac, can you not just pass the aspect classes through ajc to finish them off?
ajc -inpath library.jar -outjar finishedlibrary.jar

cheers,
Andy

On 10 August 2012 01:36, Tevoi Andrea <tevoi@xxxxxx> wrote:
> Hi all,
>
>
>
> I developed an Aspect library with @AspectJ syntax and I use it via 
> CTW to weave an application. I know that because I used java compiler, 
> aspectOf and hasAspect are not generated, so I tried to use Aspects 
> utility class to instantiate Aspect classes in Spring.
>
>
>
> Here is the Spring xml fragment:
>
> ...
>
> <bean class="org.aspectj.lang.Aspects" id="outputMessageLogger"
> factory-method="aspectOf">
>
>     <constructor-arg type="java.lang.Class"
> value="logging.OutputMessageLoggerAspect "/>
>
> ...
>
>
>
> During startup this exception is thrown:
>
> Factory method [public static java.lang.Object
> org.aspectj.lang.Aspects.aspectOf(java.lang.Class) throws 
> org.aspectj.lang.NoAspectBoundException] threw exception; nested 
> exception is org.aspectj.lang.NoAspectBoundException: Exception while 
> initializing
> logging.OutputMessageLoggerAspect: java.lang.NoSuchMethodException:
> com.cadit.xas.aop.logging.OutputMessageLoggerAspect.aspectOf()
>
>
>
> Is there something wrong in the way I use Aspects utility class?
>
>
>
> Many thanks in advance,
>
> Andrea
>
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top