Hi Alex,

We have an open bugzilla issue to do with using aop.xml to configure weaving
at compile time ( https://bugs.eclipse.org/bugs/show_bug.cgi?id=124460 ) -
this would enable you to do what you want.  Right now compilation considers
all incoming aspects to be available and they may target any source or other
.class files passed into the compiler.  The way you would have to solve it
right now is as you suggested, by creating one .jar per aspect and passing
only those necessary jars on the aspectpath for the compiler to use.

> Also, right now I'm just delivering my aspects in a javac-compiled jar
(which works because they are
> @AspectJ-style aspects). Do I need to first use ajc to generate a
read-only aspect library in a separate
> jar?

You can supply an annotation style aspect built with javac to the ajc
compiler (on the aspectpath or inpath).  You do not have to use the ajc
compiler to build that aspect in the first place, whether it is for use with
load time weaving or a further compile time weaving step.

cheers,
Andy.

2008/12/30 Alexander Devine <[email protected]>

> I have the following situation, and while I have solved the problem using
> aspectj's load-time weaver, I would like to see if it's possible to handle
> this problem using ajc at compile time.
>
> 1. I have built a java library (the jar file is perf4j.jar) that contains a
> number of aspects created using @AspectJ style syntax. That is, perf4j.jar
> was just compiled using javac, NOT ajc.
> 2. I would like to enable other developers to use my aspects by marking
> some of their methods with a "Profiled" annotation, which is also defined in
> perf4j.jar. Thus, my aspects all have a pointcut that looks like:
> execution(* *(..)) && @annotation(profiled)
> 3. Right now everything works fine if I use load-time weaving with an
> aop.xml that looks like this:
>
> <aspectj>
>   <!-- we only want to weave in the log4j TimingAspect -->
>   <aspects>
>     <aspect name="org.perf4j.log4j.aop. TimingAspect"/>
>   </aspects>
>
>   <weaver options="-verbose -showWeaveInfo">
>     <!-- other developers specify here their classes they wish to weave -->
>     <include within="com.third.party.developer.*"/>
>   </weaver>
> </aspectj>
> 4. Is there a way that I can replicate this behavior at compile time using
> ajc? The problem I have with ajc is that, as far as I can tell, there is no
> way to specify the class names of the aspects I want to include like there
> is with aop.xml. That is, my perf4j.jar contains a bunch of different
> aspects, but other developers are only going to want to chose one of those
> aspects to weave into their classes. Do I need to generate a different jar
> file for each aspect? Also, right now I'm just delivering my aspects in a
> javac-compiled jar (which works because they are @AspectJ-style aspects). Do
> I need to first use ajc to generate a read-only aspect library in a separate
> jar?
>
> Thanks for any and all help!
>
> Alex Devine
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to