Chapter 4. Aspect-oriented Spring

 

This chapter covers

  • Basics of aspect-oriented programming
  • Creating aspects from POJOs
  • Using @AspectJ annotations
  • Injecting dependencies into AspectJ aspects

As I’m writing this chapter, summertime is upon Texas (where I reside). And in Texas, it’s very common to go through several days of record-high temperatures. It’s hot. In weather like this, air conditioning is a must. But the downside of air conditioning is that it uses electricity, and electricity costs money. There’s little we can do to avoid paying for a cool and comfortable home. That’s because every home has a meter that measures every kilowatt, and once a month someone comes by to read that meter so that the electric company knows how much to bill us.

Now imagine what would happen if the meter went away and nobody came by to measure our electricity usage. Suppose it was up to each homeowner to contact the electric company and report their electricity usage. Although it’s possible that some obsessive homeowners would keep careful records of how much they used their lights, televisions, and air conditioning, most wouldn’t bother. Electricity on the honor system might be great for consumers, but it would be less than ideal for the electric companies.

4.1. What is aspect-oriented programming?

4.2. Selecting join points with pointcuts

4.3. Creating annotated aspects

4.4. Declaring aspects in XML

4.5. Injecting AspectJ aspects

4.6. Summary

sitemap