com.vaadin.server.communication
Class HeartbeatHandler
java.lang.Object
com.vaadin.server.SynchronizedRequestHandler
com.vaadin.server.communication.HeartbeatHandler
- All Implemented Interfaces:
- RequestHandler, SessionExpiredHandler, java.io.Serializable
public class HeartbeatHandler
- extends SynchronizedRequestHandler
- implements SessionExpiredHandler
Handles heartbeat requests. Heartbeat requests are periodically sent by the
client-side to inform the server that the UI sending the heartbeat is still
alive (the browser window is open, the connection is up) even when there are
no UIDL requests for a prolonged period of time. UIs that do not receive
either heartbeat or UIDL requests are eventually removed from the session and
garbage collected.
- Since:
- 7.1
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HeartbeatHandler
public HeartbeatHandler()
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
calling
SynchronizedRequestHandler.synchronizedHandleRequest(VaadinSession, VaadinRequest, VaadinResponse)
with the session locked.
- Overrides:
canHandleRequest
in class SynchronizedRequestHandler
- Parameters:
request
- the request to handle
- Returns:
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.
synchronizedHandleRequest
public boolean synchronizedHandleRequest(VaadinSession session,
VaadinRequest request,
VaadinResponse response)
throws java.io.IOException
- Handles a heartbeat request for the given session. Reads the GET
parameter named
UIConstants.UI_ID_PARAMETER
to identify the UI.
If the UI is found in the session, sets it
heartbeat timestamp
to the current
time. Otherwise, writes a HTTP Not Found error to the response.
- Specified by:
synchronizedHandleRequest
in class SynchronizedRequestHandler
- 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:
java.io.IOException
- If an IO error occurred- See Also:
SynchronizedRequestHandler.handleRequest(VaadinSession, VaadinRequest, VaadinResponse)
handleSessionExpired
public boolean handleSessionExpired(VaadinRequest request,
VaadinResponse response)
throws java.io.IOException
- Description copied from interface:
SessionExpiredHandler
- Called when the a session expiration has occured and a notification needs
to be sent to the user. If a response is written, this method should
return
true
to indicate that no more
SessionExpiredHandler
handlers should be invoked for the request.
- Specified by:
handleSessionExpired
in interface SessionExpiredHandler
- 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:
java.io.IOException
- If an IO error occurred
Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.