context.arch.subscriber
Class AbstractSubscriber

java.lang.Object
  extended bycontext.arch.subscriber.AbstractSubscriber
Direct Known Subclasses:
ClientSideSubscriber, DiscovererSubscriber, Subscriber

public abstract class AbstractSubscriber
extends java.lang.Object

Interface for Subscriber classes that may be stored in a Subscribers object. A subscriber is defined by: id+hostname+port. It specifies a callback name it subscribes to and a tag (subscriber tag as alias for the callback).

Author:
Agathe

Field Summary
static java.lang.String ADD_SUBSCRIBER
          Tag to indicate message is for adding a subscriber
static java.lang.String CALLBACK_NAME
          Tag for callback (on widget side)
static java.lang.String CALLBACK_TAG
          Tag for callback tag (on subscriber side)
static java.lang.String CLIENT_BASEOBJECT_ID
          Tag for the client side BaseObject id
static java.lang.String HOSTNAME
          Tag for host machine of component
static int MAX_ERRORS
          Maximum number of consecutive communication errors to be tolerated
static java.lang.String PORT
          Tag for port number of component
static java.lang.String REMOVE_SUBSCRIBER
          Tag to indicate message is for removing a subscriber
static java.lang.String SUBSCRIBER
          Tag for a subscriber
static java.lang.String SUBSCRIBER_ID
          Tag for subscription id
static java.lang.String SUBSCRIBER_TYPE
          Tag for subscriber type
static java.lang.String SUBSCRIPTION_CALLBACK
          Tag to indicate message is a subscription callback
static java.lang.String SUBSCRIPTION_CALLBACK_REPLY
          Tag to indicate message is the reply to a subscription callback message
static java.lang.String SUBSCRIPTION_REPLY
          Tag to indicate message is a subscription reply
 
Constructor Summary
AbstractSubscriber(DataObject data)
          Basic constructor that creates a subscriber object from a DataObject.
AbstractSubscriber(java.lang.String subscriberType)
           
 
Method Summary
 void addError()
          Increment the error counter
static AbstractSubscriber dataObjectToAbstractSubscriber(DataObject data)
          This method return a Subscriber object based on the type specified in the SUBSCRIBER tag.
 java.lang.String getBaseObjectId()
           
 int getErrors()
          Returns the number of consecutive errors in trying to communicate with this subscriber
 java.lang.String getSubscriberHostName()
          Returns the name of the subscriber's host computer
 int getSubscriberPort()
          Returns the port number to send info to
 java.lang.String getSubscriptionCallback()
          Returns the subscriber callback that the subscriber registered
 java.lang.String getSubscriptionId()
          Returns the id of the subscriber
 void resetErrors()
          Reset the error counter
protected  void setBaseObjectId(java.lang.String id)
           
 void setSubscriberHostname(java.lang.String subHostname)
          Sets the name of the subscriber's host computer
 void setSubscriberPort(int subPort)
          Sets the port number to send info to
 void setSubscriptionCallback(java.lang.String subscriptionCallback)
          Sets the subscriber callback that the subscriber wants to register for
 void setSubscriptionId(java.lang.String id)
          Sets the id of the subscriber
 DataObject toDataObject()
          This method converts the subscriber info to a DataObject
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUBSCRIBER

public static final java.lang.String SUBSCRIBER
Tag for a subscriber

See Also:
Constant Field Values

HOSTNAME

public static final java.lang.String HOSTNAME
Tag for host machine of component

See Also:
Constant Field Values

PORT

public static final java.lang.String PORT
Tag for port number of component

See Also:
Constant Field Values

SUBSCRIBER_ID

public static final java.lang.String SUBSCRIBER_ID
Tag for subscription id

See Also:
Constant Field Values

CLIENT_BASEOBJECT_ID

public static final java.lang.String CLIENT_BASEOBJECT_ID
Tag for the client side BaseObject id

See Also:
Constant Field Values

SUBSCRIPTION_REPLY

public static final java.lang.String SUBSCRIPTION_REPLY
Tag to indicate message is a subscription reply

See Also:
Constant Field Values

CALLBACK_TAG

public static final java.lang.String CALLBACK_TAG
Tag for callback tag (on subscriber side)

See Also:
Constant Field Values

CALLBACK_NAME

public static final java.lang.String CALLBACK_NAME
Tag for callback (on widget side)

See Also:
Constant Field Values

SUBSCRIPTION_CALLBACK

public static final java.lang.String SUBSCRIPTION_CALLBACK
Tag to indicate message is a subscription callback

See Also:
Constant Field Values

ADD_SUBSCRIBER

public static final java.lang.String ADD_SUBSCRIBER
Tag to indicate message is for adding a subscriber

See Also:
Constant Field Values

REMOVE_SUBSCRIBER

public static final java.lang.String REMOVE_SUBSCRIBER
Tag to indicate message is for removing a subscriber

See Also:
Constant Field Values

SUBSCRIPTION_CALLBACK_REPLY

public static final java.lang.String SUBSCRIPTION_CALLBACK_REPLY
Tag to indicate message is the reply to a subscription callback message

See Also:
Constant Field Values

SUBSCRIBER_TYPE

public static final java.lang.String SUBSCRIBER_TYPE
Tag for subscriber type

See Also:
Constant Field Values

MAX_ERRORS

public static final int MAX_ERRORS
Maximum number of consecutive communication errors to be tolerated

See Also:
Constant Field Values
Constructor Detail

AbstractSubscriber

public AbstractSubscriber(java.lang.String subscriberType)

AbstractSubscriber

public AbstractSubscriber(DataObject data)
Basic constructor that creates a subscriber object from a DataObject. The DataObject must contain a tag

Parameters:
data - DataObject containing the subscriber info
Method Detail

dataObjectToAbstractSubscriber

public static AbstractSubscriber dataObjectToAbstractSubscriber(DataObject data)
This method return a Subscriber object based on the type specified in the SUBSCRIBER tag.

Parameters:
data - DataObject containing the subscriber info

getSubscriptionId

public java.lang.String getSubscriptionId()
Returns the id of the subscriber

Returns:
the subscriber id

setSubscriptionId

public void setSubscriptionId(java.lang.String id)
Sets the id of the subscriber

Parameters:
id - ID of the subscriber

getSubscriberHostName

public java.lang.String getSubscriberHostName()
Returns the name of the subscriber's host computer

Returns:
the host name of the subscriber

setSubscriberHostname

public void setSubscriberHostname(java.lang.String subHostname)
Sets the name of the subscriber's host computer


getSubscriberPort

public int getSubscriberPort()
Returns the port number to send info to

Returns:
the port number of the subscriber

setSubscriberPort

public void setSubscriberPort(int subPort)
Sets the port number to send info to


getSubscriptionCallback

public java.lang.String getSubscriptionCallback()
Returns the subscriber callback that the subscriber registered

Returns:
the subscriptionCallback of the subscriber

setSubscriptionCallback

public void setSubscriptionCallback(java.lang.String subscriptionCallback)
Sets the subscriber callback that the subscriber wants to register for


addError

public void addError()
Increment the error counter


resetErrors

public void resetErrors()
Reset the error counter


getErrors

public int getErrors()
Returns the number of consecutive errors in trying to communicate with this subscriber

Returns:
number of consecutive communications errors for this subscriber

toDataObject

public DataObject toDataObject()
This method converts the subscriber info to a DataObject

Returns:
Subscriber object converted to a DataObject

getBaseObjectId

public java.lang.String getBaseObjectId()

setBaseObjectId

protected void setBaseObjectId(java.lang.String id)

toString

public java.lang.String toString()