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.






