views:

38

answers:

0

My project's copy contains the following snippet in HibernateGrailsPlugin.groovy :

def doWithDynamicMethods = {
        def dynamicMethods = HibernatePluginSupport.doWithDynamicMethods
        dynamicMethods.delegate = delegate
        dynamicMethods.call(it)

        // aids in generating appropriate documentation in plugin.xml since 
        // domain class methods are lazily loaded we initialize them here
        if(plugin.basePlugin) {
            try {
                def clz = application.classLoader.loadClass("org.grails.Behavior")
                clz.count()             
            }
            catch(e) {
                // ignore
            }
        }
    }

I'm new to grails/groovy, but if I understand correctly, this closure is delegating the add/removal of dynamic methods to the doWithDynamicMethods closure of the HibernatePluginSupport class. It seems the HibernatePluginSupport class is compiled with the rest of grails specific code, if the code for HibernatedPluginSupport lived in my project's copy of the plugin I could easily customize it to my needs. My question is, how do I modify the autogenerated methods for specific classes? The only way I see is rewriting the doWithDynamicMethods closure in the groovy file, but I don't want to do that since I'm only customizing it for some domain classes. More specifically, How do I remove/replace dynamic methods added by the 'HibernatePluginSupport.doWithDynamicMethods' closure?