Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Load-time weaving issue

Hi,

I took the code as-is and set it up to run ltw from the command line.

The only change I made was adding a main method to the SearchService2
class just so that I could 'run' something:

    public static void main(String[] argv) {
      new SearchService2().get("foo",null);
    }

I then ran it:

java -javaagent:/Users/aclement/installs/aspectj170m1/lib/aspectjweaver.jar
test.services.SearchService2
[AppClassLoader@535ff48b] info AspectJ Weaver Version 1.7.0.M1 built
on Friday Dec 16, 2011 at 16:56:09 GMT
[AppClassLoader@535ff48b] info register classloader
sun.misc.Launcher$AppClassLoader@535ff48b
[AppClassLoader@535ff48b] info using configuration
/Users/aclement/installs/aspectj170m1/marc/bin/META-INF/aop.xml
[AppClassLoader@535ff48b] info register aspect test.services.LoggingAspect
[AppClassLoader@535ff48b] debug weaving 'test.services.SearchService2'
[AppClassLoader@535ff48b] weaveinfo Join point
'method-call(java.util.List
test.services.SearchService2.get(java.lang.String,
test.services.SearchService2$Operator))' in Type
'test.services.SearchService2' (SearchService2.java:18) advised by
before advice from 'test.services.LoggingAspect'
(LoggingAspect.java:4)
[AppClassLoader@535ff48b] weaveinfo Join point
'method-call(java.util.List
test.services.SearchService2.get(java.lang.String,
test.services.SearchService2$Operator))' in Type
'test.services.SearchService2' (SearchService2.java:18) advised by
after advice from 'test.services.LoggingAspect' (LoggingAspect.java:9)
[AppClassLoader@535ff48b] debug weaving 'test.services.LoggingAspect'
[AppClassLoader@535ff48b] info processing reweavable type
test.services.LoggingAspect: test/services/LoggingAspect.java
[AppClassLoader@535ff48b] debug cannot weave
'org.aspectj.lang.NoAspectBoundException'
Before search for:foo op:null
test.services.SearchService2.get 2
After search for:foo op:null

The advice was OK (this was with the include="test.services.*" line).
 I changed the include line to:

<include within="test.services.SearchService2"/>

and that also worked.

When you say it doesn't work, what do you see - do you see the aspect
registration in the debug output, but just no weave infos for the
SearchService2 class?  Can you run it successfully the same as I have
run it?

cheers,
Andy

On 23 February 2012 07:14,  <marc.brette@xxxxxxx> wrote:
> Not much luck. The pointcut below work with
>
>         <include within="*"/>
>
> But not with
>
>         <include within="test.services.*"/>
>
>
>
>
>
> From: aspectj-users-bounces@xxxxxxxxxxx
> [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Pasturel
> Sent: mercredi 22 février 2012 19:41
> To: aspectj-users@xxxxxxxxxxx
> Subject: Re: [aspectj-users] Load-time weaving issue
>
>
>
>
> have you tried with the pointcut definited as below ?
>
>    pointcut search(SearchService2 service, String terms,
> SearchService2.Operator operator) :
>
>      call(*  *..SearchService2.get(String, SearchService2.Operator))
>
>                                                                 &&
> target(service)
>
>                                                                 &&
> args(terms, operator);
>
>
> Le 22/02/2012 18:45, marc.brette@xxxxxxx a écrit :
>
> Hi,
>
> I try to use Load Time Weaving with a very simple program. It works except
> when I try to restrict the weaving to a class or a package.
>
> There is probably something obvious I missed but I tried most of the debug
> flags and it does not help.
>
> My example work with compile-time weaving.
>
>
>
> Aop.xml:
>
> <aspectj>
>
>
>
>     <aspects>
>
>         <aspect name="test.services.LoggingAspect"/>
>
>     </aspects>
>
>
>
>     <weaver options="-verbose -debug -showWeaveInfo">
>
>         <!--When I add this it does not work-->
>
>         <include within="test.services.*"/>
>
>         <!--<include within="test.services.SearchService2"/>   This does not
> work either -->
>
>         <!--<include within="*"/>  This does work -->
>
>     </weaver>
>
> </aspectj>
>
>
>
> Aspect:
>
> package test.services;
>
> public aspect LoggingAspect {
>
>
>
>     before(SearchService2 service, String term, SearchService2.Operator
> operator): search(service, term, operator) {
>
>         System.out.println("Before search for:" + term + " op:" + operator);
>
>         System.out.flush();
>
>     }
>
>
>
>     after(SearchService2 service, String term, SearchService2.Operator
> operator): search(service, term, operator) {
>
>         System.out.println("After search for:" + term + " op:" + operator);
>
>         System.out.flush();
>
>     }
>
>
>
>      pointcut search(SearchService2 service, String terms,
> SearchService2.Operator operator) :
>
>      call(* SearchService2.get(String, SearchService2.Operator))
>
>                                                                 &&
> target(service)
>
>                                                                 &&
> args(terms, operator);
>
>
>
> }
>
>
>
> Class to Weave:
>
> package test.services;
>
>
>
> import java.util.Arrays;
>
> import java.util.List;
>
>
>
> public class SearchService2 {
>
>
>
>     public enum Operator {
>
>         EQUALS,
>
>         CONTAINS
>
>     }
>
>     public List<String> get(String term, Operator operator) {
>
>         System.out.println("test.services.SearchService2.get 2");
>
>         return Arrays.asList(term + "1", term + "2");
>
>     }
>
> }
>
>
>
> Any help appreciated
>
> Best regards,
>
> Marc
>
>
>
>
>
>
> _______________________________________________
>
> 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