|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Router
org.restlet.ext.spring.SpringBeanRouter
public class SpringBeanRouter
Restlet Router which behaves like Spring's
BeanNameUrlHandlerMapping. It
takes every bean of type Resource defined in a particular context and
examines its aliases (generally speaking, its name and id). If one of the
aliases begins with a forward slash, the resource will be attached to that
URL.
Example:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" >
<!-- Singleton instance of this class -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter"/>
<!-- Prototype beans for the resources -->
<bean name="/studies" id="studiesResource" autowire="byName" scope="prototype" class="edu.northwestern.myapp.StudiesResource" >
<property name="studyDao" ref="studyDao"/>
</bean>
<bean name="/studies/{study-identifier}/template" id="templateResource" autowire="byName" scope="prototype" class="edu.northwestern.myapp.TemplateResource" />
</beans>
This will route two resources: "/studies" and
"/studies/{study-identifier}/template" to the corresponding
Resource subclass.
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.
| Field Summary |
|---|
| Fields inherited from class org.restlet.Router |
|---|
BEST, CUSTOM, FIRST, LAST, NEXT, RANDOM |
| Constructor Summary | |
|---|---|
SpringBeanRouter()
|
|
| Method Summary | |
|---|---|
protected Finder |
createFinder(BeanFactory beanFactory,
String beanName)
Creates an instance of SpringBeanFinder. |
boolean |
isFindInAncestors()
Returns true if bean names will be searched for higher up in the BeanFactory hierarchy. |
void |
postProcessBeanFactory(ConfigurableListableBeanFactory factory)
Modify the application context by looking up the name of all beans of type Resource, calling the resolveUri(String, ConfigurableListableBeanFactory) method for
each of them. |
protected String |
resolveUri(String resourceName,
ConfigurableListableBeanFactory factory)
Uses this first alias for this bean that starts with '/'. |
void |
setFindInAncestors(boolean findInAncestors)
Sets if bean names will be searched for higher up in the BeanFactory hierarchy. |
| Methods inherited from class org.restlet.Router |
|---|
attach, attach, attach, attachDefault, attachDefault, createFinder, createRoute, detach, getCustom, getDefaultMatchingMode, getDefaultMatchQuery, getDefaultRoute, getFinderClass, getMaxAttempts, getNext, getRequiredScore, getRetryDelay, getRoutes, getRoutingMode, handle, setDefaultMatchingMode, setDefaultMatchQuery, setDefaultRoute, setFinderClass, setMaxAttempts, setRequiredScore, setRetryDelay, setRoutes, setRoutingMode |
| Methods inherited from class org.restlet.Restlet |
|---|
getApplication, getContext, getLogger, 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 |
|---|
public SpringBeanRouter()
| Method Detail |
|---|
protected Finder createFinder(BeanFactory beanFactory,
String beanName)
SpringBeanFinder. This can be overriden if
necessary.
beanFactory - The Spring bean factory.beanName - The bean name.public boolean isFindInAncestors()
Default is true.
public void postProcessBeanFactory(ConfigurableListableBeanFactory factory)
throws BeansException
resolveUri(String, ConfigurableListableBeanFactory) method for
each of them. If an URI is found, a finder is created for the bean name
using the createFinder(BeanFactory, String) method.
postProcessBeanFactory in interface BeanFactoryPostProcessorBeansException
protected String resolveUri(String resourceName,
ConfigurableListableBeanFactory factory)
BeanNameUrlHandlerMapping
.
public void setFindInAncestors(boolean findInAncestors)
findInAncestors - search for beans higher up in the BeanFactory hierarchy.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||