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

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

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

UI.isClosing介绍

[英]Returns whether this UI is marked as closed and is to be detached.

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是否标记为已关闭且要分离。
此方法不打算被重写。如果它被重写,则应小心,因为在UI#getCurrent()不返回此UI的情况下可能会调用此方法。

代码示例

代码示例来源: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

if (ui.isClosing()) {
  return false;

代码示例来源: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

&& connector.getUI().isClosing()) {
String msg = "Ignoring RPC call for connector "
    + connector.getClass().getName();

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

if (!ui.isClosing()) {
  ui.close();

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

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

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

/**
 * Returns whether the given UI is active (the client-side actively
 * communicates with the server) or whether it can be removed from the
 * session and eventually collected.
 * <p>
 * A UI is active if and only if its {@link UI#isClosing() isClosing}
 * returns false and {@link #getHeartbeatTimeout() getHeartbeatTimeout} is
 * negative or has not yet expired.
 *
 * @since 7.0.0
 *
 * @param ui
 *            The UI whose status to check
 *
 * @return true if the UI is active, false if it could be removed.
 */
private boolean isUIActive(UI ui) {
  if (ui.isClosing()) {
    return false;
  } else {
    long now = System.currentTimeMillis();
    int timeout = 1000 * getHeartbeatTimeout();
    return timeout < 0 || now
        - ui.getInternals().getLastHeartbeatTimestamp() < timeout;
  }
}

代码示例来源:origin: com.vaadin/hummingbird-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(new Command() {
        @Override
        public void execute() {
          getLogger().log(Level.FINE,
              "Closing inactive UI #{0} in session {1}",
              new Object[] { ui.getUIId(), sessionId });
          ui.close();
        }
      });
    }
  }
}

相关文章