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


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


Back to the top