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