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
public class WebComponentBootstrapHandler extends BootstrapHandler
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:
- Serialized Form
-
-
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
SERVICE_WORKER_HEADER
-
Fields inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
MAX_BUFFER_SIZE
-
-
Constructor Summary
Constructors Modifier Constructor Description WebComponentBootstrapHandler()Creates a new bootstrap handler with default page builder.protectedWebComponentBootstrapHandler(BootstrapHandler.PageBuilder pageBuilder)Creates a new bootstrap handler, allowing to use custom page builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanHandleRequest(VaadinRequest request)Check whether a request may be handled by this handler.protected BootstrapHandler.BootstrapContextcreateAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session)protected BootstrapHandler.BootstrapContextcreateBootstrapContext(VaadinRequest request, VaadinResponse response, UI ui, Function<VaadinRequest,String> callback)protected StringgetRequestUrl(VaadinRequest request)Returns the request's base url to use in constructing and initialising ui.protected StringgetServiceUrl(VaadinRequest request, VaadinResponse response)Returns the service url needed for initialising the UI.protected booleanhandleWebComponentResyncRequest(BootstrapHandler.BootstrapContext context, VaadinRequest request, VaadinResponse response)Handles WebComponents resynchronization requestprotected StringmodifyPath(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.booleansynchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response)Identical toSynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)except theVaadinSessionis locked before this is called and unlocked after this has completed.protected voidwriteBootstrapPage(String contentType, VaadinResponse response, org.jsoup.nodes.Element head, String serviceUrl)Copies theElementsfound in the givenheadelements into the head of the embedding website using JavaScript.-
Methods inherited from class com.vaadin.flow.server.BootstrapHandler
getInitialUidl, getPageBuilder, getPushScript, getUIClass, initializeUIWithRouter, isFrameworkInternalRequest, isRequestForHtml, isVaadinStaticFileRequest, readResource, resolvePageTitle, setupErrorDialogs, setupHiddenElement, setupPushConnectionFactory, setupPwa, showDevServerErrors, writeErrorCodeIfRequestLocationIsInvalid
-
Methods inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
getRequestBody, handleRequest, isReadAndWriteOutsideSessionLock, synchronizedHandleRequest
-
-
-
-
Constructor Detail
-
WebComponentBootstrapHandler
public WebComponentBootstrapHandler()
Creates a new bootstrap handler with default page builder.
-
WebComponentBootstrapHandler
protected WebComponentBootstrapHandler(BootstrapHandler.PageBuilder pageBuilder)
Creates a new bootstrap handler, allowing to use custom page builder.- Parameters:
pageBuilder- Page builder to use.
-
-
Method Detail
-
canHandleRequest
protected boolean canHandleRequest(VaadinRequest request)
Description copied from class:SynchronizedRequestHandlerCheck 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 returnstruewhich means that all requests will be handled by callingSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)with the session locked.- Overrides:
canHandleRequestin classBootstrapHandler- Parameters:
request- the request to handle- Returns:
trueif the request handling should continue once the session has been locked;falseif there's no need to lock the session since the request would still not be handled.
-
getRequestUrl
protected String getRequestUrl(VaadinRequest request)
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:
createAndInitUIin classBootstrapHandler
-
createBootstrapContext
protected BootstrapHandler.BootstrapContext createBootstrapContext(VaadinRequest request, VaadinResponse response, UI ui, Function<VaadinRequest,String> callback)
Description copied from class:BootstrapHandler- Overrides:
createBootstrapContextin 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:SynchronizedRequestHandlerIdentical toSynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)except theVaadinSessionis locked before this is called and unlocked after this has completed.- Overrides:
synchronizedHandleRequestin 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:
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
-
writeBootstrapPage
protected void writeBootstrapPage(String contentType, VaadinResponse response, org.jsoup.nodes.Element head, String serviceUrl) throws IOException
Copies theElementsfound in the givenheadelements into the head of the embedding website using JavaScript. Drops<base>element.- Parameters:
contentType- Content type of the response.response-VaadinResponseinto 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
protected 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.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
protected String getServiceUrl(VaadinRequest request, VaadinResponse response)
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
-
-