org.restlet.ext.spring
Class SpringBeanFinder

java.lang.Object
  extended by org.restlet.Restlet
      extended by org.restlet.resource.Finder
          extended by org.restlet.ext.spring.SpringFinder
              extended by org.restlet.ext.spring.SpringBeanFinder
All Implemented Interfaces:
Uniform, BeanFactoryAware, ApplicationContextAware

public class SpringBeanFinder
extends SpringFinder
implements BeanFactoryAware, ApplicationContextAware

An alternative to SpringFinder which uses Spring's BeanFactory mechanism to load a prototype bean by name. If both a BeanFactory and a ApplicationContext are provided, the bean will be looked up first in the application context and then in the bean factory. 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:
Rhett Sutphin

Constructor Summary
SpringBeanFinder()
          Default constructor.
SpringBeanFinder(Router router, BeanFactory beanFactory, String beanName)
          Constructor.
 
Method Summary
 ServerResource create()
          Creates a new instance of the ServerResource class designated by the "targetClass" property.
 ApplicationContext getApplicationContext()
          Returns the parent application context.
 BeanFactory getBeanFactory()
          Returns the parent bean factory.
 String getBeanName()
          Returns the bean name.
 Context getContext()
           
 Router getRouter()
          Returns the associated router.
 void setApplicationContext(ApplicationContext applicationContext)
          Sets the parent application context
 void setBeanFactory(BeanFactory beanFactory)
          Sets the parent bean factory.
 void setBeanName(String beanName)
          Sets the bean name.
 void setRouter(Router router)
          Sets the associated router.
 
Methods inherited from class org.restlet.ext.spring.SpringFinder
create, create
 
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, 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

SpringBeanFinder

public SpringBeanFinder()
Default constructor.


SpringBeanFinder

public SpringBeanFinder(Router router,
                        BeanFactory beanFactory,
                        String beanName)
Constructor.

Parameters:
router - The associated router used to retrieve the context.
beanFactory - The Spring bean factory.
beanName - The bean name.
Method Detail

create

public ServerResource create()
Description copied from class: SpringFinder
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.

Overrides:
create in class SpringFinder
Returns:
The created resource or null.

getApplicationContext

public ApplicationContext getApplicationContext()
Returns the parent application context.

Returns:
The parent context.

getBeanFactory

public BeanFactory getBeanFactory()
Returns the parent bean factory.

Returns:
The parent bean factory.

getBeanName

public String getBeanName()
Returns the bean name.

Returns:
The bean name.

getContext

public Context getContext()
Overrides:
getContext in class Restlet

getRouter

public Router getRouter()
Returns the associated router.

Returns:
The associated router.

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
Sets the parent application context

Specified by:
setApplicationContext in interface ApplicationContextAware
Parameters:
applicationContext - The parent context.

setBeanFactory

public void setBeanFactory(BeanFactory beanFactory)
Sets the parent bean factory.

Specified by:
setBeanFactory in interface BeanFactoryAware
Parameters:
beanFactory - The parent bean factory.

setBeanName

public void setBeanName(String beanName)
Sets the bean name.

Parameters:
beanName - The bean name.

setRouter

public void setRouter(Router router)
Sets the associated router.

Parameters:
router - The associated router.


Copyright © 2005-2013 Restlet.