Chapter 2. Getting Started with AspectJ
This chapter contains recipes for getting started in developing your own aspect-oriented code using AspectJ. Beginning with the task of getting a build environment set up and moving through the different types of builds and targets, this chapter provides a tutorial in the basics of AspectJ development.
With an understanding of the fundamental concepts in aspect
orientation, this chapter first covers getting your fingers dirty
using AspectJ’s development environment. At the core
of AspectJ is its build support for weaving aspects into your Java
code. This is currently done using a compiler,
that interacts with the existing Java compiler,
javac. Working within the constraints of the Java
compilation process ensures that your aspect-oriented programs
produce standard Java classes that can be run by any Java Virtual
ajc simply automates the mapping of
your aspects onto your Java classes.
ajc tool is used for
weaving of aspects either from the command line or within an IDE or
other build tool, but there is also an alternative weaving method
supported in AspectJ,
load-time weaving. As its title suggests, load-time weaving supports the weaving of aspects into your application at the time when the Java class loader is loading the application into the JVM. This is a fairly new feature of AspectJ and is briefly described in this chapter with the caveat that the current methods by which load-time weaving ...