|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.springframework.web.servlet.HttpServletBean
org.springframework.web.servlet.FrameworkServlet
com.noelios.restlet.ext.spring.RestletFrameworkServlet
public class RestletFrameworkServlet
A Servlet which provides an automatic Restlet integration with an existing
WebApplicationContext
. The usage is
similar to Spring's DispatcherServlet
. In the web.xml file, declare the Servlet and map its root URL like this:
<servlet> <servlet-name>api</servlet-name> <servlet-class>com.noelios.restlet.ext.spring.RestletFrameworkServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>api</servlet-name> <url-pattern>/api/v1/*</url-pattern> </servlet-mapping>
Then, create a beans XML file called
/WEB-INF/[servlet-name]-servlet.xml
— in this case,
/WEB-INF/api-servlet.xml
— and define your restlets and
resources in it.
All requests to this servlet will be delegated to a single top-level restlet
loaded from the Spring application context. By default, this servlet looks
for a bean named "root". You can override that by passing in the
targetRestletBeanName
parameter. For example:
<servlet> <servlet-name>api</servlet-name> <servlet-class>com.noelios.restlet.ext.spring.RestletFrameworkServlet</servlet-class> <load-on-startup>1</load-on-startup> <init-param> <param-name>targetRestletBeanName</param-name> <param-value>guard</param-value> </init-param> </servlet>
If the target restlet is an Application
, it will be used
directly. Otherwise, it will be wrapped in an instance of Application
.
Field Summary |
---|
Fields inherited from class org.springframework.web.servlet.FrameworkServlet |
---|
DEFAULT_CONTEXT_CLASS, DEFAULT_NAMESPACE_SUFFIX, SERVLET_CONTEXT_PREFIX |
Fields inherited from class org.springframework.web.servlet.HttpServletBean |
---|
logger |
Constructor Summary | |
---|---|
RestletFrameworkServlet()
|
Method Summary | |
---|---|
protected Context |
createContext()
Creates the Restlet Context to use if the target application does
not already have a context associated, or if the target restlet is not an
Application at all. |
protected void |
doService(HttpServletRequest request,
HttpServletResponse response)
|
protected ServletConverter |
getConverter()
Provides access to the ServletConverter used to handle requests. |
protected Restlet |
getTargetRestlet()
Returns the target Restlet from Spring's Web application context. |
java.lang.String |
getTargetRestletBeanName()
Returns the bean name of the target Restlet. |
protected void |
initFrameworkServlet()
|
void |
setTargetRestletBeanName(java.lang.String targetRestletBeanName)
Sets the bean name of the target Restlet. |
Methods inherited from class org.springframework.web.servlet.HttpServletBean |
---|
addRequiredProperty, getServletContext, getServletName, init, initBeanWrapper |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doHead, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RestletFrameworkServlet()
Method Detail |
---|
protected void doService(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException
doService
in class FrameworkServlet
ServletException
java.io.IOException
protected Restlet getTargetRestlet()
public java.lang.String getTargetRestletBeanName()
protected ServletConverter getConverter()
ServletConverter
used to handle requests.
Exposed so that subclasses may do additional configuration, if necessary,
by overriding initFrameworkServlet()
.
protected void initFrameworkServlet() throws ServletException, BeansException
initFrameworkServlet
in class FrameworkServlet
ServletException
BeansException
protected Context createContext()
Context
to use if the target application does
not already have a context associated, or if the target restlet is not an
Application
at all.
Uses a simple Context
by default.
Context
public void setTargetRestletBeanName(java.lang.String targetRestletBeanName)
targetRestletBeanName
- The bean name.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |