Class UidlRequestHandler
java.lang.Object
com.vaadin.flow.server.SynchronizedRequestHandler
com.vaadin.flow.server.communication.UidlRequestHandler
- All Implemented Interfaces:
RequestHandler,SessionExpiredHandler,Serializable
Processes a UIDL request from the client.
Uses
ServerRpcHandler to execute client-to-server RPC invocations and
UidlWriter to write state changes and client RPC calls back to the
client.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
SynchronizedRequestHandler.ResponseWriter -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Patternstatic final Stringstatic final Stringstatic final PatternFields inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
MAX_BUFFER_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancanHandleRequest(VaadinRequest request) Check whether a request may be handled by this handler.static voidcommitJsonResponse(VaadinResponse response, String json) Commit the JSON response.protected ServerRpcHandlerCreates the ServerRpcHandler to use.booleanhandleSessionExpired(VaadinRequest request, VaadinResponse response) Called when the a session expiration has occurred and a notification needs to be sent to the user.booleanGets if request body should be read and the response written without holdingVaadinSessionlockbooleansynchronizedHandleRequest(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.synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response, String requestBody) Identical toSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)except theVaadinSessionis locked before this is called and the response requestBody has been read before locking the session and is provided as a separate parameter.Methods inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
getRequestBody, handleRequestMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.server.RequestHandler
handleRequest
-
Field Details
-
HASH_PATTERN
-
URL_PATTERN
-
PUSH_STATE_HASH
- See Also:
-
PUSH_STATE_LOCATION
- See Also:
-
-
Constructor Details
-
UidlRequestHandler
public UidlRequestHandler()
-
-
Method Details
-
canHandleRequest
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 classSynchronizedRequestHandler- 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.
-
createRpcHandler
Creates the ServerRpcHandler to use.- Returns:
- the ServerRpcHandler to use
-
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.- Specified by:
synchronizedHandleRequestin classSynchronizedRequestHandler- 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:
-
isReadAndWriteOutsideSessionLock
public boolean isReadAndWriteOutsideSessionLock()Description copied from class:SynchronizedRequestHandlerGets if request body should be read and the response written without holdingVaadinSessionlock- Overrides:
isReadAndWriteOutsideSessionLockin classSynchronizedRequestHandler- Returns:
- true if
SynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse, String)should be called. Returns false ifSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)should be called.
-
synchronizedHandleRequest
public Optional<SynchronizedRequestHandler.ResponseWriter> synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response, String requestBody) throws IOException, UnsupportedOperationException Description copied from class:SynchronizedRequestHandlerIdentical toSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)except theVaadinSessionis locked before this is called and the response requestBody has been read before locking the session and is provided as a separate parameter.- Overrides:
synchronizedHandleRequestin classSynchronizedRequestHandler- Parameters:
session- The session for the requestrequest- The request to handleresponse- The response object to which a response can be written.requestBody- Request body pre-read from the request object- Returns:
- a ResponseWriter wrapped into an Optional, if this handler will write the response and no further request handlers should be called, otherwise an empty Optional. The ResponseWriter will be executed after the VaadinSession is unlocked.
- Throws:
IOException- If an IO error occurredUnsupportedOperationException- See Also:
-
handleSessionExpired
public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException Description copied from interface:SessionExpiredHandlerCalled when the a session expiration has occurred and a notification needs to be sent to the user. If a response is written, this method should returntrueto indicate that no moreSessionExpiredHandlerhandlers should be invoked for the request.- Specified by:
handleSessionExpiredin interfaceSessionExpiredHandler- Parameters:
request- 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
-
commitJsonResponse
Commit the JSON response. We can't write immediately to the output stream as we want to write only a critical notification if something goes wrong during the response handling.- Parameters:
response- The response to write tojson- The JSON to write- Throws:
IOException- If there was an exception while writing to the output
-