O'Reilly logo

Grails 2: A Quick-Start Guide by Ben Klein, Dave Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Grails Service Classes

We’re going to write a method that will create several Task instances and add them to the tasks property of a newly created TekEvent. We will define this method in a service class. A Grails service class is a Plain Old Groovy Object (POGO) located in the grails-app/services directory and with a name ending in Service. By following these conventions, this plain old Groovy object will be endowed with magical powers.

Service classes are a great way to keep extra code out of our controllers. When we have application logic that doesn’t fit well in any domain class—for example, logic that involves multiple domain classes—it is tempting to add this code to the controller. Doing this can lead to bloated controllers that are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required