context.arch.comm
Interface CommunicationsClient

All Known Implementing Classes:
HTTPClientSocket

public interface CommunicationsClient

This interface specifies all the methods a CommunicationsClient object must support allowing the details of the specific protocol used to be abstracted away.

See Also:
CommunicationsObject

Method Summary
 java.lang.String addRequestProtocol(java.lang.String data, java.lang.String listener)
          This abstract method adds the protocol to a request to be sent
 java.lang.String addRequestProtocol(java.lang.String data, java.lang.String listener, java.lang.String type)
          This abstract method adds the protocol to a request to be sent
 DataObject getErrorMessage()
          This abstract method generates an error message if a request can't be handled properly, to the point where a contextual error message can still be sent as the reply
 java.lang.String getFatalMessage()
          This abstract method generates an fatal message if a request can't be handled properly, to the point where no contextual error message can be sent as the reply
 java.lang.String getProtocol()
          Abstract method to get the communications protocol being used
 java.net.Socket sendRequest(java.lang.String request)
          This abstract method sends a request
 RequestData stripReplyProtocol(java.net.Socket socket)
          This abstract method strips the protocol away from the received reply
 

Method Detail

getProtocol

public java.lang.String getProtocol()
Abstract method to get the communications protocol being used
Returns:
the protocol being used

stripReplyProtocol

public RequestData stripReplyProtocol(java.net.Socket socket)
                               throws ProtocolException
This abstract method strips the protocol away from the received reply
Parameters:
socket - The socket the reply is being received on
Returns:
the reply with the protocol stripped away in the form of a RequestData object
Throws:
ProtocolException - thrown if protocol can't be stripped away
See Also:
addRequestProtocol(String,String), CommunicationsServer.stripRequestProtocol(Socket), CommunicationsServer.addReplyProtocol(String)

addRequestProtocol

public java.lang.String addRequestProtocol(java.lang.String data,
                                           java.lang.String listener)
                                    throws ProtocolException
This abstract method adds the protocol to a request to be sent
Parameters:
data - The request to add the protocol to
listener - The recipient of the request (eg, an URL in HTTP). May be null.
Returns:
the request with the protocol added
Throws:
ProtocolException - thrown if protocol can't be added
See Also:
stripReplyProtocol(Socket), CommunicationsServer.stripRequestProtocol(Socket), CommunicationsServer.addReplyProtocol(String)

addRequestProtocol

public java.lang.String addRequestProtocol(java.lang.String data,
                                           java.lang.String listener,
                                           java.lang.String type)
                                    throws ProtocolException
This abstract method adds the protocol to a request to be sent
Parameters:
data - The request to add the protocol to
listener - The recipient of the request (eg, an URL in HTTP). May be null.
type - The type of the request: GET or POST.
Returns:
the request with the protocol added
Throws:
ProtocolException - thrown if protocol can't be added
See Also:
stripReplyProtocol(Socket), CommunicationsServer.stripRequestProtocol(Socket), CommunicationsServer.addReplyProtocol(String)

sendRequest

public java.net.Socket sendRequest(java.lang.String request)
This abstract method sends a request
Parameters:
request - The request to send
Returns:
the reply to the request

getErrorMessage

public DataObject getErrorMessage()
This abstract method generates an error message if a request can't be handled properly, to the point where a contextual error message can still be sent as the reply
Parameters:
DataObject - containing the error message
See Also:
getFatalMessage()

getFatalMessage

public java.lang.String getFatalMessage()
This abstract method generates an fatal message if a request can't be handled properly, to the point where no contextual error message can be sent as the reply
Parameters:
String - containing the fatal message
See Also:
getErrorMessage()