Class SCSessionService

java.lang.Object
org.serviceconnector.api.cln.SCService
org.serviceconnector.api.cln.SCSessionService

public class SCSessionService extends SCService
The Class SessionService. SessionService is a remote interface in client API to a session service and provides communication functions. Creating a session service instance for API users should be done by calling SCClient newSessionService().

State Diagram

        ||                                                            |-------execute-------|
        \/                                                            |                     |
    |---------|              |----------|                      |--------------|             |
    | initial |----attach--->| attached |----create session--->| has session  |--echo--|    |
    |         |<---detach----|          |<---delete session----| with service |<-------|    |
    |---------|              |----------|                      |--------------|<------------|
        ||
        \/
 
After creating a session a delete session must be done in every case at the end of communication. A delete session may be called multiple times. Nothing happens if the session turns inactive in meantime.
Author:
JTraber
  • Method Details

    • createSession

      public SCMessage createSession(SCMessage scMessage, SCMessageCallback callback) throws SCServiceException, SCMPValidatorException
      Creates the session on SC. Uses default operation timeout to complete operation.
      Once a create session has been called a delete session must be done at the end of communication.
      Parameters:
      scMessage - the SC message
      callback - the message callback which is used to inform the client in case of asynchronous operations
      Returns:
      the SC message
      Throws:
      SCServiceException - session already created
      create session on SC failed
      error message received from SC
      create session has been rejected by the server
      SCMPValidatorException - create session message is null
      message callback is null
    • createSession

      public SCMessage createSession(int operationTimeoutSeconds, SCMessage scMessage, SCMessageCallback messageCallback) throws SCServiceException, SCMPValidatorException
      Creates the session on SC.
      Once a create session has been called a delete session must be done at the end of communication.
      Parameters:
      operationTimeoutSeconds - the allowed time in seconds to complete the operation
      scMessage - the SC message
      messageCallback - the message callback which is used to inform the client in case of asynchronous operations
      Returns:
      the SC message
      Throws:
      SCServiceException - session already created
      create session on SC failed
      error message received from SC
      create session has been rejected by the server
      SCMPValidatorException - create session message is null
      message callback is null
    • execute

      public SCMessage execute(SCMessage requestMsg) throws SCServiceException, SCMPValidatorException
      Execute with default operation timeout. Execute is a synchronous operation with the SC. Any reply will be received as return of the method.
      Parameters:
      requestMsg - the request message
      Returns:
      the SC message
      Throws:
      SCServiceException - session not active (not created yet or dead)
      pending request, no second request allowed
      execute on SC failed
      error message received from SC
      SCMPValidatorException - execute message is null
    • execute

      public SCMessage execute(int operationTimeoutSeconds, SCMessage scMessage) throws SCServiceException, SCMPValidatorException
      Execute. Execute is a synchronous operation with the SC. Any reply will be received as return of the method.
      Parameters:
      operationTimeoutSeconds - the allowed time in seconds to complete the operation
      scMessage - the SC message to execute
      Returns:
      the reply
      Throws:
      SCServiceException - session not active (not created yet or dead)
      pending request, no second request allowed
      execute on SC failed
      error message received from SC
      SCMPValidatorException - execute message is null
    • send

      public void send(SCMessage requestMsg) throws SCServiceException, SCMPValidatorException
      Send with default operation timeout. Send is an asynchronous operation with the SC. Any reply will be informed over the callback.
      Parameters:
      requestMsg - the request message
      Throws:
      SCServiceException - session not active (not created yet or dead)
      pending request, no second request allowed
      send on SC failed
      SCMPValidatorException - send message is null
    • send

      public void send(int operationtTimeoutSeconds, SCMessage scMessage) throws SCServiceException, SCMPValidatorException
      Send. Asynchronous operation. Send is an asynchronous operation with the SC. Any reply will be informed over the callback.
      Parameters:
      operationtTimeoutSeconds - the allowed time in seconds to complete the operation
      scMessage - the SC message
      Throws:
      SCServiceException - session not active (not created yet or dead)
      pending request, no second request allowed
      send on SC failed
      SCMPValidatorException - send message is null
    • deleteSession

      public void deleteSession() throws SCServiceException
      Delete session on SC with default operation timeout. A delete session may be called multiple times. Nothing happens if the session turns inactive in meantime.
      Throws:
      SCServiceException - pending request, no second request allowed
      delete session on SC failed
      error message received from SC
    • deleteSession

      public void deleteSession(int operationTimeoutSeconds) throws SCServiceException
      Delete session on SC. A delete session may be called multiple times. Nothing happens if the session turns inactive in meantime.
      Parameters:
      operationTimeoutSeconds - allowed time to complete operation
      Throws:
      SCServiceException - pending request, no second request allowed
      delete session on SC failed
      error message received from SC
    • deleteSession

      public void deleteSession(SCMessage scMessage) throws SCServiceException
      Delete session on SC with default operation timeout. A delete session may be called multiple times. Nothing happens if the session turns inactive in meantime.
      Parameters:
      scMessage - the SC message
      Throws:
      SCServiceException - pending request, no second request allowed
      delete session on SC failed
      error message received from SC
    • deleteSession

      public void deleteSession(int operationTimeoutSeconds, SCMessage scMessage) throws SCServiceException
      Delete session on SC. A delete session may be called multiple times. Nothing happens if the session turns inactive in meantime.
      Parameters:
      operationTimeoutSeconds - the allowed time in seconds to complete the operation
      scMessage - the SC message
      Throws:
      SCServiceException - pending request, no second request allowed
      delete session on SC failed
      error message received from SC
    • setEchoTimeoutSeconds

      public void setEchoTimeoutSeconds(int echoTimeoutSeconds) throws SCMPValidatorException
      Sets the echo timeout in seconds. Time in seconds the an echo request waits to be confirmed. If no confirmation is received session is marked as dead.
      Parameters:
      echoTimeoutSeconds - time to wait for completion of an echo request Example: 10
      Throws:
      SCMPValidatorException - echoTimeoutSeconds > 1 and < 3600
    • getEchoTimeoutSeconds

      public int getEchoTimeoutSeconds()
      Gets the echo timeout in seconds. Time in seconds the an echo request waits to be confirmed.
      Returns:
      the echo timeout in seconds
    • setEchoIntervalSeconds

      public void setEchoIntervalSeconds(int echoIntervalSeconds)
      Sets the echo interval in seconds. Interval in seconds between two subsequent ECHO messages sent by the client to SC. The message is sent only when no message is pending.
      Parameters:
      echoIntervalSeconds - Validation: echoIntervalSeconds > 1 and < 3600
      Example: 360
    • getEchoIntervalSeconds

      public int getEchoIntervalSeconds()
      Gets the echo interval in seconds.
      Returns:
      the echo interval in seconds
    • hasSession

      public boolean hasSession()
      Checks if has a session.
      Returns:
      true, if is subscribed