com.vaadin.ui.UI.getUIId()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中com.vaadin.ui.UI.getUIId()方法的一些代码示例,展示了UI.getUIId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UI.getUIId()方法的具体详情如下:
包路径:com.vaadin.ui.UI
类名称:UI
方法名:getUIId

UI.getUIId介绍

[英]Gets the id of the UI, used to identify this UI within its application when processing requests. The UI id should be present in every request to the server that originates from this UI. VaadinService#findUI(VaadinRequest) uses this id to find the route to which the request belongs.

This method is not intended to be overridden. If it is overridden, care should be taken since this method might be called in situations where UI#getCurrent() does not return this UI.
[中]获取UI的id,用于在处理请求时在其应用程序中标识此UI。UI id应该出现在从该UI发出的对服务器的每个请求中。VaadinService#findUI(VaadinRequest)使用此id查找请求所属的路由。
此方法不打算被重写。如果它被重写,则应小心,因为在UI#getCurrent()不返回此UI的情况下可能会调用此方法。

代码示例

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * @deprecated As of 7.1. See #11410.
 */
@Deprecated
public ClientCache getClientCache(UI uI) {
  Integer uiId = Integer.valueOf(uI.getUIId());
  ClientCache cache = uiToClientCache.get(uiId);
  if (cache == null) {
    cache = new ClientCache();
    uiToClientCache.put(uiId, cache);
  }
  return cache;
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Gets a global URI for a resource if it's registered with this handler.
 *
 * @param connector
 *            the connector for which the uri should be generated.
 * @param resource
 *            the resource for which the uri should be generated.
 * @return an URI string, or <code>null</code> if the resource is not
 *         registered.
 */
public String getUri(ClientConnector connector,
    ConnectorResource resource) {
  // app://APP/global/[ui]/[type]/[id]
  String uri = legacyResourceKeys.get(resource);
  if (uri != null && !uri.isEmpty()) {
    return ApplicationConstants.APP_PROTOCOL_PREFIX
        + ApplicationConstants.APP_PATH + '/'
        + RESOURCE_REQUEST_PATH + connector.getUI().getUIId() + '/'
        + uri;
  } else {
    return null;
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Called by the framework to remove an UI instance from the session because
 * it has been closed.
 *
 * @param ui
 *            the UI to remove
 */
public void removeUI(UI ui) {
  assert hasLock() : "Session is locked";
  assert UI.getCurrent() != null : "Current UI cannot be null";
  assert ui != null : "Removed UI cannot be null";
  assert UI.getCurrent().getUIId() == ui.getUIId() : "UIs don't match";
  Integer id = Integer.valueOf(ui.getUIId());
  ui.setSession(null);
  uIs.remove(id);
  String embedId = ui.getEmbedId();
  if (embedId != null && id.equals(embedIdMap.get(embedId))) {
    embedIdMap.remove(embedId);
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Adds an initialized UI to this session.
 *
 * @param ui
 *            the initialized UI to add.
 */
public void addUI(UI ui) {
  assert hasLock();
  if (ui.getUIId() == -1) {
    throw new IllegalArgumentException(
        "Can not add an UI that has not been initialized.");
  }
  if (ui.getSession() != this) {
    throw new IllegalArgumentException(
        "The UI belongs to a different session");
  }
  Integer uiId = Integer.valueOf(ui.getUIId());
  uIs.put(uiId, ui);
  String embedId = ui.getEmbedId();
  if (embedId != null) {
    Integer previousUiId = embedIdMap.put(embedId, uiId);
    if (previousUiId != null) {
      UI previousUi = uIs.get(previousUiId);
      assert previousUi != null && embedId.equals(previousUi
          .getEmbedId()) : "UI id map and embed id map not in sync";
      // Will fire cleanup events at the end of the request handling.
      previousUi.close();
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Hack used to return existing LegacyWindow instances without regard for
 * out-of-sync problems.
 *
 * @param event
 * @return
 */
public UI getExistingUI(UIClassSelectionEvent event) {
  UI uiInstance = getUIInstance(event);
  if (uiInstance == null || uiInstance.getUIId() == -1) {
    // Not initialized -> Let go through createUIInstance to make it
    // initialized
    return null;
  } else {
    UI.setCurrent(uiInstance);
    return uiInstance;
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

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;
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Removes those UIs from the given session for which {@link UI#isClosing()
 * isClosing} yields true.
 *
 * @param session
 */
private void removeClosedUIs(final VaadinSession session) {
  List<UI> uis = new ArrayList<>(session.getUIs());
  for (final UI ui : uis) {
    if (ui.isClosing()) {
      ui.accessSynchronously(() -> {
        getLogger().log(Level.FINER, "Removing closed UI {0}",
            ui.getUIId());
        session.removeUI(ui);
      });
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

private String getStreamVariableTargetUrl(String name,
    StreamVariable value) {
  String connectorId = getConnectorId();
  UI ui = getUI();
  int uiId = ui.getUIId();
  String key = uiId + "/" + connectorId + "/" + name;
  ConnectorTracker connectorTracker = ui.getConnectorTracker();
  connectorTracker.addStreamVariable(connectorId, name, value);
  String secKey = connectorTracker.getSeckey(value);
  return ApplicationConstants.APP_PROTOCOL_PREFIX
      + ServletPortletHelper.UPLOAD_URL_PREFIX + key + "/" + secKey;
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * @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;
}

代码示例来源:origin: com.vaadin/vaadin-server

/**
 * Closes those UIs in the given session for which {@link #isUIActive}
 * yields false.
 *
 * @since 7.0.0
 */
private void closeInactiveUIs(VaadinSession session) {
  final String sessionId = session.getSession().getId();
  for (final UI ui : session.getUIs()) {
    if (!isUIActive(ui) && !ui.isClosing()) {
      ui.accessSynchronously(() -> {
        getLogger().log(Level.FINE,
            "Closing inactive UI #{0} in session {1}",
            new Object[] { ui.getUIId(), sessionId });
        ui.close();
      });
    }
  }
}

代码示例来源:origin: com.vaadin/vaadin-server

@Override
public boolean synchronizedHandleRequest(VaadinSession session,
    VaadinRequest request, VaadinResponse response) throws IOException {
  try {
    assert UI.getCurrent() == null;
    // Update browser information from the request
    session.getBrowser().updateRequestDetails(request);
    UI uI = getBrowserDetailsUI(request, session);
    session.getCommunicationManager().repaintAll(uI);
    JsonObject params = Json.createObject();
    params.put(UIConstants.UI_ID_PARAMETER, uI.getUIId());
    String initialUIDL = getInitialUidl(request, uI);
    params.put("uidl", initialUIDL);
    return commitJsonResponse(request, response,
        JsonUtil.stringify(params));
  } catch (JsonException e) {
    throw new IOException("Error producing initial UIDL", e);
  }
}

代码示例来源:origin: org.vaadin.spring/spring-vaadin

public UIID(UI ui) {
  Assert.notNull(ui, "ui must not be null");
  Assert.isTrue(ui.getUIId() > -1, "UIId of ui must not be -1");
  this.uiId = ui.getUIId();
}

代码示例来源:origin: com.vaadin/vaadin-server

getLogger().log(Level.SEVERE,
    "Exception while cleaning connector map for ui "
        + ui.getUIId(),
    e);

代码示例来源:origin: com.vaadin/hummingbird-server

@Override
  public void execute() {
    getLogger().log(Level.FINE,
        "Closing inactive UI #{0} in session {1}",
        new Object[] { ui.getUIId(), sessionId });
    ui.close();
  }
});

代码示例来源:origin: com.vaadin/hummingbird-server

@Override
  public void execute() {
    getLogger().log(Level.FINER, "Removing closed UI {0}",
        ui.getUIId());
    session.removeUI(ui);
  }
});

代码示例来源:origin: eclipse/hawkbit

@Override
public void clean() {
  LOG.info("Cleanup delayed event push strategy for UI {}", vaadinUI.getUIId());
  jobHandle.cancel(true);
  queue.clear();
}

代码示例来源:origin: org.eclipse.hawkbit/hawkbit-ui

@Override
public void clean() {
  LOG.info("Cleanup delayed event push strategy for UI", vaadinUI.getUIId());
  jobHandle.cancel(true);
  queue.clear();
}

代码示例来源:origin: info.magnolia.ui/magnolia-ui-framework

UiContextReferenceImpl(UI ui) {
  this.uiId = String.format("%s:%d", ui.getEmbedId(), ui.getUIId());
}

代码示例来源:origin: org.vaadin.spring/spring-vaadin

private UIID getUIID() {
  final UI currentUI = UI.getCurrent();
  if (currentUI != null && currentUI.getUIId() != -1) {
    return new UIID(currentUI);
  } else {
    UIID currentIdentifier = CurrentInstance.get(UIID.class);
    Assert.notNull(currentIdentifier, String.format("Found no valid %s instance!", UIID.class.getName()));
    return currentIdentifier;
  }
}

代码示例来源:origin: com.vaadin/hummingbird-server

/**
 * Called by the framework to remove an UI instance from the session because
 * it has been closed.
 *
 * @param ui
 *            the UI to remove
 */
public void removeUI(UI ui) {
  assert hasLock();
  assert UI.getCurrent() == ui;
  Integer id = Integer.valueOf(ui.getUIId());
  ui.getInternals().setSession(null);
  uIs.remove(id);
}

相关文章