context.arch
Class BaseObject

java.lang.Object
  |
  +--context.arch.BaseObject
Direct Known Subclasses:
InOutBoardServer, Interpreter, Widget

public class BaseObject
extends java.lang.Object
implements MessageHandler, CommunicationsHandler

This class is the base object for the context-aware infrastructure. It is able to poll and subscribe to other components and can be polled and subscribed to by other components. It also can generate and handle RPC-style requests. It consists of 2 main objects, the CommunicationsObject and ParserObject. It also maintains a list of subscribers and a list of handlers.

See Also:
CommunicationsObject, ParserObject, Handler

Field Summary
 CommunicationsObject communications
          Object to handle communications between components
static int EXIT_OK
          Indicates that the exit condition is normal
 Handlers handlers
          Object to keep track of context widget handlers
static java.lang.String ID
          Tag for id of this component
 ParserObject parser
          Object to handle the encoding and decoding of communications
static java.lang.String PING
          Tag for a ping
static java.lang.String PING_REPLY
          Tag for a ping reply
 AsyncServiceHandlers serviceHandlers
          Object to keep track of asynchronous service handlers
 
Constructor Summary
BaseObject()
          Basic constructor that creates a CommunicationsObject, ParserObject and Handlers object.
BaseObject(int port)
          Constructor that just creates a CommunicationsObject with the given port and ParserObject.
BaseObject(int port, java.lang.String protocol)
          Constructor that just creates a CommunicationsObject with the given port and protocol handler class, and ParserObject.
BaseObject(java.lang.String protocol)
          Constructor that just creates a CommunicationsObject with the given protocol handler class, and a ParserObject.
BaseObject(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass)
          Basic constructor that creates a CommunicationsObject with the given port and protocol, and creates a ParserObject with the given encoder and decoder.
 
Method Summary
 DataObject askInterpreter(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, AttributeNameValues data)
          This method asks an interpreter to interpret some data.
 DataObject decodeData(java.io.Reader commData)
          Stub method that decodes the given string using ParserObject
 java.lang.String encodeData(DataObject commData)
          Stub method that encodes the given string using ParserObject
 DataObject executeAsynchronousWidgetService(AsyncServiceHandler handler, java.lang.String serviceHost, int servicePort, java.lang.String serviceId, java.lang.String service, java.lang.String function, AttributeNameValues input, java.lang.String requestTag)
          This method requests that a widget execute an asynchronous service
 DataObject executeSynchronousWidgetService(java.l ang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String service, java.lang.String function, AttributeNameValues input)
          This method requests that a widget execute a synchronous service
 java.lang.String getHostAddress()
          This method gets the address of the machine this component is running on.
 java.lang.String getId()
          This method returns the id of the class that subclass this object, for use in sending messages.
 java.lang.String getVersion()
          This method returns the version number of this object.
 DataObject getVersion(java.lang.String remoteHost, int remotePort, java.lang.String remoteId)
          This method gets the version of the given component (server, widget, interpreter).
 DataObject getWidgetAttributes(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId)
          This method gets the attributes of the given widget
 DataObject getWidgetCallbacks(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId)
          This method gets the callbacks of the given widget
 DataObject getWidgetServices(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId)
          This method gets the services of the given widget
static void main(java.lang.String[] argv)
          Temporary main method to test the BaseObject class
 DataObject pingComponent(java.lang.String remoteHost, int remotePort, java.lang.String remoteId)
          This method pings a component (widget,server, or interpreter) to make sure that it is functioning ok.
 DataObject pollWidget(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId, Attributes attributes)
          This method allows a component to poll a remote widget for its attribute values.
 DataObject putDataInWidget(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId, java.lang.String callback, AttributeNameValues attributes)
          This method allows a component to put context data in a remote widget.
 DataObject queryVersion(DataObject query)
          This method returns the version number of this component.
 void quit()
          This method should be called when the object is going to exit under normal conditions.
 DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId)
          This method returns a vector containing AttributeNameValues objects for all the the data.
 DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, AttributeFunctions attributes)
          This method returns a vector containing AttributeNameValues objects for all the the data of the given attributes.
 DataObject retrieveDataFrom(java.lang.String remoteHost , int remotePort, java.lang.String remoteId, AttributeFunctions attributes, java.lang.String attribute, int compare, java.lang.Object value)
          This method returns a vector containing AttributeNameValues objects for all the the data of the given attributes and a single condition.
 DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, Retrieval retrieval)
          This method allows a component to retrieve data from other components.
 DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String attribute)
          This method returns a vector containing AttributeNameValues objects for all the the data of a given attribute.
 DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String attribute, int compare, java.lang.Object value)
          This method returns a vector containing AttributeNameValues objects for all the the data and a single condition.
 DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String myId, Retrieval retrieval)
          This method allows a component to retrieve data from other components.
 DataObject returnPing(DataObject ping)
          This method returns an error message as an answer to a ping.
 DataObject runComponentMethod(java.lang.String& nbsp;remoteHost, int remotePort, java.lang.String remoteId, java.lang.String methodName, AttributeNameValues parameters, Attributes attributes)
          This method asks an component to run some non-standard method.
 DataObject runMethod(java.lang.String methodType, DataObject data)
          This method handles both the system-defined, callbacks and user-defined RPCs.
 DataObject runUserMethod(DataObject data)
          This is an empty method that should be overridden by the object that extends this class.
 DataObject serviceResult(DataObject result)
          This method handles the results of an asynchronous service request.
 void setId(java.lang.String id)
          This method sets the id of classes that subclass this object, for use in sending messages.
 void setVersion(java.lang.String version)
          This method sets the version number of this object.
 Error subscribeTo(Handler handler, int port, java.lang.String subid, java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String callback, java.lang.String tag
          This method allows a component to subscribe to changes in other components.
 Error subscribeTo(Handler handler, int port, java.lang.String subid, java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String callback, java.lang.String tag, Attributes attributes)
          This method allows a component to subscribe to changes in other components.
 Error subscribeTo(Handler handler, int port, java.lang.String subid, java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String callback, java.lang.String tag, Conditions conditions)
          This method allows a component to subscribe to changes in other components.
 Error subscribeTo(Handler handler, int port, java.lang.String subid, java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String callback, java.lang.String tag, Conditions conditions, Attributes attributes)
          This method allows a component to subscribe to changes in other components.
 Error unsubscribeFrom( Handler handler, java.lang.String remoteHost, int remotePort, java.lang.String remoteId, Subscriber subscriber)
          This method allows a component to unsubscribe from another component.
 DataObject updateAndPollWidget(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId, Attributes attributes)
          This method allows a component to force a remote widget to update its data and return it.
 DataObject userCallback(DataObject data)
          This method is called when a callback message is received.
 DataObject userRequest(DataObject data, java.lang.String tag)
          Method that submits a user request for polling/subscription.
 DataObject userRequest(DataObject data, java.lang.String tag, java.lang.String server)
          Method that submits a user request for polling/subscription.
 DataObject userRequest(DataObject data, java.lang.String tag, java.lang.String server, int port)
          Method that submits a user request for polling/subscription.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXIT_OK

public static final int EXIT_OK
Indicates that the exit condition is normal

ID

public static final java.lang.String ID
Tag for id of this component

PING

public static final java.lang.String PING
Tag for a ping

PING_REPLY

public static final java.lang.String PING_REPLY
Tag for a ping reply

communications

public CommunicationsObject communications
Object to handle communications between components
See Also:
CommunicationsObject

parser

public ParserObject parser
Object to handle the encoding and decoding of communications
See Also:
ParserObject

handlers

public Handlers handlers
Object to keep track of context widget handlers
See Also:
Handlers, Handler

serviceHandlers

public AsyncServiceHandlers serviceHandlers
Object to keep track of asynchronous service handlers
See Also:
AsyncServiceHandlers, AsyncServiceHandler
Constructor Detail

BaseObject

public BaseObject(java.lang.String clientClass,
                  java.lang.String serverClass,
                  int serverPort,
                  java.lang.String encoderClass,
                  java.lang.String decoderClass)
Basic constructor that creates a CommunicationsObject with the given port and protocol, and creates a ParserObject with the given encoder and decoder. It also creates a Handlers object to keep track of context widget handlers.
Parameters:
clientClass - Class to use for client communications
serverClass - Class to use for server communications
serverPort - Port to use for server communications
encoderClass - Class to use for communications encoding
decoderClass - Class to use for communications decoding
See Also:
CommunicationsObject, CommunicationsObject.start(), ParserObject, Handlers

BaseObject

public BaseObject()
Basic constructor that creates a CommunicationsObject, ParserObject and Handlers object.
See Also:
CommunicationsObject, CommunicationsObject.start(), ParserObject, Handlers

BaseObject

public BaseObject(int port)
Constructor that just creates a CommunicationsObject with the given port and ParserObject. It also creates a Handlers object to keep track of context widget handlers.
Parameters:
port - Port number to communicate on
See Also:
CommunicationsObject, CommunicationsObject.start(), ParserObject, Handlers

BaseObject

public BaseObject(java.lang.String protocol)
Constructor that just creates a CommunicationsObject with the given protocol handler class, and a ParserObject. It also creates a Handlers object to keep track of context widget handlers.
Parameters:
protocol - Protocol handler class to communicate with
See Also:
CommunicationsObject, CommunicationsObject.start(), ParserObject, Handlers

BaseObject

public BaseObject(int port,
                  java.lang.String protocol)
Constructor that just creates a CommunicationsObject with the given port and protocol handler class, and ParserObject. It also creates a Handlers object to keep track of context widget handlers.
Parameters:
port - Port number to communicate on
protocol - Protocol handler class name to communicate with
See Also:
Communications Object, CommunicationsObject.start(), ParserObject, Handlers
Method Detail

decodeData

public DataObject decodeData(java.io.Reader commData)
                      throws DecodeException,
                             InvalidDecoderException
Stub method that decodes the given string using ParserObject
Specified by:
decodeData in interface MessageHandler
Parameters:
commData - String to be decoded
Returns:
the decoded data
Throws:
DecodeException - thrown if the parser can't decode the given string
InvalidDecoderException - thrown if the parser can't create the necessary decoder
See Also:
ParserObject.decodeData(java.io.Reader)

encodeData

public java.lang.String encodeData(DataObject commData)
                            throws EncodeException,
                                   InvalidEncoderException
Stub method that encodes the given string using ParserObject
Specified by:
encodeData in interface MessageHandler
Parameters:
commData - String to be decoded
Returns:
the encoded data
Throws:
EncodeException - thrown if the parser can't encode the given string
InvalidEncoderException - thrown if the parser can't create the necessary encoder
See Also:
ParserObject.encodeData(context.arch.comm.DataObject)

userRequest

public DataObject userRequest(DataObject data,
                              java.lang.String tag)
                       throws EncodeException,
                              InvalidProtocolException,
                              ProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException
Method that submits a user request for polling/subscription. The request is in the form of a DataObject. It is encoded, sent out and the reply is decoded, if necessary, and returned.
Specified by:
userRequest in interface CommunicationsH andler
Parameters:
data - DataObject that contains the request
tag - local alias for callback
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 successful ly
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
InvalidProtocolE xception - when the request can't be sent successfully due to invalid protocol use

userRequest

public DataObject userRequest(DataObject data,
                              java.lang.String alias,
                              java.lang.String server)
                       throws EncodeException,
                              InvalidProtocolException,
                              ProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException
Method that submits a user request for polling/subscription. The request is in the form of a DataObject. It is encoded, sent out and the reply is decoded, if necessary, and returned.
Specified by:
userRequest in interface CommunicationsHandler
Parameters:
data - DataObject that contains the request
tag - local alias for callback
server - Hostname of the component the request is being sent to
Returns:
DataO bject 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

userRequest

public DataObject userRequest(DataObject data,
                              java.lang.String tag,
                              java.lang.String server,
                              int port)
                       throws EncodeException,
                              ProtocolException,
                              InvalidProtocolException,
                              DecodeException,
                              InvalidDecoderException,
                              InvalidEncoderException
Method that submits a user request for polling/subscription. The request is in the form of a DataObject. It is encoded, sent out and the reply is decoded, if necessary, and returned.
Specified by:
userRequest in interface CommunicationsHandler
Parameters:
data - DataObject that contains the request
tag - local alias for callback
server - Hostname of the component the request is being sent to
port - Port number of the component the request is being sent to
Returns:
DataObject containing the reply to the request
Throws:
EncodeException - when the encoding can't b e completed successfully
DecodeException - when the decoding can't be completed successfully
InvalidEncoderEx ception - 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

subscribeTo

public Error subscribeTo(Handler handler,
                         int port,
                         java.lang.String subid,
                         java.lang.String remoteHost,
                         int remotePort,
                         java.lang.String remoteId,
                         java.lang.String callback,
                         java.lang.String tag)
This method allows a component to subscribe to changes in other components. The subscription includes the handler that will handle the callbacks, the subscriber's hostname and port, the subscription id, the remote component's hostname, port, and id, the remote component's callback, and the name of the subscriber's method that will handle the callback.
Parameters:
handler - Object that handles context widget callbacks
port - Port number the subscriber receives communications on
subId - Subscription id
remoteHost - Hostname of the context widget being subscribed to
remotePort - Port number the context widget receives communication on
remoteId - Id of the context widget being subscribed to
callback - Callback defined by the context wi dget
tag - Local alias for callback
Returns:
Error to indicate success of subscription
See Also:
Handler s, Handlers.addHandler(context.arch.handler.HandlerInfo), userRequest(context.arch.comm.DataObject, String, String, int)

subscribeTo

public Error subscribeTo(Handler handler,
                         int port,
                         java.lang.String subid,
                         java.lang.String remoteHost,
                         int remotePort,
                         java.lang.String remoteId,
                         java.lang.String callback,
                         java.lang.String tag,
                         Conditions conditions)
This method allows a component to subscribe to changes in other components. The subscription includes the handler that will handle the callbacks, the subscriber's hostname and port, the subscription id, the remote component's hostname, port, and id, the remote component's callback, and the name of the subscriber's method that will handle the callback.
Parameters:
handler - Object that handles context widget callbacks
port - Port number the subscriber receives communications on
subId - Subscription id
remoteHost - Hostname of the context widget being subscribed to
remotePort - Port number the context widget receives communication on
remoteId - Id of the context widget being subscribed to
callback - Callback defined by the context wi dget
tag - Name of the subscriber method that handles the callback being subscribed to
conditions - Any conditions to put on the subscription
Returns:
Error to indicate success of subscription
See Also: < /B>
Handlers, Handlers.addHandler(context.arch.handler.HandlerInfo), userRequest(context.arch.comm.DataObject, String, String, int)

subscribeTo

public Error subscribeTo(Handler handler,
                         int port,
                         java.lang.String subid,
                         java.lang.String remoteHost,
                         int remotePort,
                         java.lang.String remoteId,
                         java.lang.String callback,
                         java.lang.String tag,
                         Attributes attributes)
This method allows a component to subscribe to changes in other components. The subscription includes the handler that will handle the callbacks, the subscriber's hostname and port, the subscription id, the remote component's hostname, port, and id, the remote component's callback, and the name of the subscriber's method that will handle the callback.
Parameters:
handler - Object that handles context widget callbacks
port - Port number the subscriber receives communications on
subId - Subscription id
remoteHost - Hostname of the context widget being subscribed to
remotePort - Port number the context widget receives communication on
remoteId - Id of the context widget being subscribed to
callback - Callback defined by the context wi dget
tag - Name of the subscriber method that handles the callback being subscribed to
attributes - Attributes to return to the subscriber
Returns:
Error to indicate success of subscription
See Also:
Handlers, Handlers.addHandler(context.arch.handler.HandlerInfo), userRequest(context.arch.comm.DataObject, String, String, int)

subscribeTo

public Error subscribeTo(Handler handler,
                         int port,
                         java.lang.String subid,
                         java.lang.String remoteHost,
                         int remotePort,
                         java.lang.String remoteId,
                         java.lang.String callback,
                         java.lang.String tag,
                         Conditions conditions,
                         Attributes attributes)
This method allows a component to subscribe to changes in other components. The subscription includes the handler that will handle the callbacks, the subscriber's hostname and port, the subscription id, the remote component's hostname, port, and id, the remote component's callback, and the name of the subscriber's method that will handle the callback.
Parameters:
handler - Object that handles context widget callbacks
port - Port number the subscriber receives communications on
subId - Subscription id
remoteHost - Hostname of the context widget being subscribed to
remotePort - Port number the context widget receives communication on
remoteId - Id of the context widget being subscribed to
callback - Callback defined by the context wi dget
tag - local alias for callback
conditions - Any conditions to put on the subscription
attributes - Attributes to return to the subscriber
Returns :
Error to indicate success of subscription
See Also:
Handlers, Handlers.addHandler(context.arch.handler.HandlerInfo), userRequest(context.arch.comm.DataObject, String, String, int)

unsubscribeFrom

public Error unsubscribeFrom(Handler handler,
                             java.lang.String remoteHost,
                             int remotePort,
                             java.lang.String remoteId,
                             Subscriber subscriber)
This method allows a component to unsubscribe from another component.
Parameters:
handler - Object that handles context widget callbacks
remoteHost - Hostname of the widget being unsubscribed from
remotePort - Port number of the widget being unsubscribed from
remoteId - Id of the context widget being unsubscribed from
subscriber - Subscriber object holding the subscription info
Returns:
Error to indicate success of unsubscription
See Also:
Handlers, Handlers.removeHandler(context.arch.handler.HandlerInfo), userRequest(context.arch.comm.DataObject, String, String, int)

pollWidget

public DataObject pollWidget(java.lang.String widgetHost,
                             int widgetPort,
                             java.lang.String widgetId,
                             Attributes attributes)
This method allows a component to poll a remote widget for its attribute values. A list of attributes is provided to dictate which attribute values are wanted.
Parameters:
widgetHost - Hostname of the context widget being polled
widgetPort - Port number of the context widget being polled
widgetId - Id of the context widget being polled
attribute s - Attributes being requested
Returns:
DataObject containing results of poll
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

updateAndPollWidget

public DataObject updateAndPollWidget(java.lang.String widgetHost,
                                      int widgetPort,
                                      java.lang.String widgetId,
                                      Attributes attributes)
This method allows a component to force a remote widget to update its data and return it. A list of attributes is provided to dictate which attribute values are wanted.
Parameters:
widgetHost - Hostname of the context widget being polled
widgetPort - Port number of the context widget being polled
widgetId - Id of the context widget being polled
attribute s - Attributes being requested
Returns:
DataObject containing results of poll
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

putDataInWidget

public DataObject putDataInWidget(java.lang.String widgetHost,
                                  int widgetPort,
                                  java.lang.String widgetId,
                                  java.lang.String callback,
                                  AttributeNameValues attributes)
This method allows a component to put context data in a remote widget. It is really intended for components that don't use the context toolkit, but is being included here for possible future use. The method takes a callback and an AttributeNameValues object. The callback is not necessary (can have a null value), and is only used by the remote widget to determine which of the widget's subscribers need to be updated.
Parameters:
widgetHost - Hostname of the context widget to use
widgetPort - Port number of the context widget to use
widgetId - Id of the context widget to use
callback - Callback of the context widget to associate the data with
attributes - AttributeNameValues to put in the widget
Returns:
DataObject containing results of put data
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

getVersion

public DataObject getVersion(java.lang.String remoteHost,
                             int remotePort,
                             java.lang.String remoteId)
This method gets the version of the given component (server, widget, interpreter).
Parameters:
remoteHost - Hostname of the component being queried
remotePort - Port number of the component being queried
remoteId - Id of the component being queried
Returns:
DataObje ct containing version
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

getWidgetCallbacks

public DataObject getWidgetCallbacks(java.lang.String widgetHost,
                                     int widgetPort,
                                     java.lang.String widgetId)
This method gets the callbacks of the given widget
Parameters:
widgetHost - Hostname of the widget being queried
widgetPort - Port number of the widget being queried
widgetId - Id of the widget being queried
Returns:
DataObject contai ning callbacks
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

getWidgetServices

public DataObject getWidgetServices(java.lang.String widgetHost,
                                    int widgetPort,
                                    java.lang.String widgetId)
This method gets the services of the given widget
Parameters:
widgetHost - Hostname of the widget being queried
widgetPort - Port number of the widget being queried
widgetId - Id of the widget being queried
Returns:
DataObject contai ning services of the widget
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

getWidgetAttributes

public DataObject getWidgetAttributes(java.lang.String widgetHost,
                                      int widgetPort,
                                      java.lang.String widgetId)
This method gets the attributes of the given widget
Parameters:
widgetHost - Hostname of the widget being queried
widgetPort - Port number of the widget being queried
widgetId - Id of the widget being queried
Returns:
DataObject contai ning callbacks
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId,
                                   Retrieval retrieval)
This method allows a component to retrieve data from other components.
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
retrieval - Description of data to retrieve with any conditions
Returns:
DataObject containing data requested
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId,
                                   java.lang.String myId,
                                   Retrieval retrieval)
This method allows a component to retrieve data from other components.
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
myId - Id of the "user" trying to access the data
retrieval - Description of data to retrieve with any conditions
Returns:
DataObject containing data requested
See Also:
userRequest(context.arch.comm.DataObject, String, String, int)

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId,
                                   java.lang.String attribute)
This method returns a vector containing AttributeNameValues objects for all the the data of a given attribute. e.g. SQL query would be "SELECT attribute FROM table"
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
attribute - Attribute to retrieve
Returns:
DataObject containing data requested

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId,
                                   AttributeFunctions attributes)
This method returns a vector containing AttributeNameValues objects for all the the data of the given attributes. e.g. SQL query would be "SELECT attribute1,attribute2,...,attributeN FROM table"
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
attributes - Names of the attributes to retrieve data for
Returns:
DataObject containing data requested

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId,
                                   AttributeFunctions attributes,
                                   java.lang.String attribute,
                                   int compare,
                                   java.lang.Object value)
This method returns a vector containing AttributeNameValues objects for all the the data of the given attributes and a single condition. e.g. SQL query would be "SELECT attribute1,attribute2,...,attributeN FROM table WHERE attributeX > valueY"
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
attributes - Names of the attributes to retrieve data for
attribute - Name of the attribute to do conditional on
compare - Comparison flag
value - Comparison value to use
Returns:
DataObj ect containing data requested

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId)
This method returns a vector containing AttributeNameValues objects for all the the data. e.g. SQL query would be "SELECT * FROM table
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
Ret urns:
DataObject containing data requested

retrieveDataFrom

public DataObject retrieveDataFrom(java.lang.String remoteHost,
                                   int remotePort,
                                   java.lang.String remoteId,
                                   java.lang.String attribute,
                                   int compare,
                                   java.lang.Object value)
This method returns a vector containing AttributeNameValues objects for all the the data and a single condition. e.g. SQL query would be "SELECT * FROM table WHERE attributeX > valueY
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
attribute - Name of the attribute to do conditional on
compare - Comparison flag
value - Comparison value to use
Returns:
DataObject containing data requested

askInterpreter

public DataObject askInterpreter(java.lang.String remoteHost,
                                 int remotePort,
                                 java.lang.String remoteId,
                                 AttributeNameValues data)
This method asks an interpreter to interpret some data. It passes the data to be interpreted and gets back the interpreted data.
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
data - AttributeNameValues object containing the data to be interpreted
Returns:
DataObject containing the interpreted data

runComponentMethod

public DataObject runComponentMethod(java.lang.String remoteHost,
                                     int remotePort,
                                     java.lang.String remoteId,
                                     java.lang.String methodName,
                                     AttributeNameValues parameters,
                                     Attributes attributes)
This method asks an component to run some non-standard method. It passes id of the component, attributes, and parameters and gets back the result of the method.
Parameters:
remoteHost - Hostname of the component
remotePort - Port number of the component
remoteId - Id of the component
methodName - Name of the method to run
paramete rs - AttributeNameValues object that is parameters with values
attributes - Attributes object that is parameters with values
Returns:
DataObject containing the interpreted data

executeAsynchronousWidgetService

public DataObject executeAsynchronousWidgetService(AsyncServiceHandler handler,
                                                   java.lang.String serviceHost,
                                                   int servicePort,
                                                   java.lang.String serviceId,
                                                   java.lang.String service,
                                                   java.lang.String function,
                                                   AttributeNameValues input,
                                                   java.lang.String requestTag)
This method requests that a widget execute an asynchronous service
Specified by:
executeAsynchronousWidgetService in interface CommunicationsHandler
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 serv ice
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,
                                                  AttributeNameValues input)
This method requests that a widget execute a synchronous service
Specified by:
executeSynchro nousWidgetService in interface CommunicationsHandler
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

pingComponent

public DataObject pingComponent(java.lang.String remoteHost,
                                int remotePort,
                                java.lang.String remoteId)
This method pings a component (widget,server, or interpreter) to make sure that it is functioning ok.
Parameters:
remoteHost - Hostname of the component being asked for data
remotePort - Port number of the component being asked for data
remoteId - Id of the component being asked for data
Ret urns:
DataObject containing the results of the ping

quit

public void quit()
This method should be called when the object is going to exit under normal conditions. It stops the CommunicationsObject from receiving any more requests and exits.
See Also:
CommunicationsObject.quit()

runUserMethod

public DataObject runUserMethod(DataObject data)
                         throws InvalidMethodException,
                                MethodException
This is an empty method that should be overridden by the object that extends this class. It will contain the user-defined RPCs.
Parameters:
data - DataObject containing data for user-defined RPC
Returns:
result of RPC
Throws:
InvalidMethodException - thrown if specifie d RPC couldn't be found
MethodException - thrown if specified RPC had an error
See Also:
runMethod(String, DataObject)

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. If a user-defined RPC is called, this method calls runUserMethods. If a callback is specified, this method runs userCallback. Currently, the only system-defined methods are queryVersion, and userCallback.
Specified by:
runMethod in interface MessageHandler< /A>
Parameters:
methodType - Name of method to run
data - DataObject containing data for the method call
Throws:
InvalidMethodException - thro wn if specified RPC couldn't be found
MethodException - thrown if specified RPC had an error
See Also:
userCallback(context.arch.comm.DataObject), runUserMethod(context.arch.comm.DataObject), queryVersion(context.arch.comm.DataObject)

userCallback

public DataObject userCallback(DataObject data)
This method is called when a callback message is received. It determines which of its registered handlers should receive the callback message and passes it on accordingly. It creates a reply message to the callback request in the form of a DataObject. It handles all error checking.
Parameters:
data - DataObject containing the callback request
Returns:
DataObject containing the callback reply
See Also:
Handlers.getHandler(String), Handler.handle(String, context.arch.comm.DataObject)

queryVersion

public DataObject queryVersion(DataObject query)
This method returns the version number of this component.
Parameters:
query - DataObject containing the query
Returns:
DataObject containing the results of the query

returnPing

public DataObject returnPing(DataObject ping)
This method returns an error message as an answer to a ping.
Parameters:
ping - DataObject containing the ping request
Returns:
DataObject containing the results of the ping

serviceResult

public DataObject serviceResult(DataObject result)
This method handles the results of an asynchronous service request.
Parameters:
result - DataObject containing the results of the aysnchronous service request
Returns:
DataObject containing a reply to the results message

getVersion

public java.lang.String getVersion()
This method returns the version number of this object.
Returns:
version number

setVersion

public void setVersion(java.lang.String version)
This method sets the version number of this object.
Parameters:
version - of the object

setId

public void setId(java.lang.String id)
This method sets the id of classes that subclass this object, for use in sending messages.
Parameters:
id - ID of the class

getId

public java.lang.String getId()
This method returns the id of the class that subclass this object, for use in sending messages.
Returns:
id of the class

getHostAddress

public java.lang.String getHostAddress()
This method gets the address of the machine this component is running on.
Returns:
the address of the machine this component is running on

main

public static void main(java.lang.String[] argv)
Temporary main method to test the BaseObject class