Chapter 5. Modifying structure with static crosscutting

 

This chapter covers

  • Using member introduction
  • Supplementing annotations
  • Modifying type hierarchies
  • Responding to compile-time errors and warnings
  • Softening exceptions

Altering the dynamic behavior of the system in a crosscutting manner dominates the use of AOP. But often you’ll also need to alter the static structure of the system in a crosscutting manner. Whereas dynamic crosscutting modifies the behavior of the program, static crosscutting modifies the static structure of the types—the classes, interfaces, and other aspects—and their weave-time behavior. There are three broad classifications of static crosscutting:

  • Inter-type declaration (ITD)— One type (an aspect) makes declarations for another type (an interface, a class, or even an aspect). It consists of support for member introduction, type-hierarchy modification, and annotation supplementation.
  • Weave-time error and warning declarations— This form of static crosscutting detects the presence of a join point and issues errors and warnings during the weaving process.
  • Exception softening— This approach lets you deal with checked exceptions in a crosscutting manner.

In this chapter, we’ll examine all these constructs and present several examples. As in the previous chapters, we’ll discuss the traditional syntax here and visit the @AspectJ syntax in chapter 7 (part of which is supported in Spring as well). Let’s start with AspectJ’s support for introducing members.

5.1. Introducing members

 
 

5.2. Modifying the type hierarchy

 
 
 

5.3. Introducing members to multiple types

 
 
 

5.4. Supplying annotations

 
 
 

5.5. Declaring weave-time errors and warnings

 
 

5.6. Softening checked exceptions

 
 
 

5.7. Summary

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest