programming

Intersting features of using Spring Injection in Grails

After some frustration of integration testing I carry on with investigation of spring injection in Grails.

So, the grails has predefined place for storing Spring configurations it’s /grails-app/spring. The grails affords two formats for defining beans. It’s standard (well-known) xml format and you can define beans by using groovy syntax. The name of spring configuration also is defined it’s resources.groovy or/and resources.xml. It’s not mistake that I’ve written or/and as you can use both of this format in same time/I think it’s useful think. Moreover, those files share the bean configurations. Another world you can use the bean that was defined in resources.groovy for making references in resources.xml, but not vice versa.

It looks like:

resources.groovy

beans = {

testString1(String, "test string")

}

resources.xml

<bean name="testString3" class="java.lang.String">
<constructor-arg ref="testString1"/>
</bean>

One thought on “Intersting features of using Spring Injection in Grails

  1. Вижу вы уже освоили Груви, я теперь отстаю (-:
    Не совсем правда понял в чём прикол этой хренотени (-;

    > you can use both of this format in same time/I think it’s useful
    Не согласен. Покачто прикола объявлять грувишным способом не вижу, зато вижу что если вдруг с грейлза спрыгнеш то прийдётся эти объявы переписывать в спринговый конфиг.
    Что касается объявления обоими способами одновременно – порочная практика ИМХО делать одно и то же двумя разными путями. Надо уже что-то одно выбрать, чтоб хотябы точно знать в каком файле у тебя бины.

    Хотя может у грувишного способа есть какие-то преимущества о которых я не знаю. Компайл тайм валидация например. Усть такое?

Leave a comment