dcd*_*rns 4 grails grails-plugin grails-2.0
如何列出grails插件的所有控制器/服务.或者我如何知道给定GrailsApplication类的pluin名称.
Bur*_*ith 11
插件中的工件使用注释进行GrailsPlugin注释,以添加有关其源的元数据.所以你可以用它来查找控制器/服务/等.来自应用程序或这样的插件:
import org.codehaus.groovy.grails.plugins.metadata.GrailsPlugin
for (type in ['controller', 'service']) {
for (artifactClass in ctx.grailsApplication."${type}Classes") {
def clazz = artifactClass.clazz
def annotation = clazz.getAnnotation(GrailsPlugin)
if (annotation) {
println "$type $clazz.name from plugin '${annotation.name()}'"
}
else {
println "$type $clazz.name from application"
}
}
}
Run Code Online (Sandbox Code Playgroud)