Well to explain AOP there is a lot of terminology.. concerns(some programming area; e.g. logging, authentication, transaction handling etc.), cross cutting concerns(concerns that cut across multiple
classes), join points(a well defined point of execution in
java code e.g method), point cut(an AOP construct that picks a join point), advice (code (java) that executes at a joint point picked by a point cut) and more..
I'll try to give a brief idea based on AspectJ, which, is a java AOP implementation.
Lets say NarayanaRao's 3rd line is a method call to a method testMethod().
You write an Aspect (in AOP parlance a class like unit) and include a pointcut which picks the joinpoint testMethod() in NR's class. Then you write your testing java code within that advice. The pointcut can make the
context information from the join point available within the advice(for example method parameters).
Now armed with this Aspect you need to compile the class and the aspect with the AspectJ compiler "ajc". This is said to weave the Aspect code in to the byte code of the java class at the appropriate join point. Now
you should be able run the compiled class.
You can manage your build process to have two separate build configurations which uses ajc and Aspects as the development build configuration, while, using javac in the production configuration. Such Aspects would be development Aspects (In contrast there are production Aspects). So NR's development cofiguration would execute the code in the Advice and the
production build will basically call an empty method.
Check the official FAQ
here [ November 04, 2008: Message edited by: Gamini Sirisena ]