jimm.twice.ice
Class Syndicator

java.lang.Object
  extended byjimm.twice.ice.IceMachine
      extended byjimm.twice.ice.Syndicator
Direct Known Subclasses:
TwICESyndicator

public abstract class Syndicator
extends IceMachine

The syndicator class implements behavior common to all syndicators. Subclasses need to manage subscribers and worry about HTTP.

We don't hold on to a list of subscribers because doing so would depend on the persistence mechanism used. For example, we may not want to hold a list of all subscribers in memory.

Author:
Jim Menard, jimm@io.com

Field Summary
protected static java.lang.String LOG_FILE_PREFIX
           
protected static java.lang.String OFFER_SUBSCRIPTION_ID
           
protected  int packageItemId
           
protected static int UNKNOWN_SUBSCRIPTION
           
 
Fields inherited from class jimm.twice.ice.IceMachine
DEFAULT_LOGGER_PREFIX, domain, loggerPrefix, party, PING_RESPONSE_STRING
 
Constructor Summary
Syndicator(java.lang.String domain, Party party)
          Constructor.
 
Method Summary
abstract  Cancellation cancel(Cancel cancelReq)
           
protected abstract  PackageType generateItems(java.lang.String subscriptionId, java.lang.String currentState)
          Generates the ice item(s) and/or item ref(s) that satisfy the specified subscription id and builds a package containing them.
protected abstract  OfferType[] generateOffers(java.lang.String subscriberId)
          Generates the ice-offer(s) that fill a catalog
protected abstract  java.lang.String getCatalogName()
          Returns the name of the catalog sent in response to an get-catalog request.
abstract  PackageType getPackage(GetPackageType getPackageReq)
           
abstract  Packages getPackages(GetPackages getPackagesReq)
           
abstract  StatusType getStatus(GetStatus getStatusReq)
           
protected abstract  java.lang.String getSubscriberURL(java.lang.String subscriberId)
          Returns the URL of the specified subscriber (or null if it is unknown).
abstract  void handlePing()
           
protected abstract  boolean hasSubscriber(java.lang.String subscriberId)
          Returns true if subscriberId is known.
abstract  void packageConfirmations(PackageConfirmationsType packageConfirmationReq)
           
abstract  SubscriptionType subscribe(Subscribe subscribeReq)
           
 
Methods inherited from class jimm.twice.ice.IceMachine
createIceHeader, getDomain, getLocationURL, getName, getParty, getRole, getUuid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_FILE_PREFIX

protected static final java.lang.String LOG_FILE_PREFIX
See Also:
Constant Field Values

UNKNOWN_SUBSCRIPTION

protected static final int UNKNOWN_SUBSCRIPTION
See Also:
Constant Field Values

OFFER_SUBSCRIPTION_ID

protected static final java.lang.String OFFER_SUBSCRIPTION_ID
See Also:
Constant Field Values

packageItemId

protected int packageItemId
Constructor Detail

Syndicator

public Syndicator(java.lang.String domain,
                  Party party)
Constructor. The log file prefix is set to LOG_FILE_PREFIX.

Parameters:
domain - the machine's domain, used for generating ids 'n stuff
party - this machine's syndicator or subscriber information
Method Detail

hasSubscriber

protected abstract boolean hasSubscriber(java.lang.String subscriberId)
Returns true if subscriberId is known. This method is abstract because we have ... er ... abstracted the persistence mechanism out of this layer.

Parameters:
subscriberId - a subscriber's UUID

getSubscriberURL

protected abstract java.lang.String getSubscriberURL(java.lang.String subscriberId)
Returns the URL of the specified subscriber (or null if it is unknown). This method is abstract because we have abstracted the persistence mechanism out of this layer.

Parameters:
subscriberId - a subscriber's UUID
Returns:
a URL string

handlePing

public abstract void handlePing()
                         throws StatusCode
Throws:
StatusCode

subscribe

public abstract SubscriptionType subscribe(Subscribe subscribeReq)
                                    throws SubscriptionFault
Throws:
SubscriptionFault

cancel

public abstract Cancellation cancel(Cancel cancelReq)
                             throws StatusCode
Throws:
StatusCode

getStatus

public abstract StatusType getStatus(GetStatus getStatusReq)
                              throws StatusCode
Throws:
StatusCode

packageConfirmations

public abstract void packageConfirmations(PackageConfirmationsType packageConfirmationReq)
                                   throws StatusCode
Throws:
StatusCode

getPackages

public abstract Packages getPackages(GetPackages getPackagesReq)
                              throws StatusCode
Throws:
StatusCode

getPackage

public abstract PackageType getPackage(GetPackageType getPackageReq)
                                throws StatusCode
Throws:
StatusCode

generateItems

protected abstract PackageType generateItems(java.lang.String subscriptionId,
                                             java.lang.String currentState)
                                      throws StatusCode
Generates the ice item(s) and/or item ref(s) that satisfy the specified subscription id and builds a package containing them.

Parameters:
subscriptionId - the subscription id
currentState - the sender's subscription's current state
Returns:
the ICE package containing the items
Throws:
StatusCode

getCatalogName

protected abstract java.lang.String getCatalogName()
Returns the name of the catalog sent in response to an get-catalog request.

Returns:
a value for the name attribute

generateOffers

protected abstract OfferType[] generateOffers(java.lang.String subscriberId)
                                       throws StatusCode
Generates the ice-offer(s) that fill a catalog

Parameters:
subscriberId - the subscriber's UUID
Returns:
array of offers
Throws:
StatusCode