context.arch.widget
Class WTourDemo

java.lang.Object
  |
  +--context.arch.BaseObject
        |
        +--context.arch.widget.Widget
              |
              +--context.arch.widget.WPersonPresence
                    |
                    +--context.arch.widget.WTourDemo

public class WTourDemo
extends WPersonPresence
implements AsyncServiceHandler

This class is a context widget that provides information on the presence of a person at a particular demo and their level of interest in the demo. The information is in the form of a demo and a user id. It has the following callbacks: VISIT and INTEREST. It supports polling and subscriptions. Currently it uses WPersonPresence as a means of providing presence. When a user is present at a particular demo, the name of the demo, and relevant demo information is sent to subscribers. As well, a service is called to display a choices menu to the user, to allow them to select their level of interest in the demo. This information is also passed to interested subscribers.

See Also:
WPersonPresence, AsyncServiceHandler

Field Summary
static java.lang.String CLASSNAME
          Name of widget
static int DEFAULT_PORT
          Default port this widget is running on
static java.lang.String DEMO_NAME
          Tag for demo
static java.lang.String DEMO_URL
          Tag for demo url
static java.lang.String DEMOER_URL
          Tag for demoer url
static java.lang.String DISPLAY_DEVICE
          Tag for display device
static java.lang.String INTEREST
          Tag for interest callback
static java.lang.String INTEREST_LEVEL
          Tag for interest level
static java.lang.String MAX_LABEL
          Label for maximum interest
static java.lang.String MAXIMUM_INTEREST
          Tag for maximum interest
static java.lang.String MED_LABEL
          Label for medium interest
static java.lang.String MEDIUM_INTEREST
          Tag for medium interest
static java.lang.String MIN_LABEL
          Label for minimum interest
static java.lang.String MINIMUM_INTEREST
          Tag for minimum interest
 java.lang.String VERSION_NUMBER
          Widget version number
static java.lang.String VISIT
          Tag for visit callback
 
Fields inherited from class context.arch.widget.WPersonPresence
ANIND_OFFICE, CLASSNAME, COMMON_AREA, DANIEL_OFFICE, DEFAULT_PORT, FCL, GREGORY_OFFICE, ibutton, LOCATION, USERID, VERSION_NUMBER
 
Fields inherited from class context.arch.widget.Widget
attributes, attributeTypes, callbacks, CLASS, CurrentOffset, DEFAULT_PORT, id, PUT_DATA, PUT_DATA_REPLY, QUERY, QUERY_ATTRIBUTES, QUERY_ATTRIBUTES_REPLY, QUERY_CALLBACKS, QUERY_CALLBACKS_REPLY, QUERY_REPLY, QUERY_SERVICES, QUERY_SERVICES_REPLY, QUERY_VERSION, QUERY_VERSION_REPLY, services, SPACER, storage, subscribers, TIMESTAMP, UPDATE, UPDATE_AND_QUERY, UPDATE_AND_QUERY_REPLY, VERSION, VERSION_NUMBER
 
Fields inherited from class context.arch.BaseObject
communications, EXIT_OK, handlers, ID, parser, PING, PING_REPLY, serviceHandlers
 
Constructor Summary
WTourDemo(java.lang.String demo, int port, java.lang.String configFile, java.lang.String demoFile)
          Constructor that creates the widget at the given demo and monitors communications on the given port .
WTourDemo(java.lang.String demo, int port, java.lang.String configFile, java.lang.String demoFile, boolean storageFlag)
          Constructor that creates the widget at the given demo and monitors communications on the given port .
WTourDemo(java.lang.String demo, int port, java.lang.String configFile, java.lang.String demoFile, java.lang.String id, boolean storageFlag)
          Constructor that creates the widget at the given demo and monitors communications on the given port It also sets the id of this widget to the given id.
WTourDemo(java.lang.String demo, java.lang.String configFile, java.lang.String demoFile)
          Constructor that creates the widget at the given demo and monitors communications on the DEFAULT_PORT.
WTourDemo(java.lang.String demo, java.lang.String configFile, java.lang.String demoFile, boolean storageFlag)
          Constructor that creates the widget at the given demo and monitors communications on the DEFAULT_PORT.
 
Method Summary
 DataObject asynchronousServiceHandle(java.lang.String id, DataObject result)
          Method for the AsyncServiceHandle interface.
static void main(java.lang.String[] argv)
          Temporary main method to create a widget with demo and port specified by command line arguments
 void notify(java.lang.String event, java.lang.Object data)
          Called by the generator class when a significant event has occurred.
protected  Attributes setAttributes()
          This method implements the abstract method Widget.setAttributes().
protected  Callbacks setCallbacks()
          This method implements the abstract method Widget.setCallbacks().
 
Methods inherited from class context.arch.widget.WPersonPresence
IButtonData2Attributes, queryGenerator, setServices
 
Methods inherited from class context.arch.widget.Widget
addSubscriber, canHandle, canHandle, canHandle, canHandle, executeService, getAttributeType, getCurrentTime, getNewOffset, getNewOffsetNoDelay, isAttribute, isCallback, processCallbackReply, putData, queryAttributes, queryCallbacks, queryServices, queryWidget, removeSubscriber, retrieveData, runUserMethod, runWidgetMethod, sendToSubscribers, setAttribute, store, store, updateWidgetInformation
 
Methods inherited from class context.arch.BaseObject
askInterpreter, decodeData, encodeData, executeAsynchronousWidgetService, executeSynchronousWidgetService, getHostAddress, getId, getVersion, getVersion, getWidgetAttributes, getWidgetCallbacks, getWidgetServices, pingComponent, pollWidget, putDataInWidget, queryVersion, quit, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, retrieveDataFrom, returnPing, runComponentMethod, runMethod, serviceResult, setId, setVersion, subscribeTo, subscribeTo, subscribeTo, subscribeTo, unsubscribeFrom, updateAndPollWidget, userCallback, userRequest, userRequest, userRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_NUMBER

public java.lang.String VERSION_NUMBER
Widget version number

INTEREST_LEVEL

public static final java.lang.String INTEREST_LEVEL
Tag for interest level

DEMO_NAME

public static final java.lang.String DEMO_NAME
Tag for demo

DEMO_URL

public static final java.lang.String DEMO_URL
Tag for demo url

DEMOER_URL

public static final java.lang.String DEMOER_URL
Tag for demoer url

DISPLAY_DEVICE

public static final java.lang.String DISPLAY_DEVICE
Tag for display device

MINIMUM_INTEREST

public static final java.lang.String MINIMUM_INTEREST
Tag for minimum interest

MEDIUM_INTEREST

public static final java.lang.String MEDIUM_INTEREST
Tag for medium interest

MAXIMUM_INTEREST

public static final java.lang.String MAXIMUM_INTEREST
Tag for maximum interest

MIN_LABEL

public static final java.lang.String MIN_LABEL
Label for minimum interest

MED_LABEL

public static final java.lang.String MED_LABEL
Label for medium interest

MAX_LABEL

public static final java.lang.String MAX_LABEL
Label for maximum interest

VISIT

public static final java.lang.String VISIT
Tag for visit callback

INTEREST

public static final java.lang.String INTEREST
Tag for interest callback

CLASSNAME

public static final java.lang.String CLASSNAME
Name of widget

DEFAULT_PORT

public static final int DEFAULT_PORT
Default port this widget is running on
Constructor Detail

WTourDemo

public WTourDemo(java.lang.String demo,
                 java.lang.String configFile,
                 java.lang.String demoFile)
Constructor that creates the widget at the given demo and monitors communications on the DEFAULT_PORT. It also sets the id of this widget to CLASSNAME_. It reads the configFile to determine where a relevant user's server is, so it knows where to display the choices menu. It reads the demoFile to get relevant information about the demo it's monitoring with storage enabled.
Parameters:
demo - Demo the widget is "monitoring"
configFile - File to use for configuration
demoFile - File to use for configuration

WTourDemo

public WTourDemo(java.lang.String demo,
                 java.lang.String configFile,
                 java.lang.String demoFile,
                 boolean storageFlag)
Constructor that creates the widget at the given demo and monitors communications on the DEFAULT_PORT. It also sets the id of this widget to CLASSNAME_. It reads the configFile to determine where a relevant user's server is, so it knows where to display the choices menu. It reads the demoFile to get relevant information about the demo it's monitoring with storage functionality set to storageFlag.
Parameters:
demo - Demo the widget is "monitoring"
configFile - File to use for configuration
demoFile - File to use for configuration
storageFlag - Flag to indicate whether storage is enabled

WTourDemo

public WTourDemo(java.lang.String demo,
                 int port,
                 java.lang.String configFile,
                 java.lang.String demoFile)
Constructor that creates the widget at the given demo and monitors communications on the given port . It also sets the id of this widget to CLASSNAME_. It reads the configFile to determine where a relevant user's server is, so it knows where to display the choices menu. It reads the demoFile to get relevant information about the demo it's monitoring with storage enabled.
Parameters:
demo - Demo the widget is "monitoring"
port - Port to run the widget on
configFile - File to use for configuration
demoFile - File to use for configuration

WTourDemo

public WTourDemo(java.lang.String demo,
                 int port,
                 java.lang.String configFile,
                 java.lang.String demoFile,
                 boolean storageFlag)
Constructor that creates the widget at the given demo and monitors communications on the given port . It also sets the id of this widget to CLASSNAME_. It reads the configFile to determine where a relevant user's server is, so it knows where to display the choices menu. It reads the demoFile to get relevant information about the demo it's monitoring with storage functionality set to storageFlag.
Parameters:
demo - Demo the widget is "monitoring"
port - Port to run the widget on
configFile - File to use for configuration
demoFile - File to use for configuration
storageFlag - Flag to indicate whether storage is enabled

WTourDemo

public WTourDemo(java.lang.String demo,
                 int port,
                 java.lang.String configFile,
                 java.lang.String demoFile,
                 java.lang.String id,
                 boolean storageFlag)
Constructor that creates the widget at the given demo and monitors communications on the given port It also sets the id of this widget to the given id. It reads the configFile to determine where a relevant user's server is, so it knows where to display the choices menu. It reads the demoFile to get relevant information about the demo it's monitoring with storage functionality set to storageFlag
Parameters:
demo - Demo the widget is "monitoring"
port - Port to run the widget on
configFile - File to use for configuration
demoFile - File to use for demo information
id - Widget id
storageFlag - Flag to indicate whether storage is enabled
Method Detail

setCallbacks

protected Callbacks setCallbacks()
This method implements the abstract method Widget.setCallbacks(). It defines the callbacks for the widget as: VISIT with the attributes TIMESTAMP, USERID, DEMO_NAME, DEMO_URL, DEMOER_URL INTEREST with the attributes TIMESTAMP, USERID, DEMO_NAME, INTEREST_LEVEL
Overrides:
setCallbacks in class WPersonPresence
Returns:
the Callbacks used by this widget

setAttributes

protected Attributes setAttributes()
This method implements the abstract method Widget.setAttributes(). It defines the attributes for the widget as: TIMESTAMP, USERID, DEMO_NAME, and INTEREST_LEVEL
Overrides:
setAttributes in class WPersonPresence
Returns:
the Attributes used by this widget

notify

public void notify(java.lang.String event,
                   java.lang.Object data)
Called by the generator class when a significant event has occurred. It creates a DataObject, sends it to its subscribers and stores the data. When a user is present at a demo, the VISIT callback is activated. Then, the display device for this user is determined and a service to display a choices menu is called.
Overrides:
notify in class WPersonPresence
Parameters:
event - Name of the event that has occurred
data - Object containing relevant event data
See Also:
Widget.sendToSubscribers(String, AttributeNameValues), Widget.store(AttributeNameValues)

asynchronousServiceHandle

public DataObject asynchronousServiceHandle(java.lang.String id,
                                            DataObject result)
Method for the AsyncServiceHandle interface. It is called when the DISPLAY_CHOICES service returns some results. This method activates the INTEREST callback and sends subscribers the demo name, user id, timestamp of the callback and level of interest info.
Specified by:
asynchronousServiceHandle in interface AsyncServiceHandler
Parameters:
id - CLASSNAME+userid string
result - DataObject containing the result of the service execution
Returns:
null

main

public static void main(java.lang.String[] argv)
Temporary main method to create a widget with demo and port specified by command line arguments