Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: restlet section


  • ofBean: to tell GroovyRestlet that to create a component from Spring context by a bean name;
  • ofClass: to tell GroovyRestlet that to create a component using Spring's AutowireCapableBeanFactory

    GroovyRestlet will 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



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.


This handle attribute is only effected when neither ofClass nor ofBean attribute is used.