wladimirguerra
wladimirguerra

Reputation: 163

Upgrade from grails 3.2 to grails 3.3, GrailsDomainClass Api Deprecated

I have made the following replacements to upgrade my applications and plugins to grails 3.3. (the variable name change is due to improve clarity of the replacements.)

Grails 3.2:

Class<?> clazz = grailsDomainClass.clazz
...

def grailsDomainClass = new DefaultGrailsDomainClass(clazz)
...

GrailsDomainClassProperty[] properties = grailsDomainClass.properties
...

def propertyName = grailsDomainClass.propertyName
...

def referenceType = grailsDomainClassProperty.referencedPropertyType
...

Grails 3.3:

Class<?> clazz = persistentEntity.javaClass
...

def persistentEntity = grailsApplication.mappingContext.getPersistentEntity(DomainClass.class.name)
...

PersistentProperty[] properties = persistentEntity.persistentProperties
...

def propertyName = persistentEntity.decapitalizedName
...

def referenceType = persistentProperty.type

The other changes are at Grails 3.3 man.

Witch is not clear is:

  1. What is the replacement for:

    grailsDomainClass.getPropertyValue(propertyName)
    
  2. Where do I put the code which is in doWithSpring on my plugins?

The man page says:

The solution is to move any logic that executes before the context is available to somewhere else that executes after the context is available.

Somewhere else were? Is there a doWithContext closure? It can be used to inject bean?

Upvotes: 3

Views: 1173

Answers (1)

James Kleeh
James Kleeh

Reputation: 12238

  1. Use the ClassPropertyFetcher.getPropertyValue method

  2. doWithApplicationContext is a method available to override for plugins where you can put your logic.

Upvotes: 3

Related Questions