context.arch.server
Class SUser

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

public class SUser
extends Server

This class implements a user server. It should subscribe to all the widgets that could provide information about its user.

See Also:
Server

Field Summary
static java.lang.String CLASSNAME
          Name of server
static java.lang.String USERNAME
          Tag to indicate user name (our key)
 java.lang.String VERSION_NUMBER
          Widget version number
 
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
SUser(int port, java.lang.String name, boolean storageFlag, WidgetHandles widgets)
          Constructor that creates a user server for the user name on the specified port.
SUser(int port, java.lang.String name, WidgetHandles widgets)
          Constructor that creates a user server for the user name on the specified port.
SUser(java.lang.String name, boolean storageFlag, WidgetHandles widgets)
          Constructor that creates a user server for user name on the DEFAULT_PORT.
SUser(java.lang.String name, WidgetHandles widgets)
          Constructor that creates a user server for user name 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

VERSION_NUMBER

public java.lang.String VERSION_NUMBER
Widget version number

CLASSNAME

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

USERNAME

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

SUser

public SUser(int port,
             java.lang.String name,
             WidgetHandles widgets)
Constructor that creates a user server for the user name on the specified port. This server monitors the set of widgets in widgets with storage enabled.
Parameters:
name - User name this server is attached to
port - Port this server is listening on
widgets - Set of widgets this server monitors

SUser

public SUser(int port,
             java.lang.String name,
             boolean storageFlag,
             WidgetHandles widgets)
Constructor that creates a user server for the user name on the specified port. This server monitors the set of widgets in widgets with storage functionality set to storageFlag
Parameters:
name - User name this server is attached to
port - Port this server is listening on
widgets - Set of widgets this server monitors
storageFlag - Flag to indicate whether storage is enabled or not

SUser

public SUser(java.lang.String name,
             WidgetHandles widgets)
Constructor that creates a user server for user name on the DEFAULT_PORT. This server monitors the set of widgets in widgets with storage enabled.
Parameters:
name - User name this server is attached to
widgets - Set of widgets this server monitors

SUser

public SUser(java.lang.String name,
             boolean storageFlag,
             WidgetHandles widgets)
Constructor that creates a user server for user name on the DEFAULT_PORT. This server monitors the set of widgets in widgets with storage functionality set to storageFlag.
Parameters:
name - User name this server is attached to
widgets - Set of widgets this server monitors
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 USERNAME='username'
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