Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCServiceException


      registerServerCall.setUrlPath(this.urlPath);
      SCServerCallback callback = new SCServerCallback(true);
      try {
        registerServerCall.invoke(callback, Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Register server failed. ", e);
      }
      SCMPMessage reply = callback.getMessageSync(Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS
          * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException ex = new SCServiceException("Register server failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
      AppContext.attachedCommunicators.incrementAndGet();
    }
    // set up server timeout thread
View Full Code Here


        SCServerCallback callback = new SCServerCallback(true);
        try {
          deRegisterServerCall.invoke(callback, Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS
              * Constants.SEC_TO_MILLISEC_FACTOR);
        } catch (Exception e) {
          throw new SCServiceException("Deregister server failed. ", e);
        }
        SCMPMessage reply = callback.getMessageSync(Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS
            * Constants.SEC_TO_MILLISEC_FACTOR);
        if (reply.isFault()) {
          SCServiceException ex = new SCServiceException("Deregister server failed.");
          ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
          ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
          throw ex;
        }
      } finally {
        this.registered = false;
        AppContext.attachedCommunicators.decrementAndGet();
View Full Code Here

   *             check registration failed<br />
   *             error message received from SC <br />
   */
  public synchronized void checkRegistration(int operationTimeoutSeconds) throws SCServiceException {
    if (this.registered == false) {
      throw new SCServiceException("Server is not registered for a service.");
    }
    // cancel server timeout not if its running already, you might interrupt current thread
    this.cancelServerTimeout(false);
    SCMPCheckRegistrationCall checkRegistrationCall = new SCMPCheckRegistrationCall(this.requester, this.serviceName);
    SCServerCallback callback = new SCServerCallback(true);
    try {
      checkRegistrationCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      throw new SCServiceException("Check registration failed. ", e);
    }
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Check registration failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    // set up server timeout thread
    this.triggerServerTimeout();
  }
View Full Code Here

   *             error message received from SC <br />
   */
  public synchronized void attach(int operationTimeoutSeconds) throws SCServiceException, SCMPValidatorException {
    // 1. checking preconditions and validate
    if (this.attached) {
      throw new SCServiceException("SCClient already attached.");
    }
    if (host == null) {
      throw new SCMPValidatorException("Host is missing.");
    }
    ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, this.port, Constants.MAX_PORT_VALUE, SCMPError.HV_WRONG_PORTNR);
    // 2. initialize call & invoke
    synchronized (AppContext.communicatorsLock) {
      AppContext.init();
      RemoteNodeConfiguration remoteNodeConf = new RemoteNodeConfiguration(this.port + "client", this.host, this.port,
          this.connectionType.getValue(), this.keepAliveIntervalSeconds, 0, this.maxConnections);
      this.requester = new SCRequester(remoteNodeConf, this.keepAliveTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      SCServiceCallback callback = new SCServiceCallback(true);
      SCMPAttachCall attachCall = new SCMPAttachCall(this.requester);
      try {
        attachCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        this.requester.destroy();
        // release resources
        AppContext.destroy();
        throw new SCServiceException("Attach to " + host + ":" + port + " failed. ", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        this.requester.destroy();
        // release resources
        AppContext.destroy();
        SCServiceException ex = new SCServiceException("Attach to " + host + ":" + port + " failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
      // 4. post process, reply to client
      this.attached = true;
      AppContext.attachedCommunicators.incrementAndGet();
View Full Code Here

      SCServiceCallback callback = new SCServiceCallback(true);
      SCMPDetachCall detachCall = new SCMPDetachCall(this.requester);
      try {
        detachCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Detach client 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("Detach client 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.attached = false;
View Full Code Here

   *             called method after attach
   * @return the file service
   */
  public SCFileService newFileService(String serviceName) throws SCServiceException, SCMPValidatorException {
    if (this.attached == false) {
      throw new SCServiceException("Creating a new file service not possible - client not attached.");
    }
    if (serviceName == null) {
      throw new SCMPValidatorException("Service name must be set.");
    }
    ValidatorUtility
View Full Code Here

   *             called method after attach
   * @return the session service
   */
  public SCSessionService newSessionService(String serviceName) throws SCServiceException, SCMPValidatorException {
    if (this.attached == false) {
      throw new SCServiceException("Creating a new session service not possible - client not attached.");
    }
    if (serviceName == null) {
      throw new SCMPValidatorException("Service name must be set.");
    }
    ValidatorUtility
View Full Code Here

   *             called method after attach
   * @return the publish service
   */
  public synchronized SCPublishService newPublishService(String serviceName) throws SCServiceException, SCMPValidatorException {
    if (this.attached == false) {
      throw new SCServiceException("Creating a new publish service not possible - client not attached.");
    }
    if (serviceName == null) {
      throw new SCMPValidatorException("Service name must be set.");
    }
    ValidatorUtility
View Full Code Here

   */
  public synchronized void startCacheGuardian(int operationTimeoutSeconds, String guardianName,
      SCSubscribeMessage subscribeMessage, SCGuardianMessageCallback guardianCallback) throws SCServiceException,
      SCMPValidatorException {
    if (this.attached == false) {
      throw new SCServiceException("Starting a Cache Guardian not possible - client not attached.");
    }

    if (this.cacheGuardian != null && this.cacheGuardian.isActive() == true) {
      throw new SCServiceException("Cache Guardian already started.");
    }
    if (guardianName == null) {
      throw new SCMPValidatorException("Cache Guardian name must be set.");
    }
    ValidatorUtility.validateStringLengthTrim(1, guardianName, Constants.MAX_LENGTH_SERVICENAME,
View Full Code Here

   *             stop cache guardian failed<br />
   *             error message received from SC <br />
   */
  public synchronized void stopCacheGuardian(int operationTimeoutSeconds) throws SCServiceException {
    if (this.attached == false) {
      throw new SCServiceException("Stopping an Cache Guardian not possible - client not attached.");
    }
    if (this.cacheGuardian != null && this.cacheGuardian.isActive() == false) {
      // no active guardian to stop, ignore
      return;
    }
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.