Grails class names

Grails, programming

Seems like there are many flavors of the name for a Grails class:

  • fullName — Returns the full name of the class in the application with the the trailing convention part and with the package name
  • name — Returns the logical name of the class in the application without the trailing convention part if applicable and without the package name.
  • naturalName — Returns the name of the property in natural terms (eg. ‘lastName’ becomes ‘Last Name’)
  • shortName — Returns the short name of the class without package prefix
  • propertyName — Returns the name of the class as a property name
  • logicalPropertyName — Returns the logical name of the class as a property name

These are from http://grails.org/doc/2.2.x/api/org/codehaus/groovy/grails/commons/GrailsClass.html.  It looks like somebody just typed in something just to have something show up in Javadoc.

A pause in the code to show an example is probably the best way to document these names.  For a class like com.blah.UserManagementController:

  • fullName: com.blah.UserManagementController
  • name: UserManagement
  • naturalName: User Management Controller
  • shortName: UserManagementController
  • propertyName: userManagementController
  • logicalPropertyName: userManagement

Now that that’s out of the way, notes:

Spring’s application context (e.g. grailsApplication.mainContext) holds on to its beans using names that may not be obvious. The easiest way to figure out is to fire up

grails console

and evaluate

grailsApplication.mainContext.getBeanDefinitionNames()

and find the bean’s name.

Leave a Reply