pointcuts in complex relationships to further constrain when advice is executed.
We discuss pointcut composition in more detail in the next chapter.
Aspects: An aspect is the combination of advice and pointcuts. This combination
·
results in a definition of the logic that should be included in the application and
where it should execute.
Weaving: This is the process of actually inserting aspects into the application code
·
at the appropriate point. For compile-time AOP solutions, this is, unsurprisingly,
done at compile time, usually as an extra step in the build process. Likewise, for
runtime AOP solutions, the weaving process is executed dynamically at runtime.
AspectJ supports another weaving mechanism called load-time weaving (LTW), in
which it intercepts the underlying JVM class loader and provides weaving to the
bytecode when it is being loaded by the class loader.
Target: An object whose execution flow is modified by some AOP process is
·
referred to as the target object. Often you see the target object referred to as the
advised object.
Introduction: This is the process by which you can modify the structure of an
·
object by introducing additional methods or fields to it. You can use introduction
to make any object implement a specific interface without needing the object's
class to implement that interface explicitly.
Don't worry if you find these concepts confusing; this will all become clear when you see some
examples. Also, be aware that you are shielded from many of these concepts in Spring AOP, and some
are not relevant because of Spring's choice of implementation. We will discuss each of these features in
the context of Spring as we progress through the chapter.
Types of AOP
As we mentioned earlier, there are two distinct types of AOP: static and dynamic. The difference between
them is really the point at which the weaving process occurs and how this process is achieved.
Static AOP
Many of the first AOP implementations were static. In static AOP, the weaving process forms another
step in the build process for an application. In Java terms, you achieve the weaving process in a static
AOP implementation by modifying the actual bytecode of your application, changing and extending the
application code as necessary. Clearly, this is a well-performing way of achieving the weaving process
because the end result is just Java bytecode, and you do not perform any special tricks at runtime to
determine when advice should be executed.
The drawback of this mechanism is that any modifications you make to the aspects, even if you
simply want to add another joinpoint, require you to recompile the entire application. AspectJ's
compile-time weaving is an excellent example of a static AOP implementation.
Dynamic AOP
Dynamic AOP implementations, like Spring AOP, differ from static AOP implementations in that the
weaving process is performed dynamically at runtime. How this is achieved is implementation-
dependent, but as you will see, Spring's adopted approach is to create proxies for all advised objects,
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home