org.restlet.ext.spring
Class SpringFinder

java.lang.Object
  extended by org.restlet.Uniform
      extended by org.restlet.Restlet
          extended by org.restlet.Finder
              extended by 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)

Constructor Summary
SpringFinder()
          Constructor.
SpringFinder(Context context)
          Constructor.
SpringFinder(Context context, Class<? extends Resource> targetClass)
          Constructor.
 
Method Summary
 Resource createResource()
          Creates a new instance of the resource class designated by the "targetClass" property.
 Resource createResource(Request request, Response response)
           
 
Methods inherited from class org.restlet.Finder
findTarget, getTargetClass, handle
 
Methods inherited from class org.restlet.Restlet
getContext, getLogger, init, isStarted, isStopped, setContext, start, stop
 
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
 

Constructor Detail

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.
Method Detail

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.