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
Direct Known Subclasses:
SpringBeanFinder

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. Concurrency note: instances of this class or its subclasses can be invoked by several threads at the same time and therefore must be thread-safe. You should be especially careful when storing state in member variables.

Author:
Jerome Louvel
See Also:
Spring home page

Constructor Summary
SpringFinder()
          Constructor.
SpringFinder(Context context)
          Constructor.
SpringFinder(Context context, java.lang.Class<? extends Resource> targetClass)
          Constructor.
 
Method Summary
 Resource createResource()
          Creates a new instance of the resource class designated by the "targetClass" property.
 Resource createTarget(Request request, Response response)
           
 
Methods inherited from class org.restlet.Finder
createResource, createTarget, findTarget, getTargetClass, handle, setTargetClass
 
Methods inherited from class org.restlet.Restlet
getApplication, 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,
                    java.lang.Class<? extends Resource> targetClass)
Constructor.

Parameters:
context - The context.
targetClass - The target resource class.
Method Detail

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 Finder.createResource(Request, Response) method, by invoking the Resource.init(Context, Request, Response) method on the resource.

Returns:
The created resource or null.

createTarget

public Resource createTarget(Request request,
                             Response response)
Overrides:
createTarget in class Finder


Copyright © 2005-2008 Noelios Technologies.