public class BootstrapHandler extends SynchronizedRequestHandler
Modifier and Type | Class and Description |
---|---|
protected static class |
BootstrapHandler.BootstrapContext
Provides context information for the bootstrap process.
|
protected static class |
BootstrapHandler.BootstrapPageBuilder
Builds bootstrap pages.
|
static class |
BootstrapHandler.BootstrapUriResolver
The URI resolver used in the bootstrap process.
|
static interface |
BootstrapHandler.PageBuilder
Interface for objects capable of building the bootstrap page.
|
Modifier and Type | Field and Description |
---|---|
static String |
SERVICE_WORKER_HEADER |
Modifier | Constructor and Description |
---|---|
|
BootstrapHandler()
Creates an instance of the handler with default
BootstrapHandler.PageBuilder . |
protected |
BootstrapHandler(BootstrapHandler.PageBuilder pageBuilder)
Creates an instance of the handler using provided page builder.
|
Modifier and Type | Method and Description |
---|---|
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> contextPathCallback)
|
protected static elemental.json.JsonObject |
getInitialUidl(UI ui)
Generates the initial UIDL message which is included in the initial
bootstrap page.
|
protected BootstrapHandler.PageBuilder |
getPageBuilder()
Returns the current page builder object.
|
protected static String |
getPushScript(BootstrapHandler.BootstrapContext context) |
protected static Class<? extends UI> |
getUIClass(VaadinRequest request)
Returns the UI class mapped for servlet that handles the given request.
|
protected void |
initializeUIWithRouter(BootstrapHandler.BootstrapContext context,
UI ui) |
static boolean |
isFrameworkInternalRequest(VaadinRequest request)
Checks whether the request is an internal request.
|
protected static String |
readResource(String fileName) |
protected static Optional<String> |
resolvePageTitle(BootstrapHandler.BootstrapContext context)
Resolves the initial page title for the given bootstrap context and
cancels any pending JS execution for it.
|
protected static void |
setupErrorDialogs(org.jsoup.nodes.Element style) |
protected void |
setupPushConnectionFactory(PushConfiguration pushConfiguration,
BootstrapHandler.BootstrapContext context) |
protected static void |
setupPwa(org.jsoup.nodes.Document document,
VaadinService service) |
protected static void |
showWebpackErrors(VaadinService service,
org.jsoup.nodes.Document document) |
boolean |
synchronizedHandleRequest(VaadinSession session,
VaadinRequest request,
VaadinResponse response)
Identical to
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
except the VaadinSession is locked before this is called and
unlocked after this has completed. |
protected boolean |
writeErrorCodeIfRequestLocationIsInvalid(VaadinRequest request,
VaadinResponse response)
Checks whether the request is for a valid location, and if not, writes
the error code for the response.
|
handleRequest
public static final String SERVICE_WORKER_HEADER
public BootstrapHandler()
BootstrapHandler.PageBuilder
.protected BootstrapHandler(BootstrapHandler.PageBuilder pageBuilder)
pageBuilder
- Page builder to use.protected BootstrapHandler.PageBuilder getPageBuilder()
protected boolean canHandleRequest(VaadinRequest request)
SynchronizedRequestHandler
true
which means that all requests will be handled by
calling
SynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)
with the session locked.canHandleRequest
in class SynchronizedRequestHandler
request
- the request to handletrue
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.public static boolean isFrameworkInternalRequest(VaadinRequest request)
Warning: This assumes that the VaadinRequest is targeted for a
VaadinServlet and does no further checks to validate this. You want to
use
HandlerHelper.isFrameworkInternalRequest(String, HttpServletRequest)
instead.
This is public only so that
IndexHtmlRequestHandler
can
access it. If you are not IndexHtmlRequestHandler, go away.
request
- the requesttrue
if the request is Vaadin internal, false
otherwisepublic boolean synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException
SynchronizedRequestHandler
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
except the VaadinSession
is locked before this is called and
unlocked after this has completed.synchronizedHandleRequest
in class SynchronizedRequestHandler
session
- The session for the requestrequest
- The request to handleresponse
- The response object to which a response can be written.IOException
- If an IO error occurredSynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
protected boolean writeErrorCodeIfRequestLocationIsInvalid(VaadinRequest request, VaadinResponse response) throws IOException
request
- the request to checkresponse
- the response to writetrue
if location was invalid and error code was written,
false
if not (location was valid)IOException
- in case writing to response failsprotected static Optional<String> resolvePageTitle(BootstrapHandler.BootstrapContext context)
context
- the bootstrap contextprotected BootstrapHandler.BootstrapContext createAndInitUI(Class<? extends UI> uiClass, VaadinRequest request, VaadinResponse response, VaadinSession session)
protected void initializeUIWithRouter(BootstrapHandler.BootstrapContext context, UI ui)
protected BootstrapHandler.BootstrapContext createBootstrapContext(VaadinRequest request, VaadinResponse response, UI ui, Function<VaadinRequest,String> contextPathCallback)
request
- the request objectresponse
- the response objectui
- the UI objectprotected void setupPushConnectionFactory(PushConfiguration pushConfiguration, BootstrapHandler.BootstrapContext context)
protected static Class<? extends UI> getUIClass(VaadinRequest request)
This method is protected for testing purposes.
request
- the request for the UIprotected static elemental.json.JsonObject getInitialUidl(UI ui)
ui
- the UI for which the UIDL should be generatedprotected static String getPushScript(BootstrapHandler.BootstrapContext context)
protected static void showWebpackErrors(VaadinService service, org.jsoup.nodes.Document document)
protected static void setupErrorDialogs(org.jsoup.nodes.Element style)
protected static void setupPwa(org.jsoup.nodes.Document document, VaadinService service)
Copyright © 2021. All rights reserved.