|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.ui.ConnectorTracker
public class ConnectorTracker
A class which takes care of book keeping of ClientConnector
s for a
UI.
Provides getConnector(String)
which can be used to lookup a
connector from its id. This is for framework use only and should not be
needed in applications.
Tracks which ClientConnector
s are dirty so they can be updated to the
client when the following response is sent. A connector is dirty when an
operation has been performed on it on the server and as a result of this
operation new information needs to be sent to its
com.vaadin.client.ServerConnector
.
Constructor Summary | |
---|---|
ConnectorTracker(UI uI)
Creates a new ConnectorTracker for the given uI. |
Method Summary | |
---|---|
void |
addStreamVariable(java.lang.String connectorId,
java.lang.String variableName,
StreamVariable variable)
Adds a StreamVariable of the given name to the indicated connector. |
void |
cleanConcurrentlyRemovedConnectorIds(int lastSyncIdSeenByClient)
Maintains the bookkeeping connector removal and concurrency by removing entries that have become too old. |
void |
cleanConnectorMap()
Cleans the connector map from all connectors that are no longer attached to the application. |
void |
cleanStreamVariable(java.lang.String connectorId,
java.lang.String variableName)
Removes any StreamVariable of the given name from the indicated connector. |
boolean |
connectorWasPresentAsRequestWasSent(java.lang.String connectorId,
long lastSyncIdSeenByClient)
Check whether a connector was present on the client when the it was creating this request, but was removed server-side before the request arrived. |
ClientConnector |
getConnector(java.lang.String connectorId)
Gets a connector by its id. |
int |
getCurrentSyncId()
Gets the most recently generated server sync id. |
elemental.json.JsonObject |
getDiffState(ClientConnector connector)
|
java.util.Collection<ClientConnector> |
getDirtyConnectors()
Returns a collection of all connectors which have been marked as dirty. |
java.util.ArrayList<ClientConnector> |
getDirtyVisibleConnectors()
Returns a collection of those dirty
connectors that are actually visible to the client. |
static java.util.logging.Logger |
getLogger()
Gets a logger for this class |
java.lang.String |
getSeckey(StreamVariable variable)
Returns the security key associated with the given StreamVariable. |
StreamVariable |
getStreamVariable(java.lang.String connectorId,
java.lang.String variableName)
Checks if the indicated connector has a StreamVariable of the given name and returns the variable if one is found. |
boolean |
hasDirtyConnectors()
Checks if there a dirty connectors. |
boolean |
isClientSideInitialized(ClientConnector connector)
Checks whether the given connector has already been initialized in the browser. |
boolean |
isDirty(ClientConnector connector)
|
boolean |
isWritingResponse()
Checks whether the response is currently being written. |
void |
markAllClientSidesUninitialized()
Marks all currently registered connectors as uninitialized. |
void |
markAllConnectorsClean()
Mark all connectors in this uI as clean. |
void |
markAllConnectorsDirty()
Mark all connectors in this uI as dirty. |
void |
markClean(ClientConnector connector)
Mark the connector as clean. |
void |
markClientSideInitialized(ClientConnector connector)
Marks the given connector as initialized, meaning that the client-side state has been initialized for the connector. |
void |
markDirty(ClientConnector connector)
Mark the connector as dirty. |
void |
registerConnector(ClientConnector connector)
Register the given connector. |
void |
setDiffState(ClientConnector connector,
elemental.json.JsonObject diffState)
|
void |
setWritingResponse(boolean writingResponse)
Sets the current response write status. |
void |
unregisterConnector(ClientConnector connector)
Unregister the given connector. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ConnectorTracker(UI uI)
ConnectorTracker
.
uI
- The uI to attach to. Cannot be null.Method Detail |
---|
public static java.util.logging.Logger getLogger()
public void registerConnector(ClientConnector connector)
The lookup method getConnector(String)
only returns registered
connectors.
connector
- The connector to register.public void unregisterConnector(ClientConnector connector)
The lookup method getConnector(String)
only returns registered
connectors.
connector
- The connector to unregisterpublic boolean isClientSideInitialized(ClientConnector connector)
connector
- the client connector to check
true
if the initial state has previously been sent
to the browser, false
if the client-side doesn't
already know anything about the connector.public void markClientSideInitialized(ClientConnector connector)
connector
- the connector that should be marked as initializedisClientSideInitialized(ClientConnector)
public void markAllClientSidesUninitialized()
isClientSideInitialized(ClientConnector)
public ClientConnector getConnector(java.lang.String connectorId)
connectorId
- The connector id to look for
public void cleanConnectorMap()
public void markDirty(ClientConnector connector)
connector
- The connector that should be marked clean.getDirtyConnectors()
,
isWritingResponse()
public void markClean(ClientConnector connector)
connector
- The connector that should be marked clean.public void markAllConnectorsDirty()
public void markAllConnectorsClean()
public java.util.Collection<ClientConnector> getDirtyConnectors()
The state and pending RPC calls for dirty connectors are sent to the client in the following request.
public boolean hasDirtyConnectors()
public java.util.ArrayList<ClientConnector> getDirtyVisibleConnectors()
dirty
connectors
that are actually visible to the client.
public elemental.json.JsonObject getDiffState(ClientConnector connector)
public void setDiffState(ClientConnector connector, elemental.json.JsonObject diffState)
public boolean isDirty(ClientConnector connector)
public boolean isWritingResponse()
true
if the response is currently being written,
false
if outside the response writing phase.setWritingResponse(boolean)
,
markDirty(ClientConnector)
public void setWritingResponse(boolean writingResponse)
This method has a side-effect of incrementing the sync id by one (see
getCurrentSyncId()
), if isWritingResponse()
returns
true
and writingResponse
is set to
false
.
writingResponse
- the new response status.
java.lang.IllegalArgumentException
- if the new response status is the same as the previous value.
This is done to help detecting problems caused by missed
invocations of this method.markDirty(ClientConnector)
,
isWritingResponse()
,
getCurrentSyncId()
public StreamVariable getStreamVariable(java.lang.String connectorId, java.lang.String variableName)
connectorId
- variableName
-
public void addStreamVariable(java.lang.String connectorId, java.lang.String variableName, StreamVariable variable)
connectorId
- variableName
- variable
- public void cleanStreamVariable(java.lang.String connectorId, java.lang.String variableName)
connectorId
- variableName
- public java.lang.String getSeckey(StreamVariable variable)
variable
-
public boolean connectorWasPresentAsRequestWasSent(java.lang.String connectorId, long lastSyncIdSeenByClient)
connectorId
- The connector id to check for whether it was removed
concurrently or not.lastSyncIdSeenByClient
- the most recent sync id the client has seen at the time the
request was sent, or -1 to ignore potential problems
true
if the connector was removed before the client
had a chance to react to it.public int getCurrentSyncId()
The sync id is incremented by one whenever a new response is being written. This id is then sent over to the client. The client then adds the most recent sync id to each communication packet it sends back to the server. This way, the server knows at what state the client is when the packet is sent. If the state has changed on the server side since that, the server can try to adjust the way it handles the actions from the client side.
The sync id value -1
is ignored to facilitate testing with
pre-recorded requests.
setWritingResponse(boolean)
,
connectorWasPresentAsRequestWasSent(String, long)
public void cleanConcurrentlyRemovedConnectorIds(int lastSyncIdSeenByClient)
It is important to run this call for each transmission from the client
, otherwise the bookkeeping gets out of date and the results form
connectorWasPresentAsRequestWasSent(String, long)
will become
invalid (that is, even though the client knew the component was removed,
the aforementioned method would start claiming otherwise).
Entries that both client and server agree upon are removed. Since argument is the last sync id that the client has seen from the server, we know that entries earlier than that cannot cause any problems anymore.
The sync id value -1
is ignored to facilitate testing with
pre-recorded requests.
lastSyncIdSeenByClient
- the sync id the client has most recently received from the
server.connectorWasPresentAsRequestWasSent(String, long)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |