|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object context.arch.BaseObject context.arch.widget.Widget
This class is the basic context widget, with attributes and methods that should apply to all context widgets.
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static boolean DEBUG
public static final java.lang.String CLASS
public static final java.lang.String WIDGET_TYPE
public java.lang.String VERSION_NUMBER
public static final int DEFAULT_PORT
public static final java.lang.String VERSION
public static final java.lang.String TIMESTAMP
public static final java.lang.String QUERY
public static final java.lang.String QUERY_REPLY
public static final java.lang.String UPDATE_AND_QUERY
public static final java.lang.String UPDATE_AND_QUERY_REPLY
public static final java.lang.String QUERY_ATTRIBUTES
public static final java.lang.String QUERY_CONSTANT_ATTRIBUTES
public static final java.lang.String QUERY_ATTRIBUTES_REPLY
public static final java.lang.String QUERY_CONSTANT_ATTRIBUTES_REPLY
public static final java.lang.String QUERY_CALLBACKS
public static final java.lang.String QUERY_CALLBACKS_REPLY
public static final java.lang.String QUERY_SERVICES
public static final java.lang.String QUERY_SERVICES_REPLY
public static final java.lang.String QUERY_VERSION
public static final java.lang.String QUERY_VERSION_REPLY
public static final java.lang.String PUT_DATA
public static final java.lang.String PUT_DATA_REPLY
public static final java.lang.String UPDATE
public static final java.lang.String SPACER
protected Attributes attributes
protected Attributes constantAttributes
protected java.util.Hashtable attributeTypes
protected java.util.Hashtable constantAttributesTypes
protected Callbacks callbacks
protected Services services
protected long CurrentOffset
public Subscribers subscribers
Subscribers
,
Subscriber
public StorageObject storage
StorageObject
Constructor Detail |
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)
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 decodingstorageClass
- Class to use for storageid
- String to use for widget id and persistent storageStorageObject
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)
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 decodingstorageFlag
- Flag to determine whether storage should be used or notid
- String to use for widget id and persistent storageStorageObject
public Widget(int port, java.lang.String id, boolean storageFlag)
port
- Port to listen to for incoming messagesid
- Widget idstorageFlag
- Boolean flag to indicate whether storage should be turned onpublic Widget(int port, java.lang.String id)
port
- Port to listen to for incoming messagesid
- Widget idpublic Widget(java.lang.String id, boolean storageFlag)
id
- Widget idstorageFlag
- Boolean flag to indicate whether storage should be turned onpublic Widget(java.lang.String id)
id
- ID of the widgetMethod Detail |
public java.lang.String getType()
getType
in class BaseObject
protected abstract Attributes initAttributes()
protected abstract Callbacks initCallbacks()
protected abstract Attributes initConstantAttributes()
protected abstract Services initServices()
protected void setAttributes(Attributes atts)
protected void setConstantAttributes(Attributes atts)
protected void setCallbacks(Callbacks calls)
protected void setServices(Services svcs)
protected java.lang.String getAttributeType(java.lang.String name)
name
- Name of the attribute to getprotected void setAttribute(java.lang.String name, java.lang.String type)
name
- Name of the attribute to settype
- Type of the attributeprotected boolean isAttribute(java.lang.String name)
name
- Name of the attribute to checkprotected boolean isCallback(java.lang.String name)
name
- Name of the callback to check
public void notify(java.lang.String event, java.lang.Object data)
event
- Name of the event occurringdata
- Object containing the relevant dataprotected void updateWidgetInformation()
protected abstract Attributes queryGenerator()
protected DataObject runWidgetMethod(DataObject data, java.lang.String error)
data
- DataObject containing the data for the methoderror
- String containing the incoming error value
public DataObject runUserMethod(DataObject data)
runUserMethod
in class BaseObject
data
- DataObject containing the method to run and parameters
QUERY
,
QUERY_VERSION
,
UPDATE_AND_QUERY
protected DataObject putData(DataObject data, java.lang.String error)
data
- DataObject containing the context data to writeerror
- String containing the incoming error value
protected DataObject queryCallbacks(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error value
protected DataObject queryAttributes(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error value
protected DataObject queryConstantAttributes(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error value
protected DataObject queryServices(DataObject query, java.lang.String error)
query
- DataObject containing the queryerror
- String containing the incoming error value
protected DataObject queryWidget(DataObject query, boolean update, java.lang.String error)
query
- DataObject containing the query requestupdate
- Whether or not to acquire new dataerror
- String containing the incoming error value
protected boolean canHandle(Attributes atts)
protected boolean canHandle(AttributeFunctions atts)
atts
- List of attributes to check
protected DataObject executeService(DataObject request, java.lang.String error)
request
- DataObject containing the service requesterror
- String containing the incoming error value
public void setNonConstantAttributes(Attributes anv)
anv
- protected void sendToSubscribers(java.lang.String callback)
BaseObject.userRequest(DataObject, String, String, int)
,
Subscribers
protected void processCallbackReply(DataObject result, Subscriber sub)
result
- DataObject containing the resultsub
- Subscriber that returned this replypublic DataObject addSubscriber(DataObject sub, java.lang.String error)
sub
- DataObject containing the subscription informationerror
- String containing the incoming error value
context.arch.subscriber.Subscribers#addSubscriber(String,String,int,String,String,Conditions,Attributes)
public DataObject removeSubscriber(DataObject sub, java.lang.String error)
sub
- DataObject containing the subscription informationerror
- String containing the incoming error value
context.arch.subscriber.Subscribers#removeSubscriber(String, String, String, String, String)
protected DataObject retrieveData(DataObject data, java.lang.String error)
data
- DataObject containing the subscription informationerror
- String containing the incoming error value
protected void store(DataObject data)
data
- Data to storeStorageObject.store(DataObject)
protected void store(Attributes data)
data
- Data to storecontext.arch.storage.StorageObject#store(AttributeNameValues)
protected void getNewOffset()
OffsetThread
protected long getNewOffsetNoDelay()
OffsetThread
protected java.lang.Long getCurrentTime()
public DataObject getUserDescription()
getUserDescription
in class BaseObject
getWidgetDescription()
public DataObject getSubscribersDescription()
public DataObject getWidgetDescription()
getUserDescription()
protected void setSubscribers()
public void handleIndependentReply(IndependentCommunication independentCommunication)
handleIndependentReply
in interface MessageHandler
handleIndependentReply
in class BaseObject
independentCommunication
- The object sent back by the threadClientsPool
,
Client
,
context.arch.util.RequestObject
,
DataObject
public void setId(java.lang.String id)
setId
in class BaseObject
id
- The id of this ctk component
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |