org.cougaar.core.relay
Class SimpleRelayBase

java.lang.Object
  extended by org.cougaar.core.relay.SimpleRelayBase
All Implemented Interfaces:
java.io.Serializable, SimpleRelay, UniqueObject
Direct Known Subclasses:
SimpleRelaySource, SimpleRelayTarget

public abstract class SimpleRelayBase
extends java.lang.Object
implements SimpleRelay, java.io.Serializable

Abstract base class for SimpleRelay implementations.

See Also:
Serialized Form

Field Summary
protected  java.lang.Object query
           
protected  java.lang.Object reply
           
protected  MessageAddress source
           
protected  MessageAddress target
           
protected  UID uid
           
 
Constructor Summary
SimpleRelayBase(UID uid, MessageAddress source, MessageAddress target)
           
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Object getQuery()
          Get the query contents
 java.lang.Object getReply()
          Get the remote reply to the query, if any.
 MessageAddress getSource()
          The agent that created the query
 MessageAddress getTarget()
          The agent that will set the reply
 UID getUID()
           
 int hashCode()
           
 void setQuery(java.lang.Object query)
          Change the query, which is optional.
 void setReply(java.lang.Object reply)
          Change the reply, which is optional.
 void setUID(UID uid)
          Set the UID of this UniqueObject, which may throw a RuntimeException if the UID is already set.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

uid

protected final UID uid

source

protected final MessageAddress source

target

protected final MessageAddress target

query

protected java.lang.Object query

reply

protected java.lang.Object reply
Constructor Detail

SimpleRelayBase

public SimpleRelayBase(UID uid,
                       MessageAddress source,
                       MessageAddress target)
Method Detail

getUID

public UID getUID()
Specified by:
getUID in interface SimpleRelay
Specified by:
getUID in interface UniqueObject
Returns:
the UID of this UniqueObject.

setUID

public void setUID(UID uid)
Description copied from interface: UniqueObject
Set the UID of this UniqueObject, which may throw a RuntimeException if the UID is already set.

Specified by:
setUID in interface SimpleRelay
Specified by:
setUID in interface UniqueObject

getSource

public MessageAddress getSource()
Description copied from interface: SimpleRelay
The agent that created the query

Specified by:
getSource in interface SimpleRelay

getTarget

public MessageAddress getTarget()
Description copied from interface: SimpleRelay
The agent that will set the reply

Specified by:
getTarget in interface SimpleRelay

getQuery

public java.lang.Object getQuery()
Description copied from interface: SimpleRelay
Get the query contents

Specified by:
getQuery in interface SimpleRelay

setQuery

public void setQuery(java.lang.Object query)
Description copied from interface: SimpleRelay
Change the query, which is optional.

Only the agent who's address matches "getSource()" may call this method, which must be followed by a blackboard "publishChange" to resend the query to the target.

Note that the relay implementation may batch changes and only send the latest change.

Specified by:
setQuery in interface SimpleRelay
Parameters:
query - the immutable query object

getReply

public java.lang.Object getReply()
Description copied from interface: SimpleRelay
Get the remote reply to the query, if any.

Blackboard interactions are asynchronous, so the plugin should use a subscription to wake when the SimpleRelay has changed.

Specified by:
getReply in interface SimpleRelay

setReply

public void setReply(java.lang.Object reply)
Description copied from interface: SimpleRelay
Change the reply, which is optional.

Only the agent who's address matches "getTarget()" should call this method, which must be followed by a blackboard "publishChange" to resend the reply to the target.

Note that the relay implementation may batch changes and only send the latest change.

Specified by:
setReply in interface SimpleRelay
Parameters:
reply - the immutable reply object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object