public class SpringVaadinServlet extends VaadinServlet
VaadinServlet that associates and manages a Spring
ConfigurableWebApplicationContext with each
VaadinSession (aka, "Vaadin application" in the old terminology).
The vaadinContextConfigLocation servlet parameter may be used to specify the Spring XML config
file location(s). For example:
<servlet>
<servlet-name>My Vaadin App</servlet-name>
<servlet-class>org.dellroad.stuff.vaadin7.SpringVaadinServlet</servlet-class>
<init-param>
<param-name>UI</param-name>
<param-value>com.example.MyApplicationUI</param-value>
</init-param>
<init-param>
<param-name>configLocation</param-name>
<param-value>classpath:com/example/MyApplicationContext.xml</param-value>
</init-param>
</servlet>
The main function of this servlet is to create and register a SpringVaadinSessionListener as a listener on the
VaadinService associated with this servlet. The SpringVaadinSessionListener in turn detects
the creation and destruction of Vaadin application instances (represented by VaadinSession
instances) and does the work of managing the associated Spring application contexts.
Use of this servlet in place of the standard Vaadin servlet is required for the @VaadinConfigurable
annotation to work.
Supported URL parameters:
| Parameter Name | Required? | Description |
|---|---|---|
applicationName |
No |
Vaadin application name. Used for logging purposes and as the name of the XML application context file
when configLocation is not specified. If this parameter is not specified, the
name of the servlet is used.
|
configLocation |
No |
Location of Spring application context XML file(s). Multiple locations are separated by whitespace.
If omitted, /WEB-INF/ServletName.xml is used, where ServletName is the name of the Vaadin
application (see applicationName).
|
listenerClass |
No |
Specify the name of a custom class extending SpringVaadinSessionListener and having the same constructor arguments.
If omitted, SpringVaadinSessionListener is used.
|
sessionTracking |
No |
Boolean value that configures whether the SpringVaadinSessionListener should track Vaadin sessions; default
false. If set to true, then getSessions() can be used to access all active sessions.
Session tracking should not be used unless sessions are normally kept in memory; e.g., don't use session tracking
when sessions are being serialized and persisted. See also VaadinSessionContainer.
|
maxSessions |
No |
Configures a limit on the number of simultaneous Vaadin sessions that may exist at one time. Going over this
limit will result in a ServiceException being thrown. A zero or negative number
means there is no limit (this is the default). Ignored unless "sessionTracking" is set to true.
|
Note: if any beans are declared scope="session" in your application context, you must register Spring's
RequestContextListener as a listener in your web.xml
(normally, Spring's DispatcherServlet would handle this task).
VaadinServlet.RequestType| Modifier and Type | Field and Description |
|---|---|
static String |
APPLICATION_NAME_PARAMETER
Servlet initialization parameter (
"applicationName") used to specify
the name the application. |
static String |
CONFIG_LOCATION_PARAMETER
Servlet initialization parameter (
"configLocation") used to specify
the location(s) of the Spring application context XML file(s). |
static String |
LISTENER_CLASS_PARAMETER
Servlet initialization parameter (
"listenerClass") used to specify
the name of an custom subclass of SpringVaadinSessionListener. |
static String |
MAX_SESSIONS_PARAMETER
Servlet initialization parameter (
"maxSessions") that configures the
maximum number of simultaneous Vaadin sessions. |
static String |
SESSION_TRACKING_PARAMETER
Servlet initialization parameter (
"sessionTracking") that enables
tracking of all Vaadin session. |
ATMOSPHERE_MISSING_ERROR, CANNOT_ACQUIRE_CLASSLOADER_SEVERE, DEFAULT_BUFFER_SIZE, DEFAULT_THEME_CACHETIME, DEFAULT_THEME_NAME, DEFAULT_WIDGETSET, ERROR_NO_UI_FOUND, INVALID_ATMOSPHERE_VERSION_WARNING, INVALID_SECURITY_KEY_MSG, MAX_BUFFER_SIZE, NOT_PRODUCTION_MODE_INFO, PARAMETER_VAADIN_RESOURCES, PARAMETER_WIDGETSET, PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, PORTAL_PARAMETER_VAADIN_THEME, PORTAL_PARAMETER_VAADIN_WIDGETSET, PORTLET_CONTEXT, PUSH_NOT_SUPPORTED_ERROR, REQUIRED_ATMOSPHERE_RUNTIME_VERSION, SERVLET_PARAMETER_CLOSE_IDLE_SESSIONS, SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, SERVLET_PARAMETER_HEARTBEAT_INTERVAL, SERVLET_PARAMETER_LEGACY_DESIGN_PREFIX, SERVLET_PARAMETER_LEGACY_PROPERTY_TOSTRING, SERVLET_PARAMETER_PRODUCTION_MODE, SERVLET_PARAMETER_PUSH_MODE, SERVLET_PARAMETER_PUSH_SUSPEND_TIMEOUT_LONGPOLLING, SERVLET_PARAMETER_RESOURCE_CACHE_TIME, SERVLET_PARAMETER_SENDURLSASPARAMETERS, SERVLET_PARAMETER_SYNC_ID_CHECK, SERVLET_PARAMETER_UI_PROVIDER, THEME_DIR_PATH, URL_PARAMETER_THEME, WARNING_HEARTBEAT_INTERVAL_NOT_NUMERIC, WARNING_LEGACY_PROPERTY_TOSTRING, WARNING_PUSH_MODE_NOT_RECOGNIZED, WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC, WARNING_UNKNOWN_LEGACY_PROPERTY_TOSTRING_VALUE, WARNING_XSRF_PROTECTION_DISABLED, WIDGETSET_DIR_PATH, WIDGETSET_MISMATCH_INFO| Constructor and Description |
|---|
SpringVaadinServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected VaadinServletService |
createServletService(DeploymentConfiguration deploymentConfiguration) |
static SpringVaadinServlet |
getServlet(VaadinSession session)
Get the
SpringVaadinServlet that is associated with the given VaadinSession. |
List<VaadinSession> |
getSessions()
Get all live
VaadinSessions associated with this instance. |
void |
init(ServletConfig config) |
protected void |
servletInitialized() |
allowServePrecompressedResource, createDeploymentConfiguration, createVaadinRequest, criticalNotification, destroy, findResourceURL, getApplicationUrl, getCacheTime, getCurrent, getDefaultTheme, getLastPathParameter, getRequestType, getResourcePath, getService, handleContextRootWithoutSlash, isAllowedVAADINResourceUrl, isStaticResourceRequest, safeEscapeForHtml, service, stripSpecialChars, writeStaticResourceResponsedoDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, servicegetInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, logpublic static final String CONFIG_LOCATION_PARAMETER
"configLocation") used to specify
the location(s) of the Spring application context XML file(s). Multiple XML files may be separated by whitespace.
This parameter is optional.public static final String LISTENER_CLASS_PARAMETER
"listenerClass") used to specify
the name of an custom subclass of SpringVaadinSessionListener.
This parameter is optional.public static final String APPLICATION_NAME_PARAMETER
"applicationName") used to specify
the name the application.
This parameter is optional.public static final String SESSION_TRACKING_PARAMETER
"sessionTracking") that enables
tracking of all Vaadin session.
This parameter is optional, and defaults to false.public static final String MAX_SESSIONS_PARAMETER
"maxSessions") that configures the
maximum number of simultaneous Vaadin sessions. Requires SESSION_TRACKING_PARAMETER to be set to true.
This parameter is optional, and defaults to zero, which means no limit.public void init(ServletConfig config) throws ServletException
init in interface Servletinit in class VaadinServletServletExceptionprotected void servletInitialized()
throws ServletException
servletInitialized in class VaadinServletServletExceptionprotected VaadinServletService createServletService(DeploymentConfiguration deploymentConfiguration) throws ServiceException
createServletService in class VaadinServletServiceExceptionpublic List<VaadinSession> getSessions()
VaadinSessions associated with this instance.VaadinSessionContainerpublic static SpringVaadinServlet getServlet(VaadinSession session)
SpringVaadinServlet that is associated with the given VaadinSession.session - Vaadin sessionSpringVaadinServletIllegalStateException - if the VaadinServlet associated with session is not a
SpringVaadinServletCopyright © 2017. All rights reserved.