Using invokeMethod & getProperty
Since 1.0, Groovy supports the ability to intercept "all" method and property access via the invokeMethod and getProperty hooks. If you only want to intercept failed method/property access take a look at Using methodMissing & propertyMissing.
In any Groovy class you can override invokeMethod which will essentially intercept all method calls (including calls to existing methods). This makes it possible to construct some quite interesting DSLs and builders.
For example a trivial XmlBuilder could be written as follows (note Groovy ships with much richer XML APIs and this just serves as an example):
You can also override property access using the
setProperty property access hooks. For example it is possible to write a trival "Expandable" object using this technique: