Chapter 12Intercepting Methods Using MOP
In Groovy we can implement aspect-oriented programming (AOP)—such as method interception or method advice—fairly easily.[31] There are three types of advice. And, no, they’re not the good advice, the bad advice, and the unsolicited advice we receive every day. We’ll focus on the before, after, and around advice. The before advice is code for a concern we’d want to execute before a certain operation. The after advice is executed after an operation’s execution. The around advice is executed instead of the intended operation. We can use MOP to implement these advice types or interceptors. We don’t need any complex tools or frameworks to do that in Groovy.
Here we’ll discuss two approaches in Groovy ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access