001: /*
002: * <copyright>
003: *
004: * Copyright 2002-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.core.relay;
028:
029: import java.io.Serializable;
030:
031: import org.cougaar.core.mts.MessageAddress;
032: import org.cougaar.core.util.UID;
033:
034: /**
035: * Abstract base class for {@link SimpleRelay} implementations.
036: */
037: public abstract class SimpleRelayBase implements SimpleRelay,
038: Serializable {
039:
040: protected final UID uid;
041: protected final MessageAddress source;
042: protected final MessageAddress target;
043:
044: protected Object query;
045: protected Object reply;
046:
047: public SimpleRelayBase(UID uid, MessageAddress source,
048: MessageAddress target) {
049: this .uid = uid;
050: this .source = source;
051: this .target = target;
052: }
053:
054: // SimpleRelay:
055:
056: public UID getUID() {
057: return uid;
058: }
059:
060: public void setUID(UID uid) {
061: throw new UnsupportedOperationException();
062: }
063:
064: public MessageAddress getSource() {
065: return source;
066: }
067:
068: public MessageAddress getTarget() {
069: return target;
070: }
071:
072: public Object getQuery() {
073: return query;
074: }
075:
076: public void setQuery(Object query) {
077: this .query = query;
078: }
079:
080: public Object getReply() {
081: return reply;
082: }
083:
084: public void setReply(Object reply) {
085: this .reply = reply;
086: }
087:
088: // Object:
089:
090: public boolean equals(Object o) {
091: if (o == this ) {
092: return true;
093: } else if (o instanceof SimpleRelay) {
094: UID u = ((SimpleRelay) o).getUID();
095: return uid.equals(u);
096: } else {
097: return false;
098: }
099: }
100:
101: public int hashCode() {
102: return uid.hashCode();
103: }
104:
105: public String toString() {
106: return "(SimpleRelay" + " uid=" + uid + " source=" + source
107: + " target=" + target + " query=" + query + " reply="
108: + reply + ")";
109: }
110: }
|