Package com.vaadin.server
Class VaadinServletService
- java.lang.Object
-
- com.vaadin.server.VaadinService
-
- com.vaadin.server.VaadinServletService
-
- All Implemented Interfaces:
Serializable
public class VaadinServletService extends VaadinService
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.vaadin.server.VaadinService
URL_PARAMETER_CLOSE_APPLICATION, URL_PARAMETER_RESTART_APPLICATION
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedVaadinServletService()Creates a servlet service.VaadinServletService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<RequestHandler>createRequestHandlers()Called during initialization to add the request handlers for the service.protected URLgetApplicationUrl(VaadinRequest request)Get the base URL that should be used for sending requests back to this service.FilegetBaseDirectory()Returns the context base directory.static StringgetCancelingRelativePath(String pathToCancel)Gets a relative path that cancels the provided path.StringgetConfiguredTheme(VaadinRequest request)Gets the theme that is configured for this deployment, e.g. from a portal parameter or just some sensible default value.StringgetConfiguredWidgetset(VaadinRequest request)Gets the widgetset that is configured for this deployment, e.g. from a parameter in web.xml.static StringgetContextRootRelativePath(VaadinRequest request)Gets a relative path you can use to refer to the context root.static VaadinServletResponsegetCurrentResponse()static javax.servlet.http.HttpServletRequestgetCurrentServletRequest()StringgetMainDivId(VaadinSession session, VaadinRequest request, Class<? extends UI> uiClass)Creates and returns a unique ID for the DIV where the UI is to be rendered.StringgetMimeType(String resourceName)Returns the MIME type of the specified file, or null if the MIME type is not known.StringgetServiceName()Gets a unique name for this service.VaadinServletgetServlet()Retrieves a reference to the servlet associated with this service.StringgetStaticFileLocation(VaadinRequest request)Return the URL from where static files, e.g. the widgetset and the theme, are served.InputStreamgetThemeResourceAsStream(UI uI, String themeName, String resource)Finds the given theme resource from the web content folder or using the class loader and returns a stream for it.booleanisStandalone(VaadinRequest request)Checks whether the UI will be rendered on its own in the browser or whether it will be included into some other context.protected booleanrequestCanCreateSession(VaadinRequest request)Checks whether it's valid to create a new service session as a result of the given request.-
Methods inherited from class com.vaadin.server.VaadinService
accessSession, addServiceDestroyListener, addSessionDestroyListener, addSessionInitListener, cleanupSession, closeSession, createCriticalNotificationJSON, createVaadinSession, criticalNotification, destroy, ensureAccessQueuePurged, ensurePushAvailable, findUI, findVaadinSession, fireSessionDestroy, generateConnectorId, getClassLoader, getCurrent, getCurrentRequest, getDependencyFilters, getDeploymentConfiguration, getExistingSession, getLockAttributeName, getRequestHandlers, getServiceInitListeners, getSessionAttributeName, getSessionLock, getSystemMessages, getSystemMessagesProvider, handleRequest, handleSessionExpired, init, initConnectorIdGenerator, initDependencyFilters, isAtmosphereAvailable, isCsrfTokenValid, isOtherSessionLocked, isUIActive, loadSession, lockSession, preserveUIOnRefresh, readFromHttpSession, reinitializeSession, removeFromHttpSession, removeServiceDestroyListener, removeSession, removeSessionDestroyListener, removeSessionInitListener, requestEnd, requestStart, runPendingAccessTasks, setClassLoader, setCurrent, setCurrentInstances, setDefaultClassLoader, setSessionLock, setSystemMessagesProvider, storeSession, unlockSession, verifyNoOtherSessionLocked, writeStringResponse, writeToHttpSession, writeUncachedStringResponse
-
-
-
-
Constructor Detail
-
VaadinServletService
public VaadinServletService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration) throws ServiceException
- Throws:
ServiceException
-
VaadinServletService
protected VaadinServletService()
Creates a servlet service. This method is for use by dependency injection frameworks etc.getServlet()should be overridden (or otherwise intercepted) so it does not returnnull.- Since:
- 8.2
-
-
Method Detail
-
createRequestHandlers
protected List<RequestHandler> createRequestHandlers() throws ServiceException
Description copied from class:VaadinServiceCalled during initialization to add the request handlers for the service. Note that the returned list will be reversed so the last handler will be called first. This enables overriding this method and using add on the returned list to add a custom request handler which overrides any predefined handler.- Overrides:
createRequestHandlersin classVaadinService- Returns:
- The list of request handlers used by this service.
- Throws:
ServiceException- if a problem occurs when creating the request handlers
-
getServlet
public VaadinServlet getServlet()
Retrieves a reference to the servlet associated with this service. Should be overridden (or otherwise intercepted) if the no-arg constructor is used to prevent NPEs.- Returns:
- A reference to the VaadinServlet this service is using
-
getStaticFileLocation
public String getStaticFileLocation(VaadinRequest request)
Description copied from class:VaadinServiceReturn the URL from where static files, e.g. the widgetset and the theme, are served. In a standard configuration the VAADIN folder inside the returned folder is what is used for widgetsets and themes. The returned folder is usually the same as the context path and independent of e.g. the servlet mapping.- Specified by:
getStaticFileLocationin classVaadinService- Parameters:
request- the request for which the location should be determined- Returns:
- The location of static resources (should contain the VAADIN directory). Never ends with a slash (/).
-
getCancelingRelativePath
public static String getCancelingRelativePath(String pathToCancel)
Gets a relative path that cancels the provided path. This essentially adds one .. for each part of the path to cancel.- Parameters:
pathToCancel- the path that should be canceled- Returns:
- a relative path that cancels out the provided path segment
-
getContextRootRelativePath
public static String getContextRootRelativePath(VaadinRequest request)
Gets a relative path you can use to refer to the context root.- Parameters:
request- the request for which the location should be determined- Returns:
- A relative path to the context root. Never ends with a slash (/).
- Since:
- 8.0.3
-
getConfiguredWidgetset
public String getConfiguredWidgetset(VaadinRequest request)
Description copied from class:VaadinServiceGets the widgetset that is configured for this deployment, e.g. from a parameter in web.xml.- Specified by:
getConfiguredWidgetsetin classVaadinService- Parameters:
request- the request for which a widgetset is required- Returns:
- the name of the widgetset
-
getConfiguredTheme
public String getConfiguredTheme(VaadinRequest request)
Description copied from class:VaadinServiceGets the theme that is configured for this deployment, e.g. from a portal parameter or just some sensible default value.- Specified by:
getConfiguredThemein classVaadinService- Parameters:
request- the request for which a theme is required- Returns:
- the name of the theme
-
isStandalone
public boolean isStandalone(VaadinRequest request)
Description copied from class:VaadinServiceChecks whether the UI will be rendered on its own in the browser or whether it will be included into some other context. A standalone UI may do things that might interfere with other parts of a page, e.g. changing the page title and requesting focus upon loading.- Specified by:
isStandalonein classVaadinService- Parameters:
request- the request for which the UI is loaded- Returns:
- a boolean indicating whether the UI should be standalone
-
getMimeType
public String getMimeType(String resourceName)
Description copied from class:VaadinServiceReturns the MIME type of the specified file, or null if the MIME type is not known. The MIME type is determined by the configuration of the container, and may be specified in a deployment descriptor. Common MIME types are "text/html" and "image/gif".- Specified by:
getMimeTypein classVaadinService- Parameters:
resourceName- a String specifying the name of a file- Returns:
- a String specifying the file's MIME type
- See Also:
ServletContext.getMimeType(String)
-
getBaseDirectory
public File getBaseDirectory()
Description copied from class:VaadinServiceReturns the context base directory. Typically an application is deployed in a such way that is has an application directory. For web applications this directory is the root directory of the web applications. In some cases applications might not have an application directory (for example web applications running inside a war).- Specified by:
getBaseDirectoryin classVaadinService- Returns:
- The application base directory or null if the application has no base directory.
-
requestCanCreateSession
protected boolean requestCanCreateSession(VaadinRequest request)
Description copied from class:VaadinServiceChecks whether it's valid to create a new service session as a result of the given request.- Specified by:
requestCanCreateSessionin classVaadinService- Parameters:
request- the request- Returns:
trueif it's valid to create a new service session for the request; elsefalse
-
getApplicationUrl
protected URL getApplicationUrl(VaadinRequest request) throws MalformedURLException
Description copied from class:VaadinServiceGet the base URL that should be used for sending requests back to this service.This is only used to support legacy cases.
- Overrides:
getApplicationUrlin classVaadinService- Returns:
- Throws:
MalformedURLException
-
getCurrentServletRequest
public static javax.servlet.http.HttpServletRequest getCurrentServletRequest()
-
getCurrentResponse
public static VaadinServletResponse getCurrentResponse()
-
getServiceName
public String getServiceName()
Description copied from class:VaadinServiceGets a unique name for this service. The name should be unique among different services of the same type but the same for corresponding instances running in different JVMs in a cluster. This is typically based on e.g. the configured servlet's or portlet's name.- Specified by:
getServiceNamein classVaadinService- Returns:
- the unique name of this service instance.
-
getThemeResourceAsStream
public InputStream getThemeResourceAsStream(UI uI, String themeName, String resource) throws IOException
Description copied from class:VaadinServiceFinds the given theme resource from the web content folder or using the class loader and returns a stream for it.- Specified by:
getThemeResourceAsStreamin classVaadinService- Parameters:
uI- The ui for which to find the resourcethemeName- The name of the themeresource- The name of the resource, e.g. "layouts/mycustomlayout.html"- Returns:
- A stream for the resource or null if the resource was not found
- Throws:
IOException- if a problem occurred while finding or opening the resource
-
getMainDivId
public String getMainDivId(VaadinSession session, VaadinRequest request, Class<? extends UI> uiClass)
Description copied from class:VaadinServiceCreates and returns a unique ID for the DIV where the UI is to be rendered.- Specified by:
getMainDivIdin classVaadinService- Parameters:
session- The service session to which the bootstrapped UI will belong.request- The request for which a div id is neededuiClass- The class of the UI that will be bootstrapped- Returns:
- the id to use in the DOM
-
-