简体   繁体   English

Grails插件:获取所有命令对象类

[英]Grails Plugin: Getting all command object classes

In a plugin, I need to iterate over all domain and command object classes to apply some meta-magic to them. 在一个插件中,我需要遍历所有域和命令对象类,以对它们应用一些元魔术。 Getting the domain classes isn't a problem, however command objects are not that easy to get hold of, since they don't seem to be considered Grails artefacts. 获取域类不是问题,但是命令对象并不是那么容易掌握,因为它们似乎不被视为Grails工件。 After browsing the docs, I came up with the following code: 浏览文档后,我想到了以下代码:

def doWithDynamicMethods = { ctx ->
    application.controllerClasses.each {
        it.commandObjectClasses.each {
            // do something
        }
    }
}

This seems to work, however it doesn't include the command objects that are used inside webflow actions . 这似乎可行,但是其中不包含在webflow操作中使用的命令对象 Is this a bug or is my approach wrong? 这是错误还是我的方法错误?

I don't believe commandObjects are true domainObjects. 我不相信commandObjects是真正的domainObjects。 You could use the Artefact API to register them and to find them. 您可以使用Artefact API进行注册并找到它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM