Restlet Framework 2.2 Snapshot
Java Standard Edition

org.restlet.ext.spring
Class SpringFinder

java.lang.Object
  extended by org.restlet.Restlet
      extended by org.restlet.resource.Finder
          extended by org.restlet.ext.spring.SpringFinder
All Implemented Interfaces:
Uniform
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 create(). Finally, attach the SpringFinder to your Router. When the create() 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="create" 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, Class<? extends ServerResource> targetClass)
          Constructor.
SpringFinder(Restlet restlet)
          Constructor.
 
Method Summary
 ServerResource create()
          Creates a new instance of the ServerResource class designated by the "targetClass" property.
 ServerResource create(Class<? extends ServerResource> targetClass, Request request, Response response)
          Calls the create() method that can be configured as a lookup method in Spring.
 ServerResource create(Request request, Response response)
           
 
Methods inherited from class org.restlet.resource.Finder
createFinder, find, getTargetClass, handle, setTargetClass, toString
 
Methods inherited from class org.restlet.Restlet
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpringFinder

public SpringFinder()
Constructor.


SpringFinder

public SpringFinder(Context context)
Constructor.

Parameters:
context - The parent context.

SpringFinder

public SpringFinder(Context context,
                    Class<? extends ServerResource> targetClass)
Constructor.

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

SpringFinder

public SpringFinder(Restlet restlet)
Constructor.

Parameters:
restlet - The parent Restlet.
Method Detail

create

public ServerResource create()
Creates a new instance of the ServerResource class designated by the "targetClass" property. This method is intended to be configured as a lookup method in Spring.

Returns:
The created resource or null.

create

public ServerResource create(Class<? extends ServerResource> targetClass,
                             Request request,
                             Response response)
Calls the create() method that can be configured as a lookup method in Spring. Overriding this method was necessary for direct calls to it, for example by unit tests.

Overrides:
create in class Finder

create

public ServerResource create(Request request,
                             Response response)
Overrides:
create in class Finder

Restlet Framework 2.2 Snapshot
Java Standard Edition

Copyright © 2005-2014 Restlet.