views:

44

answers:

1

In the grails doc, I read (something along the lines) that the implementation of a server class will bu automatically wired based on the naming convention.

If this is true, then how would one go about overriding this behavior down the road say if you have a new implementation?

do we have options? like:

  1. use @annotations
  2. if you don't want to re-compile, add the entry to the xml
+1  A: 

I am assuming "server class" was meant to be typed as "service class" and "bu"->"be"?

If those assumptions are correct: yes, they are autowired.

You create a grails service called UserService in your grails-app/services directory, you can inject it into a controller using:

def userService

You can override this behavior using the Spring DSL in the resources.groovy file in your grails-app/conf/spring directory. Or if you prefer XML, you can add a resources.xml file in grails-app/conf/spring to configure your Spring Beans.

proflux
what about using annotations?
Blankman
That's an interesting question and I'm really not sure of the answer. I assume you mean using something like @Qualifier within the class having the service injected. I'll consider the fact that I haven't encountered this proof that convention over configuration is working. :) The byName autowiring has been sufficient for me up to this point. Now I'm curious though, I'm going to have to do a few experiments tomorrow if I have some down time to see if it's as simple as updating the config and importing the Spring annotations.
proflux
well in spring-mvc you can use annotations, so I figured it was the same with grails.
Blankman