Ejemplo n.º 1
0
  /**
   * Inicializa la comunicación con el servidor.
   *
   * @throws RequestException es lanzada cuando no se puede establecer la comunicación el servidor
   */
  protected void activeCommunication() throws RequestException {
    try {
      OutputMonitor.printLine("Initialize communication", OutputMonitor.INFORMATION_MESSAGE);

      // iniciar el entorno de ejecución de ICE
      if (communication.isInitialize()) {
        communication.reset();
      } else {
        communication.initialize(this.args);
      }
      SettingProperties.loadSettingProperies();
      ApplicationContext.initContext();
      String host = cnxServer.getServerHost();
      int serverPort = cnxServer.getServerPort();
      int clientPort = clientSetting.getPortNumber();
      OutputMonitor.printLine("Server host: " + host, OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine("Server port: " + serverPort, OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "Server name: " + cnxServer.getServerName(), OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "Container name: " + cnxServer.getContainerName(), OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "Session name: " + cnxServer.getSessionName(), OutputMonitor.INFORMATION_MESSAGE);
      OutputMonitor.printLine(
          "File store name: " + cnxServer.getFileStoreName(), OutputMonitor.INFORMATION_MESSAGE);

      if (clientPort <= 0) {
        clientPort = (clientPort <= 0) ? Utilities.getAvailablePort() : clientPort;
        clientSetting.setPortNumber(clientPort);
      }

      this.appManager = new ApplicationManager(communication, netController, clientPort);
      this.appManager.activate();
      this.server =
          new DelegateServerManager(communication, cnxServer.getServerName(), host, serverPort);
      this.server.create(); // se establece la comunicación con el proxy del servidor
      this.container = server.getDlgSessionContainer(cnxServer.getContainerName());
      this.session =
          container.getNoPersistentSessionByName(
              cnxServer.getSessionName(), Invocation.SYNCHRONOUS_METHOD_INVOCATION);
      this.session.setCommunication(container.getCommunication());
      this.fileStore =
          new DelegateFileStore(communication, cnxServer.getFileStoreName(), host, serverPort);
      this.fileStore.create();
      this.startedCommunication = true;

      OutputMonitor.printLine("Initialized communication", OutputMonitor.INFORMATION_MESSAGE);
    } catch (Exception ex) {
      throw new RequestException(ex.getMessage());
    }
  }