Class WebComponentBootstrapHandler
java.lang.Object
com.vaadin.flow.server.SynchronizedRequestHandler
com.vaadin.flow.server.BootstrapHandler
com.vaadin.flow.server.communication.WebComponentBootstrapHandler
- All Implemented Interfaces:
RequestHandler
,Serializable
Bootstrap handler for WebComponent requests.
For internal use only. May be renamed or removed in a future release.
- Since:
- 2.0
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.server.BootstrapHandler
BootstrapHandler.BootstrapContext, BootstrapHandler.BootstrapPageBuilder, BootstrapHandler.BootstrapUriResolver, BootstrapHandler.PageBuilder
Nested classes/interfaces inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
SynchronizedRequestHandler.ResponseWriter
-
Field Summary
Fields inherited from class com.vaadin.flow.server.BootstrapHandler
SCRIPT_TAG, SCRIPT_TEMPLATE_FOR_STYLESHEET_LINK_TAG, SERVICE_WORKER_HEADER
Fields inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
MAX_BUFFER_SIZE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionCreates a new bootstrap handler with default page builder.protected
WebComponentBootstrapHandler
(BootstrapHandler.PageBuilder pageBuilder) Creates a new bootstrap handler, allowing to use custom page builder. -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
addGeneratedIndexContent
(org.jsoup.nodes.Document targetDocument, elemental.json.JsonObject statsJson) protected boolean
canHandleRequest
(VaadinRequest request) Check whether a request may be handled by this handler.protected BootstrapHandler.BootstrapContext
createAndInitUI
(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session) protected BootstrapHandler.BootstrapContext
createBootstrapContext
(VaadinRequest request, VaadinResponse response, UI ui, Function<VaadinRequest, String> callback) protected String
getRequestUrl
(VaadinRequest request) Returns the request's base url to use in constructing and initialising ui.protected String
getServiceUrl
(VaadinRequest request, VaadinResponse response) Returns the service url needed for initialising the UI.protected boolean
handleWebComponentResyncRequest
(BootstrapHandler.BootstrapContext context, VaadinRequest request, VaadinResponse response) Handles WebComponents resynchronization requestprotected String
modifyPath
(String basePath, String path) Create a new address for a resource which is calculated based on the request base path (servlet path) and the original path for the Vaadin resource.boolean
synchronizedHandleRequest
(VaadinSession session, VaadinRequest request, VaadinResponse response) Identical toSynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
except theVaadinSession
is locked before this is called and unlocked after this has completed.protected void
writeBootstrapPage
(String contentType, VaadinResponse response, org.jsoup.nodes.Element head, String serviceUrl) Copies theElements
found in the givenhead
elements into the head of the embedding website using JavaScript.Methods inherited from class com.vaadin.flow.server.BootstrapHandler
getInitialUidl, getPageBuilder, getPushScript, getStatsJson, getStylesheetLinks, getStylesheetTags, getUIClass, initializeUIWithRouter, isFrameworkInternalRequest, isRequestForHtml, isVaadinStaticFileRequest, readResource, resolvePageTitle, setupErrorDialogs, setupHiddenElement, setupPushConnectionFactory, setupPwa, writeErrorCodeIfRequestLocationIsInvalid
Methods inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
getRequestBody, handleRequest, isReadAndWriteOutsideSessionLock, synchronizedHandleRequest
-
Constructor Details
-
WebComponentBootstrapHandler
public WebComponentBootstrapHandler()Creates a new bootstrap handler with default page builder. -
WebComponentBootstrapHandler
Creates a new bootstrap handler, allowing to use custom page builder.- Parameters:
pageBuilder
- Page builder to use.
-
-
Method Details
-
addGeneratedIndexContent
protected static void addGeneratedIndexContent(org.jsoup.nodes.Document targetDocument, elemental.json.JsonObject statsJson) -
canHandleRequest
Description copied from class:SynchronizedRequestHandler
Check whether a request may be handled by this handler. This can be used as an optimization to avoid locking the session just to investigate some method property. The default implementation just returnstrue
which means that all requests will be handled by callingSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)
with the session locked.- Overrides:
canHandleRequest
in classBootstrapHandler
- Parameters:
request
- the request to handle- Returns:
true
if the request handling should continue once the session has been locked;false
if there's no need to lock the session since the request would still not be handled.
-
getRequestUrl
Returns the request's base url to use in constructing and initialising ui.- Parameters:
request
- Request to the url for.- Returns:
- Request's url.
-
createAndInitUI
protected BootstrapHandler.BootstrapContext createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session) - Overrides:
createAndInitUI
in classBootstrapHandler
-
createBootstrapContext
protected BootstrapHandler.BootstrapContext createBootstrapContext(VaadinRequest request, VaadinResponse response, UI ui, Function<VaadinRequest, String> callback) Description copied from class:BootstrapHandler
- Overrides:
createBootstrapContext
in classBootstrapHandler
- Parameters:
request
- the request objectresponse
- the response objectui
- the UI object- Returns:
- a new bootstrap context instance
-
synchronizedHandleRequest
public boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException Description copied from class:SynchronizedRequestHandler
Identical toSynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
except theVaadinSession
is locked before this is called and unlocked after this has completed.- Overrides:
synchronizedHandleRequest
in classBootstrapHandler
- Parameters:
session
- The session for the requestrequest
- The request to handleresponse
- The response object to which a response can be written.- Returns:
- true if a response has been written and no further request handlers should be called, otherwise false
- Throws:
IOException
- If an IO error occurred- See Also:
-
writeBootstrapPage
protected void writeBootstrapPage(String contentType, VaadinResponse response, org.jsoup.nodes.Element head, String serviceUrl) throws IOException Copies theElements
found in the givenhead
elements into the head of the embedding website using JavaScript. Drops<base>
element.- Parameters:
contentType
- Content type of the response.response
-VaadinResponse
into which the script is writtenhead
- head element of Vaadin Bootstrap page. The child elements are copied into the embedding page's head using JavaScript.serviceUrl
- base path to use for the head elements' URLs- Throws:
IOException
- if writing fails
-
modifyPath
Create a new address for a resource which is calculated based on the request base path (servlet path) and the original path for the Vaadin resource.If the resource is targeted to context root with VAADIN prefix, the path part before the VAADIN is chopped of since that has been calculated to be relative to our context and would target context root instead of the serving servlet.
- Parameters:
basePath
- full servlet path, received as part of the bootstrap request. Needs to be the client-side path used, to get around proxies.path
- original resource path- Returns:
- new resource path, relative to basePath
-
getServiceUrl
Returns the service url needed for initialising the UI.- Parameters:
request
- the request objectresponse
- the response object- Returns:
- Service url for the given request.
-
handleWebComponentResyncRequest
protected boolean handleWebComponentResyncRequest(BootstrapHandler.BootstrapContext context, VaadinRequest request, VaadinResponse response) Handles WebComponents resynchronization request- Parameters:
context
- the bootstrap context objectrequest
- the request objectresponse
- the response object- Returns:
- true if request has been handled, false otherwise
-