context.arch.widget
Class Widget

java.lang.Object
  extended bycontext.arch.BaseObject
      extended bycontext.arch.widget.Widget
All Implemented Interfaces:
CommunicationsHandler, MessageHandler
Direct Known Subclasses:
Discoverer, InstallationWidget, LightWidget, ObjectPresenceWidget, Server, VisitorDisplayWidget

public abstract class Widget
extends BaseObject

This class is the basic context widget, with attributes and methods that should apply to all context widgets.

Author:
Anind
See Also:
BaseObject

Field Summary
protected  Attributes attributes
           
protected  java.util.Hashtable attributeTypes
           
protected  Callbacks callbacks
           
static java.lang.String CLASS
          Tag for the class file being used by the widget
protected  Attributes constantAttributes
           
protected  java.util.Hashtable constantAttributesTypes
           
protected  long CurrentOffset
           
static boolean DEBUG
          Debug flag.
static int DEFAULT_PORT
          Default port for widgets to use
static java.lang.String PUT_DATA
          Tag to indicate the widget should accept the given data
static java.lang.String PUT_DATA_REPLY
          Tag to indicate the reply to a PUT_DATA message
static java.lang.String QUERY
          Tag to indicate the widget should return the latest stored data
static java.lang.String QUERY_ATTRIBUTES
          Tag to indicate the widget should return its list of attributes
static java.lang.String QUERY_ATTRIBUTES_REPLY
          Tag to indicate the reply to a QUERY_ATTRIBUTES message
static java.lang.String QUERY_CALLBACKS
          Tag to indicate the widget should return its list of callbacks
static java.lang.String QUERY_CALLBACKS_REPLY
          Tag to indicate the reply to a QUERY_CALLBACKS message
static java.lang.String QUERY_CONSTANT_ATTRIBUTES
          Tag to indicate the widget should return its list of attributes
static java.lang.String QUERY_CONSTANT_ATTRIBUTES_REPLY
          Tag to indicate the reply to a QUERY_CONSTANT_ATTRIBUTES message
static java.lang.String QUERY_REPLY
          Tag to indicate the reply to a QUERY message
static java.lang.String QUERY_SERVICES
          Tag to indicate the widget should return its list of services
static java.lang.String QUERY_SERVICES_REPLY
          Tag to indicate the reply to a QUERY_SERVICES message
static java.lang.String QUERY_VERSION
          Tag to indicate the widget should return its version number
static java.lang.String QUERY_VERSION_REPLY
          Tag to indicate the reply to a QUERY_VERSION message
protected  Services services
           
static java.lang.String SPACER
          Constant for the widget spacer
 StorageObject storage
          Object to keep track of storage
 Subscribers subscribers
          Object to handle subscriptions to context data
static java.lang.String TIMESTAMP
          Tag for the timestamp of widget data
static java.lang.String UPDATE
          Tag to indicate an update is being sent
static java.lang.String UPDATE_AND_QUERY
          Tag to indicate the widget should get the latest data from the generator and return them
static java.lang.String UPDATE_AND_QUERY_REPLY
          Tag to indicate the reply to an UPDATE_AND_QUERY message
static java.lang.String VERSION
          Tag for version number.
 java.lang.String VERSION_NUMBER
          Dummy version number.
static java.lang.String WIDGET_TYPE
          The tag for the type of this object
 
Fields inherited from class context.arch.BaseObject
BASEOBJECT_TYPE, communications, DISABLE_PORT, discoverer, EXIT_OK, gFrame, handlers, ID, parser, PING, PING_REPLY, QUERY_DESCRIPTION, QUERY_DESCRIPTION_REPLY, serviceHandlers
 
Constructor Summary
Widget(int port, java.lang.String id)
          Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services.
Widget(int port, java.lang.String id, boolean storageFlag)
          Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services.
Widget(java.lang.String id)
          Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services.
Widget(java.lang.String id, boolean storageFlag)
          Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services.
Widget(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass, boolean storageFlag, java.lang.String id)
          Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks, and services and setting up the BaseObject info.
Widget(java.lang.String clientClass, java.lang.String serverClass, int serverPort, java.lang.String encoderClass, java.lang.String decoderClass, java.lang.String storageClass, java.lang.String id)
          Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks, and services and setting up the BaseObject info.
 
Method Summary
 DataObject addSubscriber(DataObject sub, java.lang.String error)
          This method adds a subscriber to this object.
protected  boolean canHandle(AttributeFunctions atts)
          This method checks the list of attributes and conditions to ensure that the widget contains these attributes.
protected  boolean canHandle(Attributes atts)
          This method checks the list of attributes to ensure that the widget contains these attributes.
protected  DataObject executeService(DataObject request, java.lang.String error)
          This method attempts to execute a widget service.
protected  java.lang.String getAttributeType(java.lang.String name)
          Returns the attribute value with the given name
protected  java.lang.Long getCurrentTime()
          This method returns the current time to use as a timestamp
protected  void getNewOffset()
          This method creates a thread that retrieves a global time clock and determines the offset between the local clock and the global clock.
protected  long getNewOffsetNoDelay()
          This method retrieves the offset between the local clock and a global clock with no delay.
 DataObject getSubscribersDescription()
          This method returns a DataObject containig the list of subscribers
 java.lang.String getType()
          Returns the type of the object This method should be overridden
 DataObject getUserDescription()
          This method builds the widget description which contains the constant and non constant attributes, the callbacks, the services, the subscribers This method overloads the BaseObject's getUserDescription method
 DataObject getWidgetDescription()
          This method returns the desciption specific to a widget.
 void handleIndependentReply(IndependentCommunication independentCommunication)
          This method overrides the handleIndependentReply defined in the BaseObject class.
protected abstract  Attributes initAttributes()
          Sets the attributes for the widget
protected abstract  Callbacks initCallbacks()
          Sets the callbacks for the widget
protected abstract  Attributes initConstantAttributes()
          Sets the constant attributes for the widget
protected abstract  Services initServices()
          Sets the services for the widget
protected  boolean isAttribute(java.lang.String name)
          Checks if the given attribute is an attribute of this widget
protected  boolean isCallback(java.lang.String name)
          Checks if the given callback is a callback of this widget
 void notify(java.lang.String event, java.lang.Object data)
          This is an empty method that should be overridden by objects that subclass from this class.
protected  void processCallbackReply(DataObject result, Subscriber sub)
          This method should be overriden to process the results of subscription callbacks.
protected  DataObject putData(DataObject data, java.lang.String error)
          This method puts context data in a widget.
protected  DataObject queryAttributes(DataObject query, java.lang.String error)
          This method queries the attributes of a widget.
protected  DataObject queryCallbacks(DataObject query, java.lang.String error)
          This method queries the callbacks of a widget.
protected  DataObject queryConstantAttributes(DataObject query, java.lang.String error)
          This method queries the constant attributes of a widget.
protected abstract  Attributes queryGenerator()
          This abstract method is called when the widget wants to get the latest generator info.
protected  DataObject queryServices(DataObject query, java.lang.String error)
          This method queries the services of a widget.
protected  DataObject queryWidget(DataObject query, boolean update, java.lang.String error)
          This method runs a query on a widget, asking for either it's latest acquired data (QUERY) or asking for the widget to acquire and return new data (UPDATE_AND_QUERY)
 DataObject removeSubscriber(DataObject sub, java.lang.String error)
          This method removes a subscriber to this object.
protected  DataObject retrieveData(DataObject data, java.lang.String error)
          This method retrieves data from the widget's storage.
 DataObject runUserMethod(DataObject data)
          This method is meant to handle any internal methods that the baseObject doesn't handle.
protected  DataObject runWidgetMethod(DataObject data, java.lang.String error)
          This is an empty method that should be overridden by objects that subclass from this class.
protected  void sendToSubscribers(java.lang.String callback)
          This method should be called to send data to subscribers when a context widget's callback is triggered.
protected  void setAttribute(java.lang.String name, java.lang.String type)
          Sets an attribute
protected  void setAttributes(Attributes atts)
           
protected  void setCallbacks(Callbacks calls)
           
protected  void setConstantAttributes(Attributes atts)
           
 void setId(java.lang.String id)
          This method overrides the BaseObject setId(String) method so that the baseobject id specified in the subscribers object be also updated.
 void setNonConstantAttributes(Attributes anv)
          sets the current state of some set of NonConstantAttributes in the widget.
protected  void setServices(Services svcs)
           
protected  void setSubscribers()
          This method is called when the widget is restarted.
protected  void store(Attributes data)
          This stub method stores the data in the given AttributeNameValues object
protected  void store(DataObject data)
          This stub method stores the data in the given DataObject
protected  void updateWidgetInformation()
          This method is called when a remote component sends an UPDATE_AND_QUERY message.
 
Methods inherited from class context.arch.BaseObject
activateDisplay, askInterpreter, deactivateDisplay, debugprintln, decodeData, discovererQuery, discovererQuery, discovererRegistration, discovererRegistration, discovererSendSubscription, discovererSubscribe, discovererSubscriptionNotification, discovererUnregistration, discovererUpdate, encodeData, executeAsynchronousWidgetService, executeSynchronousWidgetService, findDiscoverer, findDiscoverer, findDiscoverer, getComponentDescription, getDescription, getHostAddress, getHostName, getId, getId, getLease, getListOfHandlers, getLocationAddress, getPort, getVersion, getVersion, getWidgetAttributes, getWidgetCallbacks, getWidgetConstantAttributes, getWidgetServices, independentUserRequest, leaseEndNotified, pingComponent, pingComponent, pollWidget, println, putDataInWidget, queryVersion, quit, retrieveDataFrom, retrieveDataFrom, returnPing, runComponentMethod, runMethod, serviceResult, setAllDebug, setDiscoverer, setDisplay, setDisplay, setDisplayName, setDisplayTitle, setLease, setLocationAddress, setVersion, subscribeTo, unsubscribeFrom, updateAndPollWidget, userCallback, userRequest, userRequest, userRequest, userRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
Debug flag. Set to true to see debug messages.


CLASS

public static final java.lang.String CLASS
Tag for the class file being used by the widget

See Also:
Constant Field Values

WIDGET_TYPE

public static final java.lang.String WIDGET_TYPE
The tag for the type of this object

See Also:
Constant Field Values

VERSION_NUMBER

public java.lang.String VERSION_NUMBER
Dummy version number. Subclasses should override this value.


DEFAULT_PORT

public static final int DEFAULT_PORT
Default port for widgets to use

See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
Tag for version number.

See Also:
Constant Field Values

TIMESTAMP

public static final java.lang.String TIMESTAMP
Tag for the timestamp of widget data

See Also:
Constant Field Values

QUERY

public static final java.lang.String QUERY
Tag to indicate the widget should return the latest stored data

See Also:
Constant Field Values

QUERY_REPLY

public static final java.lang.String QUERY_REPLY
Tag to indicate the reply to a QUERY message

See Also:
Constant Field Values

UPDATE_AND_QUERY

public static final java.lang.String UPDATE_AND_QUERY
Tag to indicate the widget should get the latest data from the generator and return them

See Also:
Constant Field Values

UPDATE_AND_QUERY_REPLY

public static final java.lang.String UPDATE_AND_QUERY_REPLY
Tag to indicate the reply to an UPDATE_AND_QUERY message

See Also:
Constant Field Values

QUERY_ATTRIBUTES

public static final java.lang.String QUERY_ATTRIBUTES
Tag to indicate the widget should return its list of attributes

See Also:
Constant Field Values

QUERY_CONSTANT_ATTRIBUTES

public static final java.lang.String QUERY_CONSTANT_ATTRIBUTES
Tag to indicate the widget should return its list of attributes

See Also:
Constant Field Values

QUERY_ATTRIBUTES_REPLY

public static final java.lang.String QUERY_ATTRIBUTES_REPLY
Tag to indicate the reply to a QUERY_ATTRIBUTES message

See Also:
Constant Field Values

QUERY_CONSTANT_ATTRIBUTES_REPLY

public static final java.lang.String QUERY_CONSTANT_ATTRIBUTES_REPLY
Tag to indicate the reply to a QUERY_CONSTANT_ATTRIBUTES message

See Also:
Constant Field Values

QUERY_CALLBACKS

public static final java.lang.String QUERY_CALLBACKS
Tag to indicate the widget should return its list of callbacks

See Also:
Constant Field Values

QUERY_CALLBACKS_REPLY

public static final java.lang.String QUERY_CALLBACKS_REPLY
Tag to indicate the reply to a QUERY_CALLBACKS message

See Also:
Constant Field Values

QUERY_SERVICES

public static final java.lang.String QUERY_SERVICES
Tag to indicate the widget should return its list of services

See Also:
Constant Field Values

QUERY_SERVICES_REPLY

public static final java.lang.String QUERY_SERVICES_REPLY
Tag to indicate the reply to a QUERY_SERVICES message

See Also:
Constant Field Values

QUERY_VERSION

public static final java.lang.String QUERY_VERSION
Tag to indicate the widget should return its version number

See Also:
Constant Field Values

QUERY_VERSION_REPLY

public static final java.lang.String QUERY_VERSION_REPLY
Tag to indicate the reply to a QUERY_VERSION message

See Also:
Constant Field Values

PUT_DATA

public static final java.lang.String PUT_DATA
Tag to indicate the widget should accept the given data

See Also:
Constant Field Values

PUT_DATA_REPLY

public static final java.lang.String PUT_DATA_REPLY
Tag to indicate the reply to a PUT_DATA message

See Also:
Constant Field Values

UPDATE

public static final java.lang.String UPDATE
Tag to indicate an update is being sent

See Also:
Constant Field Values

SPACER

public static final java.lang.String SPACER
Constant for the widget spacer

See Also:
Constant Field Values

attributes

protected Attributes attributes

constantAttributes

protected Attributes constantAttributes

attributeTypes

protected java.util.Hashtable attributeTypes

constantAttributesTypes

protected java.util.Hashtable constantAttributesTypes

callbacks

protected Callbacks callbacks

services

protected Services services

CurrentOffset

protected long CurrentOffset

subscribers

public Subscribers subscribers
Object to handle subscriptions to context data

See Also:
Subscribers, Subscriber

storage

public StorageObject storage
Object to keep track of storage

See Also:
StorageObject
Constructor Detail

Widget

public Widget(java.lang.String clientClass,
              java.lang.String serverClass,
              int serverPort,
              java.lang.String encoderClass,
              java.lang.String decoderClass,
              java.lang.String storageClass,
              java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks, and services and setting up the BaseObject info. TO COMPLETE : for storage use

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
storageClass - Class to use for storage
id - String to use for widget id and persistent storage
See Also:
StorageObject

Widget

public Widget(java.lang.String clientClass,
              java.lang.String serverClass,
              int serverPort,
              java.lang.String encoderClass,
              java.lang.String decoderClass,
              boolean storageFlag,
              java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks, and services and setting up the BaseObject info. This version takes a boolean to indicate whether the default storage class should be used or whether no storage should be provided.

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
storageFlag - Flag to determine whether storage should be used or not
id - String to use for widget id and persistent storage
See Also:
StorageObject

Widget

public Widget(int port,
              java.lang.String id,
              boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. It takes a port number as a parameter to indicate which port to listen for messages/connections, the id to use for the widget, and a flag to indicate whether storage functionality should be turned on or off.

Parameters:
port - Port to listen to for incoming messages
id - Widget id
storageFlag - Boolean flag to indicate whether storage should be turned on

Widget

public Widget(int port,
              java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. It takes a port number as a parameter to indicate which port to listen for messages/connections.

Parameters:
port - Port to listen to for incoming messages
id - Widget id

Widget

public Widget(java.lang.String id,
              boolean storageFlag)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. It takes the id to use for the widget, and a flag to indicate whether storage functionality should be turned on or off.

Parameters:
id - Widget id
storageFlag - Boolean flag to indicate whether storage should be turned on

Widget

public Widget(java.lang.String id)
Constructor that sets up internal variables for maintaining the list of widget attributes, callbacks and services. It takes the widget id as a parameter

Parameters:
id - ID of the widget
Method Detail

getType

public java.lang.String getType()
Returns the type of the object This method should be overridden

Overrides:
getType in class BaseObject
Returns:
String

initAttributes

protected abstract Attributes initAttributes()
Sets the attributes for the widget


initCallbacks

protected abstract Callbacks initCallbacks()
Sets the callbacks for the widget


initConstantAttributes

protected abstract Attributes initConstantAttributes()
Sets the constant attributes for the widget


initServices

protected abstract Services initServices()
Sets the services for the widget


setAttributes

protected void setAttributes(Attributes atts)

setConstantAttributes

protected void setConstantAttributes(Attributes atts)

setCallbacks

protected void setCallbacks(Callbacks calls)

setServices

protected void setServices(Services svcs)

getAttributeType

protected java.lang.String getAttributeType(java.lang.String name)
Returns the attribute value with the given name

Parameters:
name - Name of the attribute to get

setAttribute

protected void setAttribute(java.lang.String name,
                            java.lang.String type)
Sets an attribute

Parameters:
name - Name of the attribute to set
type - Type of the attribute

isAttribute

protected boolean isAttribute(java.lang.String name)
Checks if the given attribute is an attribute of this widget

Parameters:
name - Name of the attribute to check

isCallback

protected boolean isCallback(java.lang.String name)
Checks if the given callback is a callback of this widget

Parameters:
name - Name of the callback to check
Returns:
boolean True if name is a known callback name

notify

public void notify(java.lang.String event,
                   java.lang.Object data)
This is an empty method that should be overridden by objects that subclass from this class. It is intended to be called by generator objects when new data has arrived for the purpose of notifying the widget.

Parameters:
event - Name of the event occurring
data - Object containing the relevant data

updateWidgetInformation

protected void updateWidgetInformation()
This method is called when a remote component sends an UPDATE_AND_QUERY message. It calls the widget's queryGenerator method to get the latest generator info, and then stores it.


queryGenerator

protected abstract Attributes queryGenerator()
This abstract method is called when the widget wants to get the latest generator info.

Returns:
AttributeNameValues containing the latest generator information

runWidgetMethod

protected DataObject runWidgetMethod(DataObject data,
                                     java.lang.String error)
This is an empty method that should be overridden by objects that subclass from this class. It is called when another component tries to run a method on the widget, but it's not a query.

Parameters:
data - DataObject containing the data for the method
error - String containing the incoming error value
Returns:
DataObject containing the method results

runUserMethod

public DataObject runUserMethod(DataObject data)
This method is meant to handle any internal methods that the baseObject doesn't handle. In particular, this method handles the common details for query requests, update and query requests, and version requests that each widget should provide. If the method is not one of these queries, then it calls runWidgetMethod which each widget should provide.

Overrides:
runUserMethod in class BaseObject
Parameters:
data - DataObject containing the method to run and parameters
Returns:
DataObject containing the results of running the method
See Also:
QUERY, QUERY_VERSION, UPDATE_AND_QUERY

putData

protected DataObject putData(DataObject data,
                             java.lang.String error)
This method puts context data in a widget. It is expected that widgets will get data from a generator. But for some widgets, the generator will not use the context toolkit directly, but may use a web CGI script, for example. For this case, the widget provides this method to collect the data and makes it available to subscribers and for retrieval.

Parameters:
data - DataObject containing the context data to write
error - String containing the incoming error value
Returns:
DataObject containing the results of writing the data

queryCallbacks

protected DataObject queryCallbacks(DataObject query,
                                    java.lang.String error)
This method queries the callbacks of a widget.

Parameters:
query - DataObject containing the query
error - String containing the incoming error value
Returns:
DataObject containing the results of the query

queryAttributes

protected DataObject queryAttributes(DataObject query,
                                     java.lang.String error)
This method queries the attributes of a widget.

Parameters:
query - DataObject containing the query
error - String containing the incoming error value
Returns:
DataObject containing the results of the query

queryConstantAttributes

protected DataObject queryConstantAttributes(DataObject query,
                                             java.lang.String error)
This method queries the constant attributes of a widget.

Parameters:
query - DataObject containing the query
error - String containing the incoming error value
Returns:
DataObject containing the results of the query

queryServices

protected DataObject queryServices(DataObject query,
                                   java.lang.String error)
This method queries the services of a widget.

Parameters:
query - DataObject containing the query
error - String containing the incoming error value
Returns:
DataObject containing the results of the query

queryWidget

protected DataObject queryWidget(DataObject query,
                                 boolean update,
                                 java.lang.String error)
This method runs a query on a widget, asking for either it's latest acquired data (QUERY) or asking for the widget to acquire and return new data (UPDATE_AND_QUERY)

Parameters:
query - DataObject containing the query request
update - Whether or not to acquire new data
error - String containing the incoming error value
Returns:
DataObject containing the reply to the query

canHandle

protected boolean canHandle(Attributes atts)
This method checks the list of attributes to ensure that the widget contains these attributes.

Returns:
whether the list of attributes is valid

canHandle

protected boolean canHandle(AttributeFunctions atts)
This method checks the list of attributes and conditions to ensure that the widget contains these attributes.

Parameters:
atts - List of attributes to check
Returns:
whether the list of attributes and conditions is valid

executeService

protected DataObject executeService(DataObject request,
                                    java.lang.String error)
This method attempts to execute a widget service.

Parameters:
request - DataObject containing the service request
error - String containing the incoming error value
Returns:
DataObject containing the results of the service request

setNonConstantAttributes

public void setNonConstantAttributes(Attributes anv)
sets the current state of some set of NonConstantAttributes in the widget. If subscribers or storage is enabled, we send the attributes out to subscribers. Note: does not enforce strong type checking. If an arbitrary attribute is set, this widget will 'acquire' that attribute. It will probably not be sent as a callback, however.

Parameters:
anv -

sendToSubscribers

protected void sendToSubscribers(java.lang.String callback)
This method should be called to send data to subscribers when a context widget's callback is triggered. It sends data only to those subscribers that have subscribed to the specified callback.

See Also:
BaseObject.userRequest(DataObject, String, String, int), Subscribers

processCallbackReply

protected void processCallbackReply(DataObject result,
                                    Subscriber sub)
This method should be overriden to process the results of subscription callbacks.

Parameters:
result - DataObject containing the result
sub - Subscriber that returned this reply

addSubscriber

public DataObject addSubscriber(DataObject sub,
                                java.lang.String error)
This method adds a subscriber to this object. It calls Subscribers.addSubscriber() if it can add the subscriber. It returns a DataObject containing the reply information, including any error information. Agathe: change the Subscriber calls to use AbstractSubscriber

Parameters:
sub - DataObject containing the subscription information
error - String containing the incoming error value
Returns:
DataObject with the reply to the subscription request
See Also:
context.arch.subscriber.Subscribers#addSubscriber(String,String,int,String,String,Conditions,Attributes)

removeSubscriber

public DataObject removeSubscriber(DataObject sub,
                                   java.lang.String error)
This method removes a subscriber to this object. It calls Subscribers.removeSubscriber() if it can remove the subscriber. It returns a DataObject containing the reply information, including any error information.

Parameters:
sub - DataObject containing the subscription information
error - String containing the incoming error value
Returns:
DataObject with the reply to the subscription request
See Also:
context.arch.subscriber.Subscribers#removeSubscriber(String, String, String, String, String)

retrieveData

protected DataObject retrieveData(DataObject data,
                                  java.lang.String error)
This method retrieves data from the widget's storage. It returns a DataObject containing the retrieved data information, including any error information.

Parameters:
data - DataObject containing the subscription information
error - String containing the incoming error value
Returns:
DataObject with the reply to the subscription request

store

protected void store(DataObject data)
This stub method stores the data in the given DataObject

Parameters:
data - Data to store
See Also:
StorageObject.store(DataObject)

store

protected void store(Attributes data)
This stub method stores the data in the given AttributeNameValues object

Parameters:
data - Data to store
See Also:
context.arch.storage.StorageObject#store(AttributeNameValues)

getNewOffset

protected void getNewOffset()
This method creates a thread that retrieves a global time clock and determines the offset between the local clock and the global clock. It checks this

Returns:
the offset between the global and local clocks
See Also:
OffsetThread

getNewOffsetNoDelay

protected long getNewOffsetNoDelay()
This method retrieves the offset between the local clock and a global clock with no delay.

Returns:
the offset between the global and local clocks
See Also:
OffsetThread

getCurrentTime

protected java.lang.Long getCurrentTime()
This method returns the current time to use as a timestamp

Returns:
the current time, corrected using a global clock offset

getUserDescription

public DataObject getUserDescription()
This method builds the widget description which contains the constant and non constant attributes, the callbacks, the services, the subscribers This method overloads the BaseObject's getUserDescription method

Overrides:
getUserDescription in class BaseObject
Returns:
DataObject The description of the widget
See Also:
getWidgetDescription()

getSubscribersDescription

public DataObject getSubscribersDescription()
This method returns a DataObject containig the list of subscribers

Returns:
DataObject The list of subscribers

getWidgetDescription

public DataObject getWidgetDescription()
This method returns the desciption specific to a widget. By default, it returns the type of the object that is 'WIDGET' type This method should be overloaded.

Returns:
DataObject The DataObject containing the description of the widget
See Also:
getUserDescription()

setSubscribers

protected void setSubscribers()
This method is called when the widget is restarted. This method restarts the subscriptions, that is, the widget creates the subscribers that are described in its logfile. To each identified subscriber, the widget sends a PING message to check their liveliness. The URL sent is WIDGET+SUBSCRIBERS+PING. This PING is done through an independent connection (a thread handles the communication), so the result of the PING is got in the widget.handleIndependentReply.


handleIndependentReply

public void handleIndependentReply(IndependentCommunication independentCommunication)
This method overrides the handleIndependentReply defined in the BaseObject class. This method handles the reply to : If the url is not recognized, the message is sent to the BaseObject.handlIndependentReply

Specified by:
handleIndependentReply in interface MessageHandler
Overrides:
handleIndependentReply in class BaseObject
Parameters:
independentCommunication - The object sent back by the thread
See Also:
ClientsPool, Client, context.arch.util.RequestObject, DataObject

setId

public void setId(java.lang.String id)
This method overrides the BaseObject setId(String) method so that the baseobject id specified in the subscribers object be also updated.

Overrides:
setId in class BaseObject
Parameters:
id - The id of this ctk component