A quickie post, I've Disappeared for a while, but I'll be back with tons of new posts, for now, here is a quick way to get annotations on Grails Domain Classes, it might be helpful for doing some post processing of your domain model with the help of a plugin
For this example I'm getting the field annotations of all declared fields in my declared domain classes, using the doWithApplicationContext closure that comes with all plugins:
def doWithApplicationContext = { applicationContext ->
for(GrailsDomainClass domainClass in application.domainClasses) {
println "DOMAIN CLASS ${domainClass}: "
domainClass.clazz.declaredFields.each{
field ->
if(field.declaredAnnotations){
println "$ {} has the Following field.name annotations $ {field.declaredAnnotations}"
/ / Do some more processing}
}}}
0 comments:
Post a Comment