...
- ofBean: to tell
GroovyRestletthat to create a component from Spring context by a bean name; - ofClass: to tell
GroovyRestletthat to create a component using Spring's AutowireCapableBeanFactoryInfo GroovyRestletwill only use AutowireCapableBeanFactory to create instance indicated by ofClass when Spring context is provided. Otherwise it will create an instance of that class using Java reflection
Technical detail
GroovyRestlet
...
| Code Block |
|---|
builder.restlet(ofClass:"org.restle.Transform", consArgs:[transformer.MODE_REQUEST, sheet] as Object[]) |
Another important attribute of restlet is handle, which refers to a Groovy closure. Once this attribute provided, this closure will override the default handle method of the Restlet.
| Code Block |
|---|
builder.restlet(handle:{request, response, self->
return new StringRepresentation("Hello GroovyRestlet")
})
|
Sometimes it is necessary to access the instance of Restlet itself. You can do that by appending an additional argument in the closure argument list. GroovyRestlet will automatically pass the calling instance to the closure as shown in above example.
| Info |
|---|
This handle attribute is only effected when neither ofClass nor ofBean attribute is used. |
server
client
component
application
...