|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--context.arch.BaseObject
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.
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 |
public static final int EXIT_OK
public static final java.lang.String ID
public static final java.lang.String PING
public static final java.lang.String PING_REPLY
public CommunicationsObject communications
CommunicationsObject
public ParserObject parser
ParserObject
public Handlers handlers
Handlers
,
Handler
public AsyncServiceHandlers serviceHandlers
AsyncServiceHandlers
,
AsyncServiceHandler
Constructor Detail |
public BaseObject(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass)
clientClass
- Class to use for client communicationsserverClass
- Class to use for server communicationsserverPort
- Port to use for server communicationsencoderClass
- Class to use for communications encodingdecoderClass
- Class to use for communications decodingCommunicationsObject
,
CommunicationsObject.start()
,
ParserObject
,
Handlers
public BaseObject()
CommunicationsObject
,
CommunicationsObject.start()
,
ParserObject
,
Handlers
public BaseObject(int port)
port
- Port number to communicate onCommunicationsObject
,
CommunicationsObject.start()
,
ParserObject
,
Handlers
public BaseObject(java.lang.String protocol)
protocol
- Protocol handler class to communicate withCommunicationsObject
,
CommunicationsObject.start()
,
ParserObject
,
Handlers
public BaseObject(int port, java.lang.String protocol)
port
- Port number to communicate onprotocol
- Protocol handler class name to communicate withCommunications
Object
,
CommunicationsObject.start()
,
ParserObject
,
Handlers
Method Detail |
public DataObject decodeData(java.io.Reader commData) throws DecodeException, InvalidDecoderException
commData
- String to be decodedParserObject.decodeData(java.io.Reader)
public java.lang.String encodeData(DataObject commData) throws EncodeException, InvalidEncoderException
commData
- String to be decodedParserObject.encodeData(context.arch.comm.DataObject)
public DataObject userRequest(DataObject data, java.lang.String tag) throws EncodeException, InvalidProtocolException, ProtocolException, DecodeException, InvalidDecoderException, InvalidEncoderException
data
- DataObject that contains
the requesttag
- local
alias for callbackpublic DataObject userRequest(DataObject data, java.lang.String alias, java.lang.String server) throws EncodeException, InvalidProtocolException, ProtocolException, DecodeException, InvalidDecoderException, InvalidEncoderException
data
- DataObject that contains
the requesttag
- local alias for
callbackserver
- Hostname of
the component the request is being sent topublic DataObject userRequest(DataObject data, java.lang.String tag, java.lang.String server, int port) throws EncodeException, ProtocolException, InvalidProtocolException, DecodeException, InvalidDecoderException, InvalidEncoderException
data
- DataObject that contains
the requesttag
- local alias for
callbackserver
- Hostname of
the component the request is being sent toport
- Port
number of the component the request is being sent topublic 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)
handler
- Object that handles context widget callbacksport
- Port number the subscriber receives communications onsubId
- Subscription idremoteHost
- Hostname of the
context widget being subscribed toremotePort
- Port number the context widget receives communication onremoteId
- Id of the context widget being subscribed tocallback
- Callback defined by the context wi
dgettag
- Local alias for
callbackHandler
s
,
Handlers.addHandler(context.arch.handler.HandlerInfo)
,
userRequest(context.arch.comm.DataObject, String, String, int)
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)
handler
- Object that handles context widget callbacksport
- Port number the subscriber receives communications onsubId
- Subscription idremoteHost
- Hostname of the
context widget being subscribed toremotePort
- Port number the context widget receives communication onremoteId
- Id of the context widget being subscribed tocallback
- Callback defined by the context wi
dgettag
- Name of the subscriber method that handles the
callback being subscribed toconditions
- Any conditions to put on the subscriptionHandlers
,
Handlers.addHandler(context.arch.handler.HandlerInfo)
,
userRequest(context.arch.comm.DataObject, String, String, int)
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)
handler
- Object that handles context widget callbacksport
- Port number the subscriber receives communications onsubId
- Subscription idremoteHost
- Hostname of the
context widget being subscribed toremotePort
- Port number the context widget receives communication onremoteId
- Id of the context widget being subscribed tocallback
- Callback defined by the context wi
dgettag
- Name of the subscriber method that handles the
callback being subscribed toattributes
- Attributes to return to the subscriberHandlers
,
Handlers.addHandler(context.arch.handler.HandlerInfo)
,
userRequest(context.arch.comm.DataObject, String, String, int)
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)
handler
- Object that handles context widget callbacksport
- Port number the subscriber receives communications onsubId
- Subscription idremoteHost
- Hostname of the
context widget being subscribed toremotePort
- Port number the context widget receives communication onremoteId
- Id of the context widget being subscribed tocallback
- Callback defined by the context wi
dgettag
- local alias for
callbackconditions
- Any conditions
to put on the subscriptionattributes
- Attributes to return to the subscriberHandlers
,
Handlers.addHandler(context.arch.handler.HandlerInfo)
,
userRequest(context.arch.comm.DataObject, String, String, int)
public Error unsubscribeFrom(Handler handler, java.lang.String remoteHost, int remotePort, java.lang.String remoteId, Subscriber subscriber)
handler
- Object that handles context widget callbacksremoteHost
- Hostname of the widget being unsubscribed fromremotePort
- Port number of the widget being unsubscribed fromsubscriber
- Subscriber object holding the subscription infoHandlers
,
Handlers.removeHandler(context.arch.handler.HandlerInfo)
,
userRequest(context.arch.comm.DataObject, String, String, int)
public DataObject pollWidget(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId, Attributes attributes)
widgetHost
- Hostname of the context widget being polledwidgetPort
- Port number of the context widget being polledwidgetId
- Id of the context widget being polledattribute
s
- Attributes being requesteduserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject updateAndPollWidget(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId, Attributes attributes)
widgetHost
- Hostname of the context widget being polledwidgetPort
- Port number of the context widget being polledwidgetId
- Id of the context widget being polledattribute
s
- Attributes being requesteduserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject putDataInWidget(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId, java.lang.String callback, AttributeNameValues attributes)
widgetHost
- Hostname of the context widget to usewidgetPort
- Port number of the context widget to usewidgetId
- Id of the context widget to usecallback
- Callback
of the context widget to associate the data withattributes
- AttributeNameValues to put in the widgetuserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject getVersion(java.lang.String remoteHost, int remotePort, java.lang.String remoteId)
remoteHost
- Hostname of the component being queriedremotePort
- Port number of the component being queriedremoteId
- Id of the component being querieduserRequest(context.arch.comm.DataObject, String, String, int)
DL>
public DataObject getWidgetCallbacks(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId)
widgetHost
- Hostname of the widget being queriedwidgetPort
- Port number of the widget being queriedwidgetId
- Id of the widget being querieduserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject getWidgetServices(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId)
widgetHost
- Hostname of the widget being queriedwidgetPort
- Port number of the widget being queriedwidgetId
- Id of the widget being querieduserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject getWidgetAttributes(java.lang.String widgetHost, int widgetPort, java.lang.String widgetId)
widgetHost
- Hostname of the widget being queriedwidgetPort
- Port number of the widget being queriedwidgetId
- Id of the widget being querieduserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, Retrieval retrieval)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
retrieval
- Description of data to retrieve with any conditionsuserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String myId, Retrieval retrieval)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
myId
- Id of the "user" trying to access the dataretrieval
- Description of data to retrieve with any conditionsuserRequest(context.arch.comm.DataObject, String, String, int)
public DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String attribute)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
attribute
- Attribute to retrievepublic DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, AttributeFunctions attributes)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
attributes
- Names of the attributes to retrieve data forpublic DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, AttributeFunctions attributes, java.lang.String attribute, int compare, java.lang.Object value)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
attributes
- Names of the attributes to retrieve data forattribute
- Name of the attribute to do conditional oncompare
- Comparison flagvalue
- Comparison value to usepublic DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for datapublic DataObject retrieveDataFrom(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String attribute, int compare, java.lang.Object value)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
attribute
- Name of the attribute to do conditional oncompare
- Comparison flagvalue
- Comparison value to usepublic DataObject askInterpreter(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, AttributeNameValues data)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for data
data
- AttributeNameValues object containing the data to be interpretedpublic DataObject runComponentMethod(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String methodName, AttributeNameValues parameters, Attributes attributes)
remoteHost
- Hostname of the componentremotePort
- Port number of the componentremoteId
- Id of the componentmethodName
- Name of the method to runparamete
rs
- AttributeNameValues object that is parameters with valuesattributes
- Attributes object that is parameters with valuespublic 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)
handler
- Handler to handle the results of the serviceserviceHost
- Hostname of the widget with the serviceservicePort
- Port number of the widget with the serviceserviceId
- Id of the widget with the serviceservice
- Name of the widget service to runfunction
- Name of the particular service function to runinput
- AttributeNameValues object to use to execute the serv
icerequestTag
- Unique tag provided by caller to identify resultpublic DataObject executeSynchronousWidgetService(java.lang.String remoteHost, int remotePort, java.lang.String remoteId, java.lang.String service, java.lang.String function, AttributeNameValues input)
remoteHost
- Hostname of the widgetremotePort
- Port number of the widgetremoteId
- Id of the widgetservice
- Name of the widget service to runfunction - Name of the particular service function to runinput
- AttributeNameValues object to use to execute the service- Returns:
- DataObject containing the results of the execution request
public DataObject pingComponent(java.lang.String remoteHost, int remotePort, java.lang.String remoteId)
remoteHost
- Hostname of the component being asked for dataremotePort
- Port number of the component being asked for dataremoteId
- Id of the component being asked for datapublic void quit()
CommunicationsObject.quit()
public DataObject runUserMethod(DataObject data) throws InvalidMethodException, MethodException
data
- DataObject containing data for user-defined RPCrunMethod(String, DataObject)
public DataObject runMethod(java.lang.String methodType, DataObject data) throws InvalidMethodException, MethodException
methodType
- Name of method to rundata
- DataObject containing data for the method calluserCallback(context.arch.comm.DataObject)
,
runUserMethod(context.arch.comm.DataObject)
,
queryVersion(context.arch.comm.DataObject)
public DataObject userCallback(DataObject data)
data
- DataObject containing the callback requestHandlers.getHandler(String)
,
Handler.handle(String, context.arch.comm.DataObject)
public DataObject queryVersion(DataObject query)
query
- DataObject containing the querypublic DataObject returnPing(DataObject ping)
ping
- DataObject containing the ping requestpublic DataObject serviceResult(DataObject result)
result
- DataObject containing the results of the aysnchronous service requestpublic java.lang.String getVersion()
public void setVersion(java.lang.String version)
version
- of the objectpublic void setId(java.lang.String id)
id
- ID of the classpublic java.lang.String getId()
public java.lang.String getHostAddress()
public static void main(java.lang.String[] argv)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |