/** * Checks whether the given connector has already been initialized in the * browser. The given connector should be registered with this connector * tracker. * * @param connector * the client connector to check * @return <code>true</code> if the initial state has previously been sent * to the browser, <code>false</code> if the client-side doesn't * already know anything about the connector. */ public boolean isClientSideInitialized(ClientConnector connector) { assert connectorIdToConnector.get(connector .getConnectorId()) == connector : "Connector should be registered with this ConnectorTracker"; return !uninitializedConnectors.contains(connector); }
public void setDiffState(ClientConnector connector, JsonObject diffState) { assert getConnector(connector.getConnectorId()) == connector; diffStates.put(connector, diffState); }
public JsonObject getDiffState(ClientConnector connector) { assert getConnector(connector.getConnectorId()) == connector; return diffStates.get(connector); }
/** * Returns a string with the connector name and id. Useful mostly for * debugging and logging. * * @param connector * The connector * @return A string that describes the connector */ private String getConnectorString(ClientConnector connector) { if (connector == null) { return "(null)"; } String connectorId; try { connectorId = connector.getConnectorId(); } catch (RuntimeException e) { // This happens if the connector is not attached to the application. // SHOULD not happen in this case but theoretically can. connectorId = "@" + Integer.toHexString(connector.hashCode()); } return connector.getClass().getName() + "(" + connectorId + ")"; }
/** * Removes all references and information about the given connector, which * must not be registered. * * @param connector * @param globalResourceHandler */ private void removeUnregisteredConnector(ClientConnector connector, GlobalResourceHandler globalResourceHandler) { ClientConnector removedConnector = connectorIdToConnector .remove(connector.getConnectorId()); assert removedConnector == connector; if (globalResourceHandler != null) { globalResourceHandler.unregisterConnector(connector); } uninitializedConnectors.remove(connector); diffStates.remove(connector); }
@Override public void endPaintable(Component paintable) throws PaintException { if (getLogger().isLoggable(Level.FINE)) { getLogger().log(Level.FINE, "endPaintable for {0}@{1}", new Object[] { paintable.getClass().getName(), Integer.toHexString(paintable.hashCode()) }); } ClientConnector openPaintable = openPaintables.peek(); if (paintable != openPaintable) { throw new PaintException("Invalid UIDL: closing wrong paintable: '" + paintable.getConnectorId() + "' expected: '" + openPaintable.getConnectorId() + "'."); } // remove paintable from the stack openPaintables.pop(); String openTag = openPaintableTags.pop(); endTag(openTag); }
sb.append("\""); if (key instanceof ClientConnector) { sb.append(((ClientConnector) key).getConnectorId()); } else { sb.append(escapeJSON(key.toString()));
/** * Creates a string containing debug info for the connector. * * @since 7.1 * @param connector * The connector to print debug info about * @return A string with debug information */ public static String getDebugInformation(ClientConnector connector) { StringBuilder sb = new StringBuilder(); sb.append("*** Debug details of a connector: *** \n"); sb.append("Type: "); sb.append(connector.getClass().getName()); sb.append("\nId:"); sb.append(connector.getConnectorId()); if (connector instanceof Component) { Component component = (Component) connector; if (component.getCaption() != null) { sb.append("\nCaption:"); sb.append(component.getCaption()); } } writeHierarchyInformation(connector, sb); return sb.toString(); }
boolean wasUnregistered = unregisteredConnectors.remove(connector); String connectorId = connector.getConnectorId(); ClientConnector previouslyRegistered = connectorIdToConnector .get(connectorId);
private void cleanStreamVariable(VaadinSession session, final UI ui, final ClientConnector owner, final String variableName) { session.accessSynchronously(() -> ui.getConnectorTracker() .cleanStreamVariable(owner.getConnectorId(), variableName)); } }
private static String getConnectorResourceBase(String filename, ClientConnector connector) { String uri = ApplicationConstants.APP_PROTOCOL_PREFIX + ApplicationConstants.APP_PATH + '/' + ConnectorResource.CONNECTOR_PATH + '/' + connector.getUI().getUIId() + '/' + connector.getConnectorId() + '/' + encodeFileName(filename); return uri; }
private static JsonObject encodeConnectorMap(Type valueType, Map<?, ?> map, ConnectorTracker connectorTracker) { JsonObject jsonMap = Json.createObject(); for (Entry<?, ?> entry : map.entrySet()) { ClientConnector key = (ClientConnector) entry.getKey(); if (LegacyCommunicationManager.isConnectorVisibleToClient(key)) { EncodeResult encodedValue = encode(entry.getValue(), null, valueType, connectorTracker); jsonMap.put(key.getConnectorId(), encodedValue.getEncodedValue()); } } return jsonMap; }
String connectorId = connector.getConnectorId(); if (!connectorIdToConnector.containsKey(connectorId)) { getLogger().log(Level.WARNING,
"Received a legacy variable change for " + connector.getClass().getName() + " (" + connector.getConnectorId() + ") which is not a VariableOwner. The client-side connector sent these legacy variables: " + changes.keySet());
if (!hierachyInfo.hasKey(firstVisibleParent.getConnectorId())) { Set<?> stateUpdateConnectors = (Set<?>) stateUpdateConnectorsObj; if (!stateUpdateConnectors .contains(firstVisibleParent.getConnectorId())) {
String connectorType = target.getTag(connector); try { connectorTypes.put(connector.getConnectorId(), connectorType); } catch (JsonException e) { throw new PaintException( "Failed to send connector type for connector " + connector.getConnectorId() + ": " + e.getMessage(), e);
/** * @deprecated As of 7.1. See #11411. */ @Deprecated public String getStreamVariableTargetUrl(ClientConnector owner, String name, StreamVariable value) { /* * We will use the same APP/* URI space as ApplicationResources but * prefix url with UPLOAD * * e.g. APP/UPLOAD/[UIID]/[PID]/[NAME]/[SECKEY] * * SECKEY is created on each paint to make URL's unpredictable (to * prevent CSRF attacks). * * NAME and PID from URI forms a key to fetch StreamVariable when * handling post */ String paintableId = owner.getConnectorId(); UI ui = owner.getUI(); int uiId = ui.getUIId(); String key = uiId + "/" + paintableId + "/" + name; ConnectorTracker connectorTracker = ui.getConnectorTracker(); connectorTracker.addStreamVariable(paintableId, name, value); String seckey = connectorTracker.getSeckey(value); return ApplicationConstants.APP_PROTOCOL_PREFIX + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + seckey; }
for (ClientConnector connector : dirtyVisibleConnectors) { String connectorId = connector.getConnectorId(); try { JsonObject stateJson = connector.encodeState();
String connectorId = connector.getConnectorId(); JsonArray children = Json.createArray(); if (LegacyCommunicationManager .isConnectorVisibleToClient(child)) { children.set(children.length(), child.getConnectorId());
+ connector.getConnectorId() + " because the component was disabled");