grailsgrails-3.3

grails generate-controller creating strange interface service


I'm migrating a 2.5.6 app to 3.3.10. When generating controllers, detected that a service was created and used from the controllers auto-generated code. Looking at the service, is just an interface.

Looking at the grails generate-controller documentation, I can't find information about that "interface service"

http://docs.grails.org/3.3.10/ref/Command%20Line/create-controller.html

What that service is doing internally is also a mistery, and it's not clear what/where should I touch the code when I need to customize any of those methods in the service. I guess this is a new thing in Grails 3.3.x but not sure where to find more info.

So the concrete questions are:

  1. What is the purpose of that interface service?
  2. Where is that documented?
  3. How to customize? Like being implemented by a custom service?

Sample service:

import grails.gorm.services.Service

@Service(SyncLog)
interface SyncLogService {

    SyncLog get(Serializable id)

    List<SyncLog> list(Map args)

    Long count()

    void delete(Serializable id)

    SyncLog save(SyncLog syncLog)

}

Solution

  • What is the purpose of that interface service?

    It is a starting point for your data access layer.

    Where is that documented?

    At http://gorm.grails.org/latest/hibernate/manual/index.html#dataServices

    How to customize?

    It is an interface that you can edit and add/delete whatever query methods you like. The documentation linked above describes a lot of details.