Is possible to get all services extended from a certain interface in grails
So I can collect them within one service
Is possible to get all services extended from a certain interface in grails
So I can collect them within one service
Copyright © 2021 Jogjafile Inc.
Yes, I think you can do this by autowiring to
Listtype. Let's say you have three implementations of an interfaceBaseServiceingrails-app/servicesas:grails-app/services/exampleapp/BaseService.groovy
grails-app/services/exampleapp/OneImplService.groovy
grails-app/services/exampleapp/TwoImplService.groovy
Now, you can inject all implementations of
BaseSeriveas follows:grails-app/services/exampleapp/TestService.groovy
Please note that the above example is tested with Grails 5 web application. But, I would be surprised if this does not work in the previous versions of Grails.