Okay, so I got it to work (not perfectly but it's going there) but there's a strange thing happening that I don't quite understand.
I wrote a method profiler that acts on all methods of package "foo..*" and all my classes are in foo package. It's working great, profiling everything but if I change the following code:
Code:
public class Test {
public static void main(String[] args) {
new ClassPathXmlApplicationContext("foo/beans.xml");
// everything after the initialisation of the context
StuffInterface executer = new StuffExecuter();
executer.doStuff();
StuffInterface anotherExecuter = new StuffExecuter();
anotherExecuter.doStuff();
OtherStuff stuff = new OtherStuff();
stuff.doMoarStuff();
new ShutdownThingie().shutdown();
}
}
to
Code:
public class Test {
public static void main(String[] args) {
// these two lines were pulled up, before the context init
StuffInterface executer = new StuffExecuter();
executer.doStuff();
new ClassPathXmlApplicationContext("foo/beans.xml");
StuffInterface anotherExecuter = new StuffExecuter();
anotherExecuter.doStuff();
OtherStuff stuff = new OtherStuff();
stuff.doMoarStuff();
new ShutdownThingie().shutdown();
}
}
Then none of the executions of StuffInterface.doStuff() are profiled, not even the ones created after the context init.
It seems as classes are only being woven if their first instance is created AFTER the load time weaving is enabled. I'm pretty green in AOP so this may even be the expected behaviour, but still gave me some headaches until I figured it.
Question is, is there any way around this? Or the context initialisation is absolutely, positively and unquestionably the first thing to initialise in my application? If so, I could I possibly profile stuff like hashtable methods, that are eventually created before I can even load the context?