context.arch.comm
Interface CommunicationsServer

All Known Implementing Classes:
HTTPServerSocket

public interface CommunicationsServer

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

See Also:
CommunicationsObject

Method Summary
 java.lang.String addReplyProtocol(java.lang.String reply)
          This abstract method strips the protocol away from the received request
 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
 void handleIncomingRequest(java.net.Socket socket)
          This abstract method handles incoming requests on a given socket
 void quit()
          Abstract method to call when stopping a CommunicationsServer object
 void start()
          Abstract method to call when starting a CommunicationsServer object
 RequestData stripRequestProtocol(java.net.Socket socket)
          This abstract method strips the protocol away from the received request
 

Method Detail

start

public void start()
Abstract method to call when starting a CommunicationsServer object

quit

public void quit()
Abstract method to call when stopping a CommunicationsServer object

getProtocol

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

stripRequestProtocol

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

addReplyProtocol

public java.lang.String addReplyProtocol(java.lang.String reply)
                                  throws ProtocolException
This abstract method strips the protocol away from the received request
Parameters:
reply - The reply to add the protocol to
Returns:
the reply with the protocol added
Throws:
ProtocolException - thrown if protocol can't be added
See Also:
stripRequestProtocol(java.net.Socket), CommunicationsClient.addRequestProtocol(String,String), CommunicationsClient.stripReplyProtocol(java.net.Socket)

handleIncomingRequest

public void handleIncomingRequest(java.net.Socket socket)
This abstract method handles incoming requests on a given socket
Parameters:
socket - The socket requests are coming in on

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
Returns:
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
Returns:
String containing the fatal message
See Also:
getErrorMessage()