grails metaprogramming
Posted
by Don
on Stack Overflow
See other posts from Stack Overflow
or by Don
Published on 2010-05-25T08:07:20Z
Indexed on
2010/05/25
8:11 UTC
Read the original article
Hit count: 372
Hi,
My understanding is that there are two obvious places in a Grails app where one can do meta-programming:
- The
init
closure ofBootstrap.groovy
- The
doWithDynamicMethods
closure of a plugin
The meta-programming I'm referring to here should be visible throughout the metaprogramming, typical examples include adding (or replacing) methods of 3rd party classes.
String.metaClass.myCustomMethod = { /* implementation omitted */ }
The disadvantage of (1), is that the metaprogramming won't be applied when the application is dynamically reloaded. The disadvantage of (2) is that I need to create and maintain an entire plugin just for the sake of a little metaprogramming.
Is there a better place to do this kind of metaprogramming?
Thanks, Don
© Stack Overflow or respective owner