Class DefaultReqRespManager

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  DefaultReqRespManager.RequestEntry
      A request entry is used the the request map after a send message call i waiting for a response, contains a response PKI Message data.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultReqRespManager​(long timeOut, MessageHandler messageHandler, java.lang.String messageSenderName, java.lang.String messageListenerName)
      Default constructor of a DefaultReqRespManager
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void cancelWaitForResponse​(java.lang.String requestId)
      Method signaling that the waiting thread have stopped listening for a response to this request.
      protected CSMessage checkIfResponseIsReady​(java.lang.String requestId)
      Method to check if a response have been sent to a request with the given id.
      protected java.lang.String findRequestId​(CSMessage responseMessage)
      Method that extracts the requestId from the responseMessage.
      protected CSResponse findResponsePayload​(CSMessage responseMessage)  
      protected boolean populateResponseMapIfStillExist​(java.lang.String requestId, CSMessage responseMessage)
      Method that is called by the responseRecieved method that it received a message to this listener and should populate the response map.
      protected void registerWaitForRequestId​(java.lang.String requestId)
      Signals that the current manager is listening for this message.
      void responseReceived​(byte[] requestData, CSMessage responseMessage, java.util.Map<java.lang.String,​java.lang.String> messageAttributes)
      Method signaling that a response was received.
      CSMessage sendRequest​(java.lang.String requestId, byte[] request)
      Main method signaling sending a request with given id and waits for a response for a given time before a time-out IO exception is thrown.
      CSMessage sendRequest​(java.lang.String requestId, byte[] request, java.util.Map<java.lang.String,​java.lang.String> requestAttributes)
      Main method signaling sending a request with given id and waits for a response for a given time before a time-out IO exception is thrown.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • timeOut

        protected long timeOut
      • messageListenerName

        protected java.lang.String messageListenerName
      • messageSenderName

        protected java.lang.String messageSenderName
      • SLEEP_INTERVAL_MILLIS

        protected static long SLEEP_INTERVAL_MILLIS
    • Constructor Detail

      • DefaultReqRespManager

        public DefaultReqRespManager​(long timeOut,
                                     MessageHandler messageHandler,
                                     java.lang.String messageSenderName,
                                     java.lang.String messageListenerName)
                              throws MessageProcessingException
        Default constructor of a DefaultReqRespManager
        Parameters:
        timeOut - time in milliseconds to wait for response.
        messageHandler - , the related message handler.
        messageListenerName - the name of the message listener to use, never null and must be registered in the message handler.
        messageSenderName - the name of the message sender to use, never null and must be registered in the message handler.
        Throws:
        MessageProcessingException - if internal problems occurred setting up the request response manager.
    • Method Detail

      • responseReceived

        public void responseReceived​(byte[] requestData,
                                     CSMessage responseMessage,
                                     java.util.Map<java.lang.String,​java.lang.String> messageAttributes)
        Description copied from interface: MessageResponseCallback
        Method signaling that a response was received.

        Important only messages with a destination matching this source id should be sent through this callback.

        Specified by:
        responseReceived in interface MessageResponseCallback
        Parameters:
        requestData - the original request data
        responseMessage - the response message that was received.
        messageAttributes - meta data related to the message such as reply-to queues or correlation id etc if underlying implementation supports it.
        See Also:
        MessageResponseCallback.responseReceived(byte[], CSMessage, Map)
      • registerWaitForRequestId

        protected void registerWaitForRequestId​(java.lang.String requestId)
        Signals that the current manager is listening for this message.
        Parameters:
        requestId - the id of the message to register
      • checkIfResponseIsReady

        protected CSMessage checkIfResponseIsReady​(java.lang.String requestId)
        Method to check if a response have been sent to a request with the given id.
        Parameters:
        requestId - the id to check for
        Returns:
        the PKIMessage response or null if no response have been recieved yet.
      • cancelWaitForResponse

        protected void cancelWaitForResponse​(java.lang.String requestId)
        Method signaling that the waiting thread have stopped listening for a response to this request.
      • populateResponseMapIfStillExist

        protected boolean populateResponseMapIfStillExist​(java.lang.String requestId,
                                                          CSMessage responseMessage)
        Method that is called by the responseRecieved method that it received a message to this listener and should populate the response map.
      • findRequestId

        protected java.lang.String findRequestId​(CSMessage responseMessage)
        Method that extracts the requestId from the responseMessage. Where IssueTokenCredentialsResponse and GetCredentialResponse and FailureResponse is supported.
        Parameters:
        responseMessage - the message to parse request id from
        Returns:
        the request id or null if no valid request id was found in the response
      • findResponsePayload

        protected CSResponse findResponsePayload​(CSMessage responseMessage)