Practical Introduction into Code Injection with AspectJ, Javassist, and Java Proxy

The ability to inject pieces of code into compiled classes and methods, either statically or at runtime, may be of immense help. This applies especially to troubleshooting problems in third-party libraries without source codes or in an environment where it isn’t possible to use a debugger or a profiler. Code injection is also useful forContinue reading “Practical Introduction into Code Injection with AspectJ, Javassist, and Java Proxy”

Advertisement

Enforcing a common log format with AspectJ

Enforcing a common log format with AspectJ Andy Wilson has recently blogged about the need for uniformly formatted log messages containing all the necessary information to make log parsing easier and mentioned an extensive refactoring he did on a project to achieve this. One of the readers mentioned that he could save the effort ofContinue reading “Enforcing a common log format with AspectJ”

Compiling with AspectJ’s ajc compiler from Maven

I needed to compile AspectJ classes (.java with annotations) with ajc and I wanted to have that integrated into the Maven build process. I tried several means, finally finding the one that worked. Note: I had to use ajc even though I was using the pure java 5 syntax based on annotations instead of theContinue reading “Compiling with AspectJ’s ajc compiler from Maven”

Injecting timing aspect into JUnit test in Eclipse using AspectJ, AJDT

Introduction This blog describes my experience with using AOP, namely AspectJ, to measure the individual execution times and their average of a particular low-level method invoked many times during a JUnit test run from within Eclipse. It concentrates on creating the aspect and integrating (weaving) it into the JUnit test execution in the Eclipse environment.Continue reading “Injecting timing aspect into JUnit test in Eclipse using AspectJ, AJDT”