Skip to: Site menu | Main content

Groovy 

      Download | Documentation | Developers | Community

An agile dynamic language for the Java Platform

SpringIntegrationExamples Add comment to Wiki View in Wiki Edit Wiki page Printable Version

Example the spring integration

Integrating with Spring using Groovy-Restlet is straightforward.

Using ofBean attribute
def comp = builder.component(){
    application(uri:""){
        router{
            resource(uri:"/users/{user}", ofBean:"userResource")
        }
    }
}

comp.servers.add(protocol.HTTP, 8182)

The bean userResource is defined spring definition file as followed:

<bean id="userResource" class="org.lpny.groovyrestlet.example.spring.UserResource"
		scope="prototype" />
Using ofClass attribute
def comp = builder.component(){
    application(uri:""){
        router{
            resource(uri:"/orders", ofClass:"org.lpny.groovyrestlet.example.spring.OrdersResource")
        }
    }
}

comp.servers.add(protocol.HTTP, 8182)

If spring context is specified when creating GroovyRestlet instance, Spring'` AutowireCapableBeanFactory will be used to create that instance and autowire all necessary properties.