context.arch.comm.language
Interface MessageHandler

All Known Implementing Classes:
BaseObject

public interface MessageHandler

This interface specifies all the methods for encoding outgoing messages and decoding incoming messages, as well as the method that handles decoded incoming messages.


Method Summary
 DataObject decodeData(java.io.Reader message)
          Method to decode the incoming data
 java.lang.String encodeData(DataObject data)
          Method to encode the incoming data
 void handleIndependentReply(IndependentCommunication independentCommunication)
          This method is called after the independentUserRequest has been called.
 DataObject runMethod(java.lang.String methodType, DataObject data)
          This method handles both the system-defined, callbacks and user-defined RPCs.
 

Method Detail

decodeData

public DataObject decodeData(java.io.Reader message)
                      throws DecodeException,
                             InvalidDecoderException
Method to decode the incoming data

Parameters:
message - Message to be decoded
Returns:
the decoded message in a DataObject
Throws:
DecodeException - thrown when the given data can not be decoded successfully
InvalidDecoderException - thrown when the decoder can not be run successfully

encodeData

public java.lang.String encodeData(DataObject data)
                            throws EncodeException,
                                   InvalidEncoderException
Method to encode the incoming data

Parameters:
data - Data to be encoded
Returns:
the encoded message
Throws:
EncodeException - thrown when the given data can not be encoded successfully
InvalidEncoderException - thrown when the encoder can not be run successfully

runMethod

public DataObject runMethod(java.lang.String methodType,
                            DataObject data)
                     throws InvalidMethodException,
                            MethodException
This method handles both the system-defined, callbacks and user-defined RPCs.

Parameters:
methodType - Name of method to run
data - DataObject containing data for the method call
Throws:
InvalidMethodException - thrown if specified RPC couldn't be found
MethodException - thrown if specified RPC had an error

handleIndependentReply

public void handleIndependentReply(IndependentCommunication independentCommunication)
This method is called after the independentUserRequest has been called. The thread in charge of the communication sends the results to this method. This method should be overridden by classes that need to handle the responses.

See Also:
ClientsPool, Client, context.arch.util.RequestObject, DataObject