Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Excerpt

Example the spring integration

Integrating with Spring using Groovy-Restlet is straightforward.

Using ofBean attribute
Code Block
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:

Code Block
xml
xml
<bean id="userResource" class="org.lpny.groovyrestlet.example.spring.UserResource"
		scope="prototype" />
Using ofClass attribute
Code Block
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.