context.arch.server
Class STourId

java.lang.Object
  |
  +--context.arch.BaseObject
        |
        +--context.arch.widget.Widget
              |
              +--context.arch.server.Server
                    |
                    +--context.arch.server.STourId

public class STourId
extends Server

This class implements a user id server for a tour guide app. It should subscribe to all the widgets that could provide information about its user with regards to a tour.

See Also:
Server

Field Summary
static java.lang.String CLASSNAME
          Name of server
static java.lang.String USERID
          Tag to indicate user id (our key)
 
Fields inherited from class context.arch.server.Server
DEFAULT_PORT, widgets
 
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
STourId(int port, java.lang.String userid, boolean storageFlag, WidgetHandles widgets, java.lang.String configFile)
          Constructor that creates a user server for user id on the specified port.
STourId(int port, java.lang.String userid, WidgetHandles widgets, java.lang.String configFile)
          Constructor that creates a user server for user id on the specified port.
STourId(java.lang.String userid, boolean storageFlag, WidgetHandles widgets, java.lang.String configFile)
          Constructor that creates a user server for user id on the DEFAULT_PORT.
STourId(java.lang.String userid, WidgetHandles widgets, java.lang.String configFile)
          Constructor that creates a user server for user id on the DEFAULT_PORT.
 
Method Summary
static void main(java.lang.String[] argv)
          Main method to create a server with name, port and widgets specified by command line arguments.
protected  AttributeNameValues queryGenerator()
          This abstract method is called when the widget wants to get the latest generator info.
protected  Conditions setConditions()
          This method sets the conditions to apply to the server's subscriptions.
protected  Attributes setServerAttributes()
          This method sets the attributes for the server - those that are specific to the server, and not contained in the widgets it subscribes to.
protected  Callbacks setServerCallbacks()
          This method set the callbacks for a server - those that are specific to the server, and not contained in the widgets it subscribes to.
protected  Services setServerServices()
          This method set the services for a server - those that are specific to the server, and not contained in the widgets it subscribes to.
 
Methods inherited from class context.arch.server.Server
handle, queryWidget, serverSetup, setAttributes, setCallbacks, setServices, setWidgets, startSubscriptions, storeAttributeNameValues
 
Methods inherited from class context.arch.widget.Widget
addSubscriber, canHandle, canHandle, canHandle, canHandle, executeService, getAttributeType, getCurrentTime, getNewOffset, getNewOffsetNoDelay, isAttribute, isCallback, notify, processCallbackReply, putData, queryAttributes, queryCallbacks, queryServices, 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

CLASSNAME

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

USERID

public static final java.lang.String USERID
Tag to indicate user id (our key)
Constructor Detail

STourId

public STourId(int port,
               java.lang.String userid,
               WidgetHandles widgets,
               java.lang.String configFile)
Constructor that creates a user server for user id on the specified port. This server monitors the set of widgets in widgets and the tour guide widgets specified in configFile. This latter set of widgets include TourRegistration, TourDemo, and TourEnd widgets with storage enabled.
Parameters:
port - Port this server is listening on
userid - User id this server is attached to
widgets - Set of widgets this server monitors
configFile - File to use for configuration

STourId

public STourId(int port,
               java.lang.String userid,
               boolean storageFlag,
               WidgetHandles widgets,
               java.lang.String configFile)
Constructor that creates a user server for user id on the specified port. This server monitors the set of widgets in widgets and the tour guide widgets specified in configFile. This latter set of widgets include TourRegistration, TourDemo, and TourEnd widgets with storage functionality set to storageFlag
Parameters:
port - Port this server is listening on
userid - User id this server is attached to
widgets - Set of widgets this server monitors
configFile - File to use for configuration
storageFlag - Flag to indicate whether storage is enabled or not

STourId

public STourId(java.lang.String userid,
               WidgetHandles widgets,
               java.lang.String configFile)
Constructor that creates a user server for user id on the DEFAULT_PORT. This server monitors the set of widgets in widgets and the tour guide widgets specified in configFile. This latter set of widgets include TourRegistration, TourDemo, and TourEnd widgets with storage enabled.
Parameters:
userid - User id this server is attached to
widgets - Set of widgets this server monitors
configFile - File to use for configuration

STourId

public STourId(java.lang.String userid,
               boolean storageFlag,
               WidgetHandles widgets,
               java.lang.String configFile)
Constructor that creates a user server for user id on the DEFAULT_PORT. This server monitors the set of widgets in widgets and the tour guide widgets specified in configFile. This latter set of widgets include TourRegistration, TourDemo, and TourEnd widgets with storage functionality set to storageFlag.
Parameters:
userid - User id this server is attached to
widgets - Set of widgets this server monitors
configFile - File to use for configuration
storageFlag - Flag to indicate whether storage is enabled or not
Method Detail

queryGenerator

protected AttributeNameValues queryGenerator()
This abstract method is called when the widget wants to get the latest generator info. Maybe we should query our widgets here?
Overrides:
queryGenerator in class Widget
Returns:
Attributes containing the latest generator information

setServerAttributes

protected Attributes setServerAttributes()
This method sets the attributes for the server - those that are specific to the server, and not contained in the widgets it subscribes to. Currently, there are none.
Overrides:
setServerAttributes in class Server
Returns:
Attributes object containing the server-specific attributes

setServerCallbacks

protected Callbacks setServerCallbacks()
This method set the callbacks for a server - those that are specific to the server, and not contained in the widgets it subscribes to. Currently, there are none.
Overrides:
setServerCallbacks in class Server
Returns:
Callbacks object containing the server-specific callbacks

setServerServices

protected Services setServerServices()
This method set the services for a server - those that are specific to the server, and not contained in the widgets it subscribes to. Currently, there are none.
Overrides:
setServerServices in class Server
Returns:
Services object containing the server-specific services

setConditions

protected Conditions setConditions()
This method sets the conditions to apply to the server's subscriptions. The condition for the User Server is USERID='userid'
Overrides:
setConditions in class Server
Returns:
Conditions containing condition info for server subscriptions

main

public static void main(java.lang.String[] argv)
Main method to create a server with name, port and widgets specified by command line arguments. Each widget is specified by: host, port, id