com.vaadin.flow.server.
Class VaadinServletService
All Implemented Interfaces:
Direct Known Subclasses:
A service implementation connected to a VaadinServlet
.
Since:
1.0
Author:
Vaadin Ltd
See Also:
-
Field Summary
Fields inherited from class com.vaadin.flow.server.VaadinService
ATMOSPHERE_MISSING_ERROR, INVALID_ATMOSPHERE_VERSION_WARNING
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a servlet service.
VaadinServletService
(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration) Creates an instance connected to the given servlet and using the given configuration.
-
Method Summary
Modifier and TypeMethodDescriptionprotected VaadinContext
Constructs
VaadinContext
for this service.protected List<RequestHandler>
Called during initialization to add the request handlers for the service.
getContextRootRelativePath
(VaadinRequest request) Returns relative context path for given request.
static VaadinServletResponse
static jakarta.servlet.http.HttpServletRequest
getMainDivId
(VaadinSession session, VaadinRequest request) Creates and returns a unique ID for the DIV where the UI is to be rendered.
getMimeType
(String resourceName) Returns the MIME type of the specified file, or null if the MIME type is not known.
protected PwaRegistry
getResource
(String path) Returns a URL to the resource at the given Vaadin URI.
getResourceAsStream
(String path) Opens a stream to to the resource at the given Vaadin URI.
Finds the given resource in the servlet context.
protected RouteRegistry
Find a route registry to use for this service.
Gets a unique name for this service.
Retrieves a reference to the servlet associated with this service.
getStaticResource
(String path) Returns a URL to the static resource at the given URI or null if no file found.
protected boolean
requestCanCreateSession
(VaadinRequest request) Checks whether it's valid to create a new service session as a result of the given request.
resolveResource
(String url) Resolves the given
url
resource to be useful forVaadinService.getResource(String)
andVaadinService.getResourceAsStream(String)
.protected void
Tries to acquire default class loader and sets it as a class loader for this
VaadinService
if found.Methods inherited from class com.vaadin.flow.server.VaadinService
accessSession, addServiceDestroyListener, addSessionDestroyListener, addSessionInitListener, addUIInitListener, closeSession, createCriticalNotificationJSON, createCriticalNotificationJSON, createInstantiator, createSessionExpiredJSON, createUINotFoundJSON, createVaadinRequestInterceptors, createVaadinSession, destroy, ensureAccessQueuePurged, ensurePushAvailable, findUI, findVaadinSession, fireSessionDestroy, fireUIInitListeners, getBootstrapInitialPredicate, getBootstrapUrlPredicate, getClassLoader, getContext, getCsrfTokenAttributeName, getCurrent, getCurrentRequest, getDependencyFilters, getDeploymentConfiguration, getExistingSession, getInstantiator, getRequestHandlers, getRouter, getSessionAttributeName, getSessionLock, getSystemMessages, getSystemMessagesProvider, getVaadinRequestInterceptors, handleRequest, handleSessionExpired, init, isAtmosphereAvailable, isCsrfTokenValid, isOtherSessionLocked, isResourceAvailable, isUIActive, loadInstantiators, loadSession, lockSession, modifyIndexHtmlResponse, readFromHttpSession, reinitializeSession, removeFromHttpSession, removeSession, requestEnd, requestStart, runPendingAccessTasks, setBootstrapInitialPredicate, setBootstrapUrlPredicate, setClassLoader, setCurrent, setCurrentInstances, setSystemMessagesProvider, storeSession, unlockSession, verifyNoOtherSessionLocked, writeStringResponse, writeToHttpSession, writeUncachedStringResponse
-
Constructor Details
-
VaadinServletService
Creates an instance connected to the given servlet and using the given configuration.
Parameters:
servlet
- the servlet which receives requestsdeploymentConfiguration
- the configuration to use -
VaadinServletService
protected VaadinServletService()Creates a servlet service. This method is for use by dependency injection frameworks etc.
getServlet()
andVaadinService.getContext()
should be overridden (or otherwise intercepted) to not returnnull
.
-
-
Method Details
-
createRequestHandlers
Description copied from class:
VaadinService
Called 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:
createRequestHandlers
in classVaadinService
Returns:
The list of request handlers used by this service.
Throws:
ServiceException
- if a problem occurs when creating the request handlers -
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
-
getMimeType
Description copied from class:
VaadinService
Returns 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".
ServletContext.getMimeType(String)
Specified by:
getMimeType
in classVaadinService
Parameters:
resourceName
- a String specifying the name of a fileReturns:
a String specifying the file's MIME type
See Also:
-
requestCanCreateSession
Description copied from class:
VaadinService
Checks whether it's valid to create a new service session as a result of the given request.
Specified by:
requestCanCreateSession
in classVaadinService
Parameters:
request
- the requestReturns:
true
if it's valid to create a new service session for the request; elsefalse
-
getCurrentServletRequest
public static jakarta.servlet.http.HttpServletRequest getCurrentServletRequest() -
getCurrentResponse
-
getServiceName
Description copied from class:
VaadinService
Gets 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 name.
Specified by:
getServiceName
in classVaadinService
Returns:
the unique name of this service instance.
-
getMainDivId
Description copied from class:
VaadinService
Creates and returns a unique ID for the DIV where the UI is to be rendered.
Specified by:
getMainDivId
in classVaadinService
Parameters:
session
- The service session to which the bootstrapped UI will belong.request
- The request for which a div id is neededReturns:
the id to use in the DOM
-
getRouteRegistry
Description copied from class:
VaadinService
Find a route registry to use for this service.
Specified by:
getRouteRegistry
in classVaadinService
Returns:
the route registry to use, not
null
-
getPwaRegistry
Specified by:
getPwaRegistry
in classVaadinService
-
resolveResource
Description copied from class:
VaadinService
Resolves the given
url
resource to be useful forVaadinService.getResource(String)
andVaadinService.getResourceAsStream(String)
.Specified by:
resolveResource
in classVaadinService
Parameters:
url
- the resource to resolve, notnull
Returns:
the resolved URL or the same as the input url if no translation was performed
-
getStaticResource
Description copied from class:
VaadinService
Returns a URL to the static resource at the given URI or null if no file found.
Specified by:
getStaticResource
in classVaadinService
Parameters:
path
- the URL for the resourceReturns:
the resource located at the named path, or
null
if there is no resource at that path -
getResource
Description copied from class:
VaadinService
Returns a URL to the resource at the given Vaadin URI.
Specified by:
getResource
in classVaadinService
Parameters:
path
- the untranslated Vaadin URL for the resourceReturns:
the resource located at the named path, or
null
if there is no resource at that path -
getResourceAsStream
Description copied from class:
VaadinService
Opens a stream to to the resource at the given Vaadin URI.
Specified by:
getResourceAsStream
in classVaadinService
Parameters:
path
- the untranslated Vaadin URL for the resourceReturns:
a stream for the resource or
null
if no resource exists at the specified path -
getResourceInServletContext
Finds the given resource in the servlet context.
Parameters:
path
- the path inside servlet contextReturns:
a URL for the resource or
null
if no resource was found -
getContextRootRelativePath
Description copied from class:
VaadinService
Returns relative context path for given request. Override this method in subclasses.
Specified by:
getContextRootRelativePath
in classVaadinService
Parameters:
request
- Request.Returns:
Relative context root path for that request.
-
constructVaadinContext
Description copied from class:
VaadinService
Constructs
VaadinContext
for this service. This method will be called only once, upon first call toVaadinService.getContext()
.Specified by:
constructVaadinContext
in classVaadinService
Returns:
Context. This may never be
null
. -
setDefaultClassLoader
protected void setDefaultClassLoader()Description copied from class:
VaadinService
Tries to acquire default class loader and sets it as a class loader for this
VaadinService
if found. If current security policy disallows acquiring class loader instance it will log a message and re-throwSecurityException
Overrides:
setDefaultClassLoader
in classVaadinService
-