Package com.vaadin.flow.server
Class VaadinServletService
java.lang.Object
com.vaadin.flow.server.VaadinService
com.vaadin.flow.server.VaadinServletService
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
SpringVaadinServletService
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
ConstructorsModifierConstructorDescriptionprotectedCreates 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 VaadinContextConstructsVaadinContextfor 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 VaadinServletResponsestatic jakarta.servlet.http.HttpServletRequestgetMainDivId(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 PwaRegistrygetResource(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 RouteRegistryFind 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 booleanrequestCanCreateSession(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 givenurlresource to be useful forVaadinService.getResource(String)andVaadinService.getResourceAsStream(String).protected voidTries to acquire default class loader and sets it as a class loader for thisVaadinServiceif found.Methods inherited from class com.vaadin.flow.server.VaadinService
accessSession, addServiceDestroyListener, addSessionDestroyListener, addSessionInitListener, addUIInitListener, closeSession, createCriticalNotificationJSON, createCriticalNotificationJSON, createDefaultExecutor, createDefaultObjectMapper, createInstantiator, createSessionExpiredJSON, createUINotFoundJSON, createVaadinRequestInterceptors, createVaadinSession, destroy, ensureAccessQueuePurged, ensurePushAvailable, findUI, findVaadinSession, fireSessionDestroy, fireUIInitListeners, getBootstrapInitialPredicate, getBootstrapUrlPredicate, getClassLoader, getContext, getCsrfTokenAttributeName, getCurrent, getCurrentRequest, getDependencyFilters, getDeploymentConfiguration, getExecutor, 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: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
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: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:
-
requestCanCreateSession
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
-
getCurrentServletRequest
public static jakarta.servlet.http.HttpServletRequest getCurrentServletRequest() -
getCurrentResponse
-
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 name.- Specified by:
getServiceNamein classVaadinService- Returns:
- the unique name of this service instance.
-
getMainDivId
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 needed- Returns:
- the id to use in the DOM
-
getRouteRegistry
Description copied from class:VaadinServiceFind a route registry to use for this service.- Specified by:
getRouteRegistryin classVaadinService- Returns:
- the route registry to use, not
null
-
getPwaRegistry
- Specified by:
getPwaRegistryin classVaadinService
-
resolveResource
Description copied from class:VaadinServiceResolves the givenurlresource to be useful forVaadinService.getResource(String)andVaadinService.getResourceAsStream(String).- Specified by:
resolveResourcein 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:VaadinServiceReturns a URL to the static resource at the given URI or null if no file found.- Specified by:
getStaticResourcein classVaadinService- Parameters:
path- the URL for the resource- Returns:
- the resource located at the named path, or
nullif there is no resource at that path
-
getResource
Description copied from class:VaadinServiceReturns a URL to the resource at the given Vaadin URI.- Specified by:
getResourcein classVaadinService- Parameters:
path- the untranslated Vaadin URL for the resource- Returns:
- the resource located at the named path, or
nullif there is no resource at that path
-
getResourceAsStream
Description copied from class:VaadinServiceOpens a stream to to the resource at the given Vaadin URI.- Specified by:
getResourceAsStreamin classVaadinService- Parameters:
path- the untranslated Vaadin URL for the resource- Returns:
- a stream for the resource or
nullif no resource exists at the specified path
-
getResourceInServletContext
Finds the given resource in the servlet context.- Parameters:
path- the path inside servlet context- Returns:
- a URL for the resource or
nullif no resource was found
-
getContextRootRelativePath
Description copied from class:VaadinServiceReturns relative context path for given request. Override this method in subclasses.- Specified by:
getContextRootRelativePathin classVaadinService- Parameters:
request- Request.- Returns:
- Relative context root path for that request.
-
constructVaadinContext
Description copied from class:VaadinServiceConstructsVaadinContextfor this service. This method will be called only once, upon first call toVaadinService.getContext().- Specified by:
constructVaadinContextin classVaadinService- Returns:
- Context. This may never be
null.
-
setDefaultClassLoader
protected void setDefaultClassLoader()Description copied from class:VaadinServiceTries to acquire default class loader and sets it as a class loader for thisVaadinServiceif found. If current security policy disallows acquiring class loader instance it will log a message and re-throwSecurityException- Overrides:
setDefaultClassLoaderin classVaadinService
-