org.restlet.ext.spring
Class SpringFinder
java.lang.Object
org.restlet.Uniform
org.restlet.Restlet
org.restlet.Finder
org.restlet.ext.spring.SpringFinder
public class SpringFinder
- extends Finder
Finder that is specialized for easier usage by Spring wiring services. The idea
is to create a singleton Spring bean based on that SpringFinder and configure
it using Spring's "lookup-method" element to return instances of a
"prototype" bean for createResource()
. Finally, attach the
SpringFinder to your Router. When the createResource() method is invoked, a
new instance of your prototype bean will be created and returned.
A sample xml for "lookup-method":
<bean id="myFinder" class="org.restlet.ext.spring.SpringFinder">
<lookup-method name="createResource" bean="myResource"/>
</bean>
<bean id="myResource" class="com.mycompany.rest.resource.MyResource" scope="prototype">
<property name="aProperty" value="anotherOne"/>
<property name="oneMore" value="true"/>
</bean>
Note that the Code Generation Library
(cglib) will be required in order to use the Spring's lookup method
mechanism.
- Author:
- Jerome Louvel (contact@noelios.com)
Methods inherited from class org.restlet.Uniform |
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SpringFinder
public SpringFinder()
- Constructor.
SpringFinder
public SpringFinder(Context context)
- Constructor.
- Parameters:
context
- The context.
SpringFinder
public SpringFinder(Context context,
Class<? extends Resource> targetClass)
- Constructor.
- Parameters:
context
- The context.targetClass
- The target resource class.
createResource
public Resource createResource(Request request,
Response response)
- Overrides:
createResource
in class Finder
createResource
public Resource createResource()
- Creates a new instance of the resource class designated by the
"targetClass" property. For easier Spring configuration, the default
target resource's constructor is invoked. The created instance is
initialized by the calling
createResource(Request, Response)
method, by invoking the Resource.init(Context, Request, Response)
method on the resource.
- Returns:
- The created resource or null.
Copyright © 2005-2007 Noelios Consulting.