Package org.restlet.ext.spring
Class SpringServerServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.restlet.ext.servlet.ServerServlet
-
- org.restlet.ext.spring.SpringServerServlet
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Servlet
,javax.servlet.ServletConfig
public class SpringServerServlet extends ServerServlet
Spring specific ServerServlet adapter. This class is similar to the ServerServlet, but instead of creating the used Restlet Application and Restlet Component, it lookups them up from the SpringContext which is found in the ServletContext. If the Application or Component beans can't be found, the default behavior of the parent class is used.- Author:
- Florian Schwarz
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
APPLICATION_BEAN_PARAM_NAME
Name of the Servlet parameter containing a bean-id of the application to use.static java.lang.String
Component_BEAN_PARAM_NAME
Name of the Servlet parameter containing a bean-id of the component to use.
-
Constructor Summary
Constructors Constructor Description SpringServerServlet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.restlet.Application
createApplication(org.restlet.Context parentContext)
Lookups the single Restlet Application used by this Servlet from the SpringContext inside the ServletContext.org.restlet.Component
createComponent()
Lookups the single Restlet Component used by this Servlet from Spring's Context available inside the ServletContext.org.springframework.web.context.WebApplicationContext
getWebApplicationContext()
Get the Spring WebApplicationContext from the ServletContext.-
Methods inherited from class org.restlet.ext.servlet.ServerServlet
createCall, createServer, createWarClient, destroy, getApplication, getComponent, getContextPath, getInitParameter, getLocalAddr, getLocalPort, getServer, init, init, init, loadClass, service
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
-
-
-
Field Detail
-
APPLICATION_BEAN_PARAM_NAME
public static final java.lang.String APPLICATION_BEAN_PARAM_NAME
Name of the Servlet parameter containing a bean-id of the application to use.- See Also:
- Constant Field Values
-
Component_BEAN_PARAM_NAME
public static final java.lang.String Component_BEAN_PARAM_NAME
Name of the Servlet parameter containing a bean-id of the component to use.- See Also:
- Constant Field Values
-
-
Method Detail
-
createApplication
public org.restlet.Application createApplication(org.restlet.Context parentContext)
Lookups the single Restlet Application used by this Servlet from the SpringContext inside the ServletContext. The bean name looked up isAPPLICATION_BEAN_PARAM_NAME
.- Overrides:
createApplication
in classServerServlet
- Parameters:
parentContext
- The parent component context.- Returns:
- The Restlet-Application to use.
-
createComponent
public org.restlet.Component createComponent()
Lookups the single Restlet Component used by this Servlet from Spring's Context available inside the ServletContext. The bean name looked up isComponent_BEAN_PARAM_NAME
.- Overrides:
createComponent
in classServerServlet
- Returns:
- The Restlet-Component to use.
-
getWebApplicationContext
public org.springframework.web.context.WebApplicationContext getWebApplicationContext()
Get the Spring WebApplicationContext from the ServletContext. (by hand would be webApplicationContext applicationContext = (WebApplicationContext) getServletContext().getAttribute(WebApplicationContext .ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);)- Returns:
- The Spring WebApplicationContext.
-
-