ibspan.tss.agents.sha.history
Class HistorySubscriptionManager

java.lang.Object
  extended by ibspan.tss.agents.sha.history.HistorySubscriptionManager
All Implemented Interfaces:
NewEventHandler, SubscriptionResponder.SubscriptionManager

public class HistorySubscriptionManager
extends Object
implements SubscriptionResponder.SubscriptionManager, NewEventHandler

This class deals with the registration/deregistration of subscriptions for packs of events, delegated to it by SubscriptionManager object and creates notifications containing information about new events., when required by HistoryLogger. This functionality result from the interface this class implements.

The class uses internal not-persistent knowledge-base for storing constraints of registered subscription and every time this contraints of particular subscription are fulfilled (number of new events is equal for which the subscriber subscribed), then sends notification message to the appriopriate subscriber.

Author:
Maciej Gawinecki
See Also:
SubscriptionResponder.SubscriptionManager, HistoryLogger

Constructor Summary
HistorySubscriptionManager(Agent a, HistoryDAO daoHistory)
          Constructs HistorySubscriptionManger belongs to.
 
Method Summary
 boolean deregister(SubscriptionResponder.Subscription sub)
          Deregister a Subscription object from the knowledge-base..
 void handleNewEvent(Event e)
          Notifies subscriber every time number events, together with the passed as argument, is equal to the number contrained by the subscriber in registration message.
 boolean register(SubscriptionResponder.Subscription sub)
          Register a new Subscription object in the knowledge-base.
 void setContentManager(ContentManager cm)
          Set the content manager for this component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistorySubscriptionManager

public HistorySubscriptionManager(Agent a,
                                  HistoryDAO daoHistory)
Constructs HistorySubscriptionManger belongs to.

Parameters:
a - is the agent this HistorySubscriptionManger belongs to.
daoHistory - DAO object of History model, which will be used to extract information about events, the subscriber is willing to be informed about.
Method Detail

setContentManager

public void setContentManager(ContentManager cm)
Set the content manager for this component.

Parameters:
cm - is a content manager.

deregister

public boolean deregister(SubscriptionResponder.Subscription sub)
                   throws FailureException
Deregister a Subscription object from the knowledge-base..

Specified by:
deregister in interface SubscriptionResponder.SubscriptionManager
Parameters:
s - The Subscription object to be registered
Returns:
The boolean value returned by this method provides an indication to the SubscriptionResponder about whether or not an INFORM message should be sent back to the initiator. The default implementation of the handleCancel() method of the SubscriptionResponder ignores this indication, but programmers can override it.
Throws:
FailureException

register

public boolean register(SubscriptionResponder.Subscription sub)
                 throws RefuseException,
                        NotUnderstoodException
Register a new Subscription object in the knowledge-base.

Specified by:
register in interface SubscriptionResponder.SubscriptionManager
Parameters:
s - The Subscription object to be registered
Returns:
The boolean value returned by this method provides an indication to the SubscriptionResponder about whether or not an AGREE message should be sent back to the initiator. The default implementation of the prepareResponse method of the SubscriptionResponder ignores this indication, but programmers can override it.
Throws:
RefuseException
NotUnderstoodException

handleNewEvent

public void handleNewEvent(Event e)
Notifies subscriber every time number events, together with the passed as argument, is equal to the number contrained by the subscriber in registration message.

Specified by:
handleNewEvent in interface NewEventHandler
Parameters:
e - is the event to be handled.