12 Jun 2012 15:25
[groovy-user] Hooks and Callbacks
Hi all, I'm looking for a recommendation on how to best implement hooks and callbacks in groovy. The basic pattern includes the following: 1. Hooks are keys against which callbacks (closures) can be registered. A map is associated with this registration that contains information that can be used when callbacks against a hook is executed. 2. In code, callbacks for a given hook can be executed. Arguments can be passed to the hook.execute() call that, in conjunction with the map that is associated with callbacks, determines the order in which callbacks are executed or even whether a given callback is executed or not. 3. The above is not an event-driven pattern. It just allows for code logic to be more extensible and allows for template-based code design where basic functionality can be provided by the template designer and augmented by the template user by registering additional callbacks against known hooks. I've fully implemented this in C++ code, but I'm now looking to take advantage of whatever Groovy might provide to make this easier. Any thoughts? Thanks, Steve Amerige SAS Institute, Deployment Developer ---------------------------------------------------------------------(Continue reading)
RSS Feed