context.arch.comm
Interface CommunicationsHandler

All Known Implementing Classes:
BaseObject

public interface CommunicationsHandler

This interface specifies all the basic methods to allow communications with other components. Currently, this means calling userRequest, executeAsynchronousWidgetService and executeSynchronousWidgetService.


Method Summary
 DataObject executeAsynchronousWidgetService(AsyncServiceHandler handler, java.lang.String serviceHost, int servicePort, java.lang.String serviceId, java.lang.String service, java.lang.String function, Attributes input, java.lang.String requestTag)
          This method requests that a widget execute an asynchronous service
 DataObject executeSynchronousWidgetService(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String service, java.lang.String function, Attributes input)
          This method requests that a widget execute a synchronous service
 void independentUserRequest(IndependentCommunication request)
          This method is used to send a message through a threaded communication.
 DataObject userRequest(DataObject data, java.lang.String url)
          Deprecated.  
 DataObject userRequest(DataObject data, java.lang.String url, java.lang.String server)
          Method that allows a component to communicate with another component.
 DataObject userRequest(DataObject data, java.lang.String url, java.lang.String server, int port)
          Method that allows a component to communicate with another component.
 DataObject userRequest(RequestObject request)
          Method that allows a component to communicate with another component.
 

Method Detail

userRequest

public DataObject userRequest(RequestObject request)
                       throws EncodeException,
                              InvalidProtocolException,
                              ProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException,
                              java.io.IOException
Method that allows a component to communicate with another component.

Parameters:
request - The RequestObject containing the data to send, the url name and the destination server hostname and port.
Returns:
DataObject containing the reply to the request
Throws:
EncodeException - when the encoding can't be completed successfully
DecodeException - when the decoding can't be completed successfully
InvalidEncoderException - when the encoder can't be created
InvalidDecoderException - when the decoder can't be created
ProtocolException - when the request can't be sent successfully
InvalidProtocolException - when the request can't be sent successfully due to invalid protocol use
java.io.IOException

userRequest

public DataObject userRequest(DataObject data,
                              java.lang.String url)
                       throws EncodeException,
                              InvalidProtocolException,
                              ProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException,
                              java.io.IOException
Deprecated.  

Method that allows a component to communicate with another component.

Parameters:
data - DataObject that contains the request
url - RPC tag that indicates the type of request
Returns:
DataObject containing the reply to the request
Throws:
EncodeException - when the encoding can't be completed successfully
DecodeException - when the decoding can't be completed successfully
InvalidEncoderException - when the encoder can't be created
InvalidDecoderException - when the decoder can't be created
ProtocolException - when the request can't be sent successfully
InvalidProtocolException - when the request can't be sent successfully due to invalid protocol use
java.io.IOException

userRequest

public DataObject userRequest(DataObject data,
                              java.lang.String url,
                              java.lang.String server)
                       throws EncodeException,
                              InvalidProtocolException,
                              ProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException,
                              java.io.IOException
Method that allows a component to communicate with another component.

Parameters:
data - DataObject that contains the request
url - RPC tag that indicates the type of request
server - Hostname of the component to communicate with
Returns:
DataObject containing the reply to the request
Throws:
EncodeException - when the encoding can't be completed successfully
DecodeException - when the decoding can't be completed successfully
InvalidEncoderException - when the encoder can't be created
InvalidDecoderException - when the decoder can't be created
ProtocolException - when the request can't be sent successfully
InvalidProtocolException - when the request can't be sent successfully due to invalid protocol use
java.io.IOException

userRequest

public DataObject userRequest(DataObject data,
                              java.lang.String url,
                              java.lang.String server,
                              int port)
                       throws EncodeException,
                              ProtocolException,
                              InvalidProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException,
                              java.io.IOException
Method that allows a component to communicate with another component.

Parameters:
data - DataObject that contains the request
url - RPC tag that indicates the type of request
server - Hostname of the component to communicate with
port - Port number of the component to communicate with
Returns:
DataObject containing the reply to the request
Throws:
EncodeException - when the encoding can't be completed successfully
DecodeException - when the decoding can't be completed successfully
InvalidEncoderException - when the encoder can't be created
InvalidDecoderException - when the decoder can't be created
ProtocolException - when the request can't be sent successfully
InvalidProtocolException - when the request can't be sent successfully due to invalid protocol use
java.io.IOException

executeAsynchronousWidgetService

public DataObject executeAsynchronousWidgetService(AsyncServiceHandler handler,
                                                   java.lang.String serviceHost,
                                                   int servicePort,
                                                   java.lang.String serviceId,
                                                   java.lang.String service,
                                                   java.lang.String function,
                                                   Attributes input,
                                                   java.lang.String requestTag)
This method requests that a widget execute an asynchronous service

Parameters:
handler - Handler to handle the results of the service
serviceHost - Hostname of the widget with the service
servicePort - Port number of the widget with the service
serviceId - Id of the widget with the service
service - Name of the widget service to run
function - Name of the particular service function to run
input - AttributeNameValues object to use to execute the service
requestTag - Unique tag provided by caller to identify result
Returns:
DataObject containing the results of the execution request

executeSynchronousWidgetService

public DataObject executeSynchronousWidgetService(java.lang.String remoteHost,
                                                  int remotePort,
                                                  java.lang.String remoteId,
                                                  java.lang.String service,
                                                  java.lang.String function,
                                                  Attributes input)
This method requests that a widget execute a synchronous service

Parameters:
remoteHost - Hostname of the widget
remotePort - Port number of the widget
remoteId - Id of the widget
service - Name of the widget service to run
function - Name of the particular service function to run
input - AttributeNameValues object to use to execute the service
Returns:
DataObject containing the results of the execution request

independentUserRequest

public void independentUserRequest(IndependentCommunication request)
                            throws EncodeException,
                                   InvalidEncoderException
This method is used to send a message through a threaded communication. The request is sent by a thread in charge of the communication. The request is encapsulated in a IndependentCommunication that contains a RequestObject (data to send and the recipient of the data) and the reply message and the exceptions that occured during the communication. If the communication result is null, the baseObject won't be notified about how the communication ended. Actually, the thread in charge of the communication won't notify the baseObject, but update the request object. If the result is not null, result is the IndependentCommunications object that will contain the oriinal request and the reply. At the end of the communication, the thread updates request with the reply message and the exception, and add it into result. The base object is notified of the end of the threaded communication when the handleIndependentReply is called by the thread.

Parameters:
request - The IndependentCommunication object that contain the RequestObject, and will contain after the communication the reply dataObject and the vector of exception
Throws:
EncodeException
InvalidEncoderException
See Also:
BaseObject.handleIndependentReply(context.arch.comm.clients.IndependentCommunication), IndependentCommunication, context.arch.comm.clients.IndependentCommunications, context.arch.util.RequesObject