kaos.core.csi.observe
Class ObserverManagerImpl

java.lang.Object
  extended by kaos.core.csi.observe.ObserverManagerImpl
All Implemented Interfaces:
ObserverManager

public class ObserverManagerImpl
extends java.lang.Object
implements ObserverManager

This class implements the Command interface, which defines sending commands to entities


Nested Class Summary
static class ObserverManagerImpl.MyRemoteKAoSObserver
           
 
Field Summary
protected  Locator _myLocator
           
protected  java.lang.String _nickname
           
protected  java.util.Hashtable _observablesDescriptions
           
protected  java.util.Hashtable _observers
           
protected  QueryRegistration _query
           
protected  TransportSupport _transport
           
protected  java.lang.String _transportName
           
 
Method Summary
 void assertNotLocatable(boolean exp, java.lang.String msg)
           
 void deregisterObserver(KAoSObserver observer, java.lang.String updateType, java.io.Serializable updateCondition, KAoSEntityDescription observableDesc)
          Deregister the given KAoSObserver from the registry of observers asoociated with the KAoSObservable, whose GUID is given.
 void deregisterObserver(KAoSObserver observer, java.lang.String updateType, java.io.Serializable updateCondition, java.lang.String observableGUID)
          Deregister the given KAoSObserver from the registry of observers asoociated with the KAoSObservable, whose GUID is given.
 boolean equals(java.lang.Object obj)
          Two agents are equal if their respective hash codes are equal.
 java.lang.String getID()
           
static ObserverManager getInstance(java.lang.String transportName)
          Retrieve an instance of ObserverManager.
static ObserverManager getInstance(java.lang.String transportName, java.lang.String nickName)
          Retrieve a reference to the ObserverManager.
 int hashCode()
          Determines the hash code for the AgentUsecase.
static void main(java.lang.String[] args)
           
protected  void printDebugString(java.lang.String msg, int loggerDisplayLevel)
           
 void receiveMessage(TransportMessage tmsg)
          Implements the receiveMessage method mandated by the MessageListener interface.
 void registerObserver(KAoSObserver observer, java.lang.String updateType, java.io.Serializable updateCondition, KAoSEntityDescription observableDesc)
          Register the given KAoSObserver with the KAoSObservable, whose KAoSEntityDescription is given, for updates described by the updateType and updateConstraints.
 void registerObserver(KAoSObserver observer, java.lang.String updateType, java.io.Serializable updateCondition, java.lang.String observableGUID)
          Register the given KAoSObserver with the KAoSObservable, whose GUID is given for updates described by the updateType and updateConditions.
 void registerObserver(KAoSObserver observer, java.lang.String updateType, java.io.Serializable updateCondition, java.lang.String observableGUID, java.lang.String brokerGUID)
          Register the given KAoSObserver with the KAoSObservable, whose GUID is given for updates described by the updateType and updateConditions.
protected  MethodCallResultMsg satisfyRequest(MethodCallRequestMsg requestMsg)
           
 void updateObserver(java.lang.String observerID, java.lang.String observableID, java.lang.String updateType, java.lang.Object updateCondition, java.lang.Object update)
          Receive an update from MyRemoteKAoSObserver
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_myLocator

protected Locator _myLocator

_nickname

protected java.lang.String _nickname

_query

protected QueryRegistration _query

_transport

protected TransportSupport _transport

_transportName

protected java.lang.String _transportName

_observers

protected java.util.Hashtable _observers

_observablesDescriptions

protected java.util.Hashtable _observablesDescriptions
Method Detail

getInstance

public static ObserverManager getInstance(java.lang.String transportName)
                                   throws java.lang.Exception
Retrieve an instance of ObserverManager.

Returns:
a singleton, ObserverManager.
Throws:
java.lang.Exception

getInstance

public static ObserverManager getInstance(java.lang.String transportName,
                                          java.lang.String nickName)
                                   throws java.lang.Exception
Retrieve a reference to the ObserverManager.

Parameters:
transportName - is a String containing the name of the transport to use by the ObserverManager.
nickName - is a String containing the nick name of the ObserverManager that may be used by certain transport implementations, or null if not required by the transport.
Returns:
a reference to the ObserverManager
Throws:
java.lang.Exception

registerObserver

public void registerObserver(KAoSObserver observer,
                             java.lang.String updateType,
                             java.io.Serializable updateCondition,
                             java.lang.String observableGUID)
                      throws NotLocatableException,
                             TransportFailure
Register the given KAoSObserver with the KAoSObservable, whose GUID is given for updates described by the updateType and updateConditions.

Specified by:
registerObserver in interface ObserverManager
Parameters:
observer - KAoSObserver requesting registration for updates.
updateType - String indicating type of update the KAoSObserver is interested in.
updateCondition - Serializable describing the conditions under which to send the update.
observableGUID - String containing the GUID of the KAoSObservable to register with.
Throws:
NotLocatableException - when the KAoSObservable cannot be located.
TransportFailure - when transport services fails.

registerObserver

public void registerObserver(KAoSObserver observer,
                             java.lang.String updateType,
                             java.io.Serializable updateCondition,
                             KAoSEntityDescription observableDesc)
                      throws NotLocatableException,
                             TransportFailure
Register the given KAoSObserver with the KAoSObservable, whose KAoSEntityDescription is given, for updates described by the updateType and updateConstraints.

Specified by:
registerObserver in interface ObserverManager
Parameters:
observer - KAoSObserver registering with for updates.
updateType - String indicating type of update the KAoSObserver is interested in.
updateCondition - Object describing the conditions under which to send the update.
Throws:
NotLocatableException - when the KAoSObservable cannot be located.
TransportFailure - when transport services fail.

registerObserver

public void registerObserver(KAoSObserver observer,
                             java.lang.String updateType,
                             java.io.Serializable updateCondition,
                             java.lang.String observableGUID,
                             java.lang.String brokerGUID)
                      throws NotLocatableException,
                             TransportFailure
Register the given KAoSObserver with the KAoSObservable, whose GUID is given for updates described by the updateType and updateConditions.

Specified by:
registerObserver in interface ObserverManager
Parameters:
observer - KAoSObserver requesting registration for updates.
updateType - String indicating type of update the KAoSObserver is interested in.
updateCondition - Serializable describing the conditions under which to send the update.
observableGUID - String containing the GUID of the KAoSObservable to register with.
brokerID - String containing the GUID of the broker, through which
Throws:
NotLocatableException - when the KAoSObservable or broker cannot be located.
TransportFailure - when transport services fail. the rgistration will be processed.

deregisterObserver

public void deregisterObserver(KAoSObserver observer,
                               java.lang.String updateType,
                               java.io.Serializable updateCondition,
                               java.lang.String observableGUID)
                        throws NotLocatableException,
                               TransportFailure
Deregister the given KAoSObserver from the registry of observers asoociated with the KAoSObservable, whose GUID is given.

Specified by:
deregisterObserver in interface ObserverManager
Parameters:
observer - KAoSObserver deregistering.
updateType - String indicating type of update the KAoSObserver is no longer interested in.
updateCondition - Serializable containing the condition the KAoSObserver is no longer interested in.
observableGUID - String specifying the GUID of the observable, from which to deregister for the given update type.
Throws:
NotLocatableException - when the KAoSObservable cannot be located.
TransportFailure - when transport services fail.

deregisterObserver

public void deregisterObserver(KAoSObserver observer,
                               java.lang.String updateType,
                               java.io.Serializable updateCondition,
                               KAoSEntityDescription observableDesc)
                        throws NotLocatableException,
                               TransportFailure
Deregister the given KAoSObserver from the registry of observers asoociated with the KAoSObservable, whose GUID is given.

Specified by:
deregisterObserver in interface ObserverManager
Parameters:
observer - KAoSObserver deregistering.
updateType - String indicating type of update the KAoSObserver is no longer interested in.
updateCondition - Serializable containing the condition the KAoSObserver is no longer interested in.
observableDesc - KAoSEntityDescription of the observable, from which to deregister for the given update type.
Throws:
NotLocatableException - when the KAoSObservable cannot be located.
TransportFailure - when transport services fail.

receiveMessage

public void receiveMessage(TransportMessage tmsg)
Implements the receiveMessage method mandated by the MessageListener interface. This method prints the incoming TransportMessage to System.out.

See Also:
MessageListener, TransportMessage, "JAS Specification, Section(s) 3.4.2, 4.7.2"

equals

public boolean equals(java.lang.Object obj)
Two agents are equal if their respective hash codes are equal.

Overrides:
equals in class java.lang.Object
Returns:
true if obj equals this AgentUsecase.
See Also:
hashCode(), "JAS Specification, Section(s) 4.7.2"

hashCode

public int hashCode()
Determines the hash code for the AgentUsecase. The AgentUsecase hash code is simply the hash code of the represented agents AgentName. If the AgentName field has not yet been set, then the hash code is found from super.hashCode() .

Overrides:
hashCode in class java.lang.Object
Returns:
int the hashCode for this AgentUsecase.
See Also:
AgentName#hashCode, Object.hashCode(), "JAS Specification, Section(s) 4.7.2"

updateObserver

public void updateObserver(java.lang.String observerID,
                           java.lang.String observableID,
                           java.lang.String updateType,
                           java.lang.Object updateCondition,
                           java.lang.Object update)
Receive an update from MyRemoteKAoSObserver

Parameters:
observerID - The ID of the observer to inform
observableID - String identifying the KAoSObservable sending the update.
updateType - String indicating type of update.
updateCondition - Object indicating the update condition.
update - Object containing the update.

getID

public java.lang.String getID()

satisfyRequest

protected MethodCallResultMsg satisfyRequest(MethodCallRequestMsg requestMsg)

assertNotLocatable

public void assertNotLocatable(boolean exp,
                               java.lang.String msg)
                        throws NotLocatableException
Throws:
NotLocatableException - if exp is true.

printDebugString

protected void printDebugString(java.lang.String msg,
                                int loggerDisplayLevel)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception