Chapter 6. Services and AOP
Most kayakers that I know are demented and proud of it. We tend to look for those places on a river that are dangerous enough to scare but tame enough to play. While I was learning to surf hydraulics on Barton Creek at high water, I slipped into a hydraulic to play, but couldn’t get out. I flipped, upstream, and the hydraulic quickly flipped me 360 degrees, so that I was upright again. I frantically surfed a little while longer, then flipped again, and then all of my control deserted me. The hydraulic then took over, and spun me around like a window shade. When my friends laughed and grabbed their cameras instead of their safety ropes, I bailed, coughing and gagging my way to the bank to nurse my battered ego. I mumbled something about my boat being the source of the problem. Predictably, one of my friends got into my boat, and then toyed with my nemesis, the killer hydraulic, for a while. To make things worse, he then threw his paddle onto the bank, and played some more. He said, “Bruce, it’s not the boat. It’s how you use it.” I’m still fuming today.
Building a Service
The core functions of your application are roughly complete, but it’s going to be hard to trace what changes a user made, and when. In this example, you’ll build an audit trail that records a log record whenever someone takes an action that changes the database. Rather than add the same code in many different places, you’ll build a simple Spring service to do the job. You’ll focus on ...