I'm trying to use Spring to provide load time weaving to several classes in a project I've created. I'm having trouble getting it to work when I call a class that is not within my local project.
I created a class named ExampleClass
and when I perform an @Around
on a method in there, I can see the modifications I made to the return, however when I attempt to do the same to String
I'm unable to get any results.
This is my Aspect
Code:
@Pointcut("call(* java.lang.String.*(..))")
public void cutString() {}
@Before("cutString()")
public void aroundString() throws Throwable {
System.out.println("I Never See This");
}
Here's my call to that code:
public class Main {
public static void main(String[] args) {
new ClassPathXmlApplicationContext("classpath:my-context.xml");
String string = new String("I Only See This");
System.out.println(string.toLowerCase());
}
}
The content of my-context.xml
is just a <context:load-time-weaver />
.
I have an aop.xml
defined which as I said works for one class, but not another:
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver>
<include within="com.example.*" />
<include within="java.lang.String" />
</weaver>
<aspects>
<aspect name="com.example.PerformMonitor" />
</aspects>
</aspectj>
Am I missing something, or is this a limitation of Spring and AspectJ?