Class JavaScriptBootstrapHandler
- java.lang.Object
-
- com.vaadin.flow.server.SynchronizedRequestHandler
-
- com.vaadin.flow.server.BootstrapHandler
-
- com.vaadin.flow.server.communication.JavaScriptBootstrapHandler
-
- All Implemented Interfaces:
RequestHandler,Serializable
- Direct Known Subclasses:
IndexHtmlRequestHandler
public class JavaScriptBootstrapHandler extends BootstrapHandler
Processes a 'start' request type from the client to initialize server session and UI. It returns a JSON response with everything needed to bootstrap flow views.The handler is for client driven projects where `index.html` does not contain bootstrap data. Bootstrapping is the responsibility of the `@vaadin/flow` client that is able to ask the server side to create the vaadin session and do the bootstrapping lazily.
For internal use only. May be renamed or removed in a future release.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJavaScriptBootstrapHandler.JavaScriptBootstrapContextCustom BootstrapContext forJavaScriptBootstrapHandler.-
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 Constructor Description JavaScriptBootstrapHandler()Creates a new bootstrap handler with default page builder.
-
Method Summary
All Methods Static 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 elemental.json.JsonObjectgetInitialJson(VaadinRequest request, VaadinResponse response, VaadinSession session)Returns the JSON object with the application config and UIDL info that can be used in the bootstrapper to embed that info in the initial page.protected StringgetRequestUrl(VaadinRequest request)protected static StringgetServiceUrl(VaadinRequest vaadinRequest)Gets the service URL as a URL relative to the request URI.protected voidinitializeUIWithRouter(BootstrapHandler.BootstrapContext context, UI ui)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.-
Methods inherited from class com.vaadin.flow.server.BootstrapHandler
getInitialUidl, getPageBuilder, getPushScript, getUIClass, isFrameworkInternalRequest, isRequestForHtml, isVaadinStaticFileRequest, readResource, resolvePageTitle, setupErrorDialogs, setupHiddenElement, setupPushConnectionFactory, setupPwa, showDevServerErrors, writeErrorCodeIfRequestLocationIsInvalid
-
Methods inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
getRequestBody, handleRequest, isReadAndWriteOutsideSessionLock, synchronizedHandleRequest
-
-
-
-
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)
-
createAndInitUI
protected BootstrapHandler.BootstrapContext createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session)
- Overrides:
createAndInitUIin classBootstrapHandler
-
initializeUIWithRouter
protected void initializeUIWithRouter(BootstrapHandler.BootstrapContext context, UI ui)
- Overrides:
initializeUIWithRouterin 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)
-
getServiceUrl
protected static String getServiceUrl(VaadinRequest vaadinRequest)
Gets the service URL as a URL relative to the request URI.- Parameters:
vaadinRequest- the request- Returns:
- the relative service URL
-
getInitialJson
protected elemental.json.JsonObject getInitialJson(VaadinRequest request, VaadinResponse response, VaadinSession session)
Returns the JSON object with the application config and UIDL info that can be used in the bootstrapper to embed that info in the initial page.- Parameters:
request- the vaadin request.response- the response.session- the vaadin session.- Returns:
- the initial application JSON.
-
-