Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCServiceException


          * (this.receivePublicationTimeoutSeconds + this.noDataIntervalSeconds));
    } catch (Exception e) {
      PerformanceLogger.end(this.sessionId);
      // inactivate the session
      this.sessionActive = false;
      SCServiceException ex = new SCServiceException("Receive publication failed.");
      ex.setSCErrorCode(SCMPError.BROKEN_SUBSCRIPTION.getErrorCode());
      ex.setSCErrorText(SCMPError.BROKEN_SUBSCRIPTION.getErrorText("Receive publication for service=" + this.serviceName
          + " failed."));
      this.messageCallback.receive(ex);
      return;
    }
  }
View Full Code Here


   * @throws SCServiceException
   *             listener is already started<br />
   */
  public void setKeepAliveTimeoutSeconds(int keepAliveTimeoutSeconds) throws SCMPValidatorException, SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, keepAliveTimeoutSeconds, Constants.MAX_KP_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_KEEPALIVE_TIMEOUT);
    this.keepAliveTimeoutSeconds = keepAliveTimeoutSeconds;
View Full Code Here

   * @throws SCServiceException
   *             called method after attach
   */
  public void setTCPKeepAlive(boolean tcpKeepAlive) throws SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // sets the TCP keep alive in basic configuration
    AppContext.getBasicConfiguration().setTCPKeepAlive(tcpKeepAlive);
  }
View Full Code Here

   *             listener is already started<br />
   */
  public void setCheckRegistrationTimeoutSeconds(int checkRegistrationTimeoutSeconds) throws SCMPValidatorException,
      SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, checkRegistrationTimeoutSeconds, Constants.MAX_CRG_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_OPERATION_TIMEOUT);
    this.checkRegistraionTimeoutSeconds = checkRegistrationTimeoutSeconds;
View Full Code Here

   * @throws SCServiceException
   *             listener is already started<br />
   */
  public void setCheckRegistrationIntervalSeconds(int checkRegistrationIntervalSeconds) throws SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    this.checkRegistrationIntervalSeconds = checkRegistrationIntervalSeconds;
  }
View Full Code Here

   *             SC port and listener port are the same<br />
   *             bind to interface failed<be>
   */
  public synchronized void startListener() throws SCServiceException, SCMPValidatorException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to start again.");
    }
    if (this.scHost == null) {
      throw new SCMPValidatorException("Host must be set.");
    }
    if (this.connectionType == null) {
      throw new SCMPValidatorException("ConnectionType must be set.");
    }
    ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, this.scPort, Constants.MAX_PORT_VALUE, SCMPError.HV_WRONG_PORTNR);
    ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, this.listenerPort, Constants.MAX_PORT_VALUE,
        SCMPError.HV_WRONG_PORTNR);

    if (this.scPort == this.listenerPort) {
      throw new SCMPValidatorException("SC port and listener port must not be the same.");
    }

    if (this.nics == null || this.nics.size() == 0) {
      nics = new ArrayList<String>();
      try {
        Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
        for (NetworkInterface netint : Collections.list(nets)) {
          Enumeration<InetAddress> inetAdresses = netint.getInetAddresses();
          for (InetAddress inetAddress : Collections.list(inetAdresses)) {
            if (inetAddress instanceof Inet6Address) {
              // ignore IPV6 addresses, bind not possible on this NIC
              continue;
            }
            nics.add(inetAddress.getHostAddress());
            LOGGER.debug("SCServer listens on " + inetAddress.getHostAddress());
          }
        }
      } catch (Exception e) {
        LOGGER.fatal("unable to detect network interface", e);
        throw new SCMPValidatorException(SCMPError.V_WRONG_CONFIGURATION_FILE, "Wrong interface.");
      }
    }

    ListenerConfiguration listenerConfig = new ListenerConfiguration(SCSessionServer.class.getSimpleName());
    listenerConfig.setConnectionType(this.connectionType.getValue());
    listenerConfig.setNetworkInterfaces(nics);
    listenerConfig.setPort(this.listenerPort);

    responder = new Responder(listenerConfig);
    try {
      responder.create();
      responder.startListenAsync();
    } catch (Exception ex) {
      this.listening = false;
      LOGGER.error("unable to start listener=" + listenerConfig.getName(), ex);
      throw new SCServiceException("Unable to start listener.", ex);
    }
    this.listening = true;
    RemoteNodeConfiguration remoteNodeConf = new RemoteNodeConfiguration(this.listenerPort + "server", this.scHost,
        this.scPort, this.connectionType.getValue(), this.keepAliveIntervalSeconds, this.checkRegistrationIntervalSeconds,
        1);
View Full Code Here

   * @throws SCMPValidatorException
   *             service name not set<br />
   */
  public SCSessionServer newSessionServer(String serviceName) throws SCServiceException, SCMPValidatorException {
    if (this.listening == false) {
      throw new SCServiceException("NewSessionServer not possible - server not listening.");
    }
    if (serviceName == null) {
      throw new SCMPValidatorException("service name must be set");
    }
    return new SCSessionServer(this, serviceName, requester);
View Full Code Here

        unsubscribeCall.setSessionInfo(scSubscribeMessage.getSessionInfo());
      }
      try {
        unsubscribeCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Unsubscribe failed.", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException ex = new SCServiceException("Unsubscribe failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
    } finally {
      // 4. post process, reply to client
      this.sessionId = null;
View Full Code Here

   * @throws SCMPValidatorException
   *             service name not set<br />
   */
  public SCPublishServer newPublishServer(String serviceName) throws SCServiceException, SCMPValidatorException {
    if (this.listening == false) {
      throw new SCServiceException("newPublishServer not possible - server not listening.");
    }
    if (serviceName == null) {
      throw new SCMPValidatorException("service name must be set");
    }
    return new SCPublishServer(this, serviceName, requester);
View Full Code Here

   *             called method after subscribe
   */
  public void setReceivePublicationTimeoutSeconds(int receivePublicationTimeoutSeconds) throws SCMPValidatorException,
      SCServiceException {
    if (this.sessionActive) {
      throw new SCServiceException("Can not set receivePublicationTimeoutSeconds, subscription is already subscribed.");
    }
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, receivePublicationTimeoutSeconds, Constants.MAX_RECEIVE_PUBLICAION_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_RECEIVE_PUBLICAION_TIMEOUT);
    this.receivePublicationTimeoutSeconds = receivePublicationTimeoutSeconds;
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.