Chapter 2. Getting Started with AspectJ
Introduction
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,
ajc
,
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
Machine (JVM). ajc
simply automates the mapping of
your aspects onto your Java classes.
The ajc
tool is used for
compile-time
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 ...
Get AspectJ Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.