public class VaadinServletService extends VaadinService
VaadinServlet
.ATMOSPHERE_MISSING_ERROR, CANNOT_ACQUIRE_CLASSLOADER_SEVERE, INVALID_ATMOSPHERE_VERSION_WARNING, URL_PARAMETER_CLOSE_APPLICATION, URL_PARAMETER_RESTART_APPLICATION
Modifier | Constructor and Description |
---|---|
protected |
VaadinServletService()
Creates a servlet service.
|
|
VaadinServletService(VaadinServlet servlet,
DeploymentConfiguration deploymentConfiguration)
Creates an instance connected to the given servlet and using the given
configuration.
|
Modifier and Type | Method and Description |
---|---|
protected VaadinContext |
constructVaadinContext()
Constructs
VaadinContext for this service. |
protected List<RequestHandler> |
createRequestHandlers()
Called during initialization to add the request handlers for the service.
|
String |
getContextRootRelativePath(VaadinRequest request)
Returns relative context path for given request.
|
static VaadinServletResponse |
getCurrentResponse() |
static HttpServletRequest |
getCurrentServletRequest() |
String |
getMainDivId(VaadinSession session,
VaadinRequest request)
Creates and returns a unique ID for the DIV where the UI is to be
rendered.
|
String |
getMimeType(String resourceName)
Returns the MIME type of the specified file, or null if the MIME type is
not known.
|
protected PwaRegistry |
getPwaRegistry() |
URL |
getResource(String path,
WebBrowser browser,
AbstractTheme theme)
Returns a URL to the resource at the given Vaadin URI.
|
InputStream |
getResourceAsStream(String path,
WebBrowser browser,
AbstractTheme theme)
Opens a stream to to the resource at the given Vaadin URI.
|
URL |
getResourceInServletContextOrWebJar(String path)
Finds the given resource in the servlet context or in a webjar.
|
protected RouteRegistry |
getRouteRegistry()
Find a route registry to use for this service.
|
String |
getServiceName()
Gets a unique name for this service.
|
VaadinServlet |
getServlet()
Retrieves a reference to the servlet associated with this service.
|
URL |
getStaticResource(String path)
Returns a URL to the static resource at the given URI or null if no file
found.
|
Optional<String> |
getThemedUrl(String url,
WebBrowser browser,
AbstractTheme theme)
Checks if the given URL has a themed version.
|
void |
init()
Initializes this service.
|
protected boolean |
requestCanCreateSession(VaadinRequest request)
Checks whether it's valid to create a new service session as a result of
the given request.
|
String |
resolveResource(String url,
WebBrowser browser)
Resolves the given
url resource to be useful for
VaadinService.getResource(String, WebBrowser, AbstractTheme) and
VaadinService.getResourceAsStream(String, WebBrowser, AbstractTheme) . |
protected void |
setDefaultClassLoader()
Tries to acquire default class loader and sets it as a class loader for
this
VaadinService if found. |
accessSession, addServiceDestroyListener, addSessionDestroyListener, addSessionInitListener, addUIInitListener, closeSession, createCriticalNotificationJSON, createCriticalNotificationJSON, createInstantiator, createSessionExpiredJSON, createUINotFoundJSON, createVaadinSession, destroy, ensureAccessQueuePurged, ensurePushAvailable, findUI, findVaadinSession, fireSessionDestroy, fireUIInitListeners, getClassLoader, getContext, getCurrent, getCurrentRequest, getDependencyFilters, getDeploymentConfiguration, getExistingSession, getHtmlImportDependencyCache, getInstantiator, getRequestHandlers, getRouter, getSessionAttributeName, getSessionLock, getSystemMessages, getSystemMessagesProvider, handleRequest, handleSessionExpired, isAtmosphereAvailable, isCsrfTokenValid, isOtherSessionLocked, isResourceAvailable, isUIActive, loadInstantiators, loadSession, lockSession, modifyBootstrapPage, readFromHttpSession, reinitializeSession, removeFromHttpSession, removeSession, requestEnd, requestStart, runPendingAccessTasks, setClassLoader, setCurrent, setCurrentInstances, setSystemMessagesProvider, storeSession, unlockSession, verifyNoOtherSessionLocked, writeStringResponse, writeToHttpSession, writeUncachedStringResponse
public VaadinServletService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration)
servlet
- the servlet which receives requestsdeploymentConfiguration
- the configuration to useprotected VaadinServletService()
getServlet()
and VaadinService.getContext()
should be
overridden (or otherwise intercepted) to not return null
.protected List<RequestHandler> createRequestHandlers() throws ServiceException
VaadinService
createRequestHandlers
in class VaadinService
ServiceException
- if a problem occurs when creating the request handlerspublic VaadinServlet getServlet()
public String getMimeType(String resourceName)
VaadinService
getMimeType
in class VaadinService
resourceName
- a String specifying the name of a fileServletContext#getMimeType(String)
protected boolean requestCanCreateSession(VaadinRequest request)
VaadinService
requestCanCreateSession
in class VaadinService
request
- the requesttrue
if it's valid to create a new service session
for the request; else false
public void init() throws ServiceException
VaadinService
init
in class VaadinService
ServiceException
- if a problem occurs when creating the servicepublic static HttpServletRequest getCurrentServletRequest()
public static VaadinServletResponse getCurrentResponse()
public String getServiceName()
VaadinService
getServiceName
in class VaadinService
public String getMainDivId(VaadinSession session, VaadinRequest request)
VaadinService
getMainDivId
in class VaadinService
session
- The service session to which the bootstrapped UI will belong.request
- The request for which a div id is neededprotected RouteRegistry getRouteRegistry()
VaadinService
getRouteRegistry
in class VaadinService
null
protected PwaRegistry getPwaRegistry()
getPwaRegistry
in class VaadinService
public String resolveResource(String url, WebBrowser browser)
VaadinService
url
resource to be useful for
VaadinService.getResource(String, WebBrowser, AbstractTheme)
and
VaadinService.getResourceAsStream(String, WebBrowser, AbstractTheme)
.resolveResource
in class VaadinService
url
- the resource to resolve, not null
browser
- the web browser to resolve for, relevant for es5 vs es6
resolvingpublic URL getStaticResource(String path)
VaadinService
getStaticResource
in class VaadinService
path
- the URL for the resourcenull
if
there is no resource at that pathpublic URL getResource(String path, WebBrowser browser, AbstractTheme theme)
VaadinService
getResource
in class VaadinService
path
- the untranslated Vaadin URL for the resourcebrowser
- the web browser to resolve for, relevant for es5 vs es6
resolvingtheme
- the theme to use for translating the URL or null
if no theme is usednull
if
there is no resource at that pathpublic InputStream getResourceAsStream(String path, WebBrowser browser, AbstractTheme theme)
VaadinService
getResourceAsStream
in class VaadinService
path
- the untranslated Vaadin URL for the resourcebrowser
- the web browser to resolve for, relevant for es5 vs es6
resolvingtheme
- the theme to use for translating the URL or null
if no theme is usednull
if no resource
exists at the specified pathpublic Optional<String> getThemedUrl(String url, WebBrowser browser, AbstractTheme theme)
VaadinService
getThemedUrl
in class VaadinService
url
- the URL to lookupbrowser
- the browser to use for lookuptheme
- the theme to checkpublic URL getResourceInServletContextOrWebJar(String path)
path
- the path inside servlet context, automatically translated as
needed for webjarsnull
if no resource was
foundpublic String getContextRootRelativePath(VaadinRequest request)
VaadinService
getContextRootRelativePath
in class VaadinService
request
- Request.protected VaadinContext constructVaadinContext()
VaadinService
VaadinContext
for this service.
This method will be called only once, upon first call to
VaadinService.getContext()
.constructVaadinContext
in class VaadinService
null
.protected void setDefaultClassLoader()
VaadinService
VaadinService
if found. If current security policy disallows
acquiring class loader instance it will log a message and re-throw
SecurityException
setDefaultClassLoader
in class VaadinService
Copyright © 2023. All rights reserved.