com.vaadin.flow.server.communication.
Class UidlRequestHandler
- java.lang.Object
-
- com.vaadin.flow.server.SynchronizedRequestHandler
-
- com.vaadin.flow.server.communication.UidlRequestHandler
-
All Implemented Interfaces:
public class UidlRequestHandler extends SynchronizedRequestHandler implements SessionExpiredHandler
Processes a UIDL request from the client. Uses
ServerRpcHandler
to execute client-to-server RPC invocations andUidlWriter
to write state changes and client RPC calls back to the client.Since:
1.0
Author:
Vaadin Ltd
See Also:
-
-
Constructor Summary
Constructors Constructor and Description UidlRequestHandler()
-
Method Summary
All Methods Modifier and Type Method and Description protected boolean
canHandleRequest(VaadinRequest request)
Check whether a request may be handled by this handler.
static void
commitJsonResponse(VaadinResponse response, String json)
Commit the JSON response.
protected ServerRpcHandler
createRpcHandler()
Creates the ServerRpcHandler to use.
boolean
handleSessionExpired(VaadinRequest request, VaadinResponse response)
Called when the a session expiration has occurred and a notification needs to be sent to the user.
boolean
synchronizedHandleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response)
Identical to
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
except theVaadinSession
is locked before this is called and unlocked after this has completed.-
Methods inherited from class com.vaadin.flow.server.SynchronizedRequestHandler
handleRequest
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.server.RequestHandler
handleRequest
-
-
-
-
Field Detail
-
UIDL_PATH
public static final String UIDL_PATH
See Also:
-
-
Method Detail
-
canHandleRequest
protected boolean canHandleRequest(VaadinRequest request)
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 returns
true
which means that all requests will be handled by callingSynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)
with the session locked.Overrides:
canHandleRequest
in classSynchronizedRequestHandler
Parameters:
request
- the request to handleReturns:
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.
-
createRpcHandler
protected ServerRpcHandler 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:
SynchronizedRequestHandler
Identical to
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
except theVaadinSession
is locked before this is called and unlocked after this has completed.Specified by:
synchronizedHandleRequest
in 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 occurredSee Also:
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
-
handleSessionExpired
public boolean handleSessionExpired(VaadinRequest request, VaadinResponse response) throws IOException
Description copied from interface:
SessionExpiredHandler
Called 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 return
true
to indicate that no moreSessionExpiredHandler
handlers should be invoked for the request.Specified by:
handleSessionExpired
in 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
public static void commitJsonResponse(VaadinResponse response, String json) throws IOException
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 writeThrows:
IOException
- If there was an exception while writing to the output
-
-