kaos.core.csi.observe
Class ObserverManagerImpl

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

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 static boolean __INITIALIZED
           
protected static ObserverManager __INSTANCE
           
protected static java.lang.String _DEREGISTER_OBSERVER
           
protected  Locator _myLocator
           
protected  java.lang.String _nickname
           
protected static java.lang.String _NICKNAME_ROOT
           
protected  java.util.Hashtable _observablesDescriptions
           
protected  java.util.Hashtable _observers
           
protected  QueryRegistration _query
           
protected static java.lang.String _REGISTER_OBSERVER
           
protected  TransportSupport _transport
           
protected  java.lang.String _transportName
           
 
Constructor Summary
protected ObserverManagerImpl()
           
 
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.
protected  void initialize(java.lang.String transportName, java.lang.String nickName)
           
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 registerKAoSExtensionComponentObserver(java.lang.String repType, java.lang.String ontType, KAoSObserver observer, java.lang.String updateType, java.io.Serializable updateCondition, KAoSEntityDescription entityDesc)
          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, 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

__INSTANCE

protected static final ObserverManager __INSTANCE

__INITIALIZED

protected static boolean __INITIALIZED

_NICKNAME_ROOT

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

_REGISTER_OBSERVER

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

_DEREGISTER_OBSERVER

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

_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
Constructor Detail

ObserverManagerImpl

protected ObserverManagerImpl()
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.

registerKAoSExtensionComponentObserver

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

Specified by:
registerKAoSExtensionComponentObserver 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,
                             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.
observableDesc - KAoSEntityDescription describing the observable.
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.
brokerGUID - 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:
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)

initialize

protected void initialize(java.lang.String transportName,
                          java.lang.String nickName)
                   throws java.lang.Exception
Throws:
java.lang.Exception

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