예제 #1
0
  @PostConstruct
  void registerListeners() {
    if (null == bus) {
      return;
    }
    ServerLifeCycleManager slm = bus.getExtension(ServerLifeCycleManager.class);
    if (null != slm) {
      slm.registerListener(
          new ServerLifeCycleListener() {
            public void startServer(Server server) {
              RMManager.this.startServer(server);
            }

            public void stopServer(Server server) {
              RMManager.this.stopServer(server);
            }
          });
    }
    ClientLifeCycleManager clm = bus.getExtension(ClientLifeCycleManager.class);
    if (null != clm) {
      clm.registerListener(
          new ClientLifeCycleListener() {
            public void clientCreated(Client client) {
              RMManager.this.clientCreated(client);
            }

            public void clientDestroyed(Client client) {
              RMManager.this.clientDestroyed(client);
            }
          });
    }
  }
예제 #2
0
  public void close() {
    if (cfg.getBus() == null) {
      return;
    }
    for (Closeable c : cfg.getEndpoint().getCleanupHooks()) {
      try {
        c.close();
      } catch (IOException e) {
        // ignore
      }
    }
    ClientLifeCycleManager mgr = cfg.getBus().getExtension(ClientLifeCycleManager.class);
    if (null != mgr) {
      mgr.clientDestroyed(new FrontendClientAdapter(getConfiguration()));
    }

    if (cfg.getConduitSelector() instanceof Closeable) {
      try {
        ((Closeable) cfg.getConduitSelector()).close();
      } catch (IOException e) {
        // ignore, we're destroying anyway
      }
    } else {
      cfg.getConduit().close();
    }
    state.reset();
    state = null;
    cfg = null;
  }