Ejemplo n.º 1
0
  /**
   * Starts XMPP component.
   *
   * @param component the instance of XMPP component to start.
   * @return <tt>true</tt> if XMPP component has been started successfully.
   */
  private boolean startComponent(ComponentBase component) {
    this.component = component;

    String host = component.getHostname();
    int port = component.getPort();

    this.componentManager = new ExternalComponentManager(host, port);

    String componentSubDomain = component.getSubdomain();
    componentManager.setSecretKey(componentSubDomain, component.getSecret());

    componentManager.setServerName(component.getDomain());

    ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);

    component.init();

    connectRetry = new RetryStrategy(executorService);

    connectRetry.runRetryingTask(new SimpleRetryTask(0, 5000, true, getConnectCallable()));

    return true;
  }
Ejemplo n.º 2
0
  /** Disconnects XMPP component if one is currently in use. */
  private void stopComponent() {
    synchronized (connectSynRoot) {
      if (component == null || componentManager == null) return;

      if (connectRetry != null) {
        connectRetry.cancel();
        connectRetry = null;
      }

      component.shutdown();
      try {
        componentManager.removeComponent(component.getSubdomain());
      } catch (ComponentException e) {
        logger.error(e, e);
      }

      component.dispose();

      component = null;
      componentManager = null;
    }
  }