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 org.cougaar.core.blackboard.DirectiveImpl;
030: import org.cougaar.core.util.UID;
031:
032: /**
033: * A {@link org.cougaar.core.blackboard.Directive} for relay
034: * messages, which can add/change/remove a {@link Relay.Target} and
035: * send responses back to the {@link Relay.Source}.
036: */
037: public abstract class RelayDirective extends DirectiveImpl {
038: protected final UID uid;
039:
040: public RelayDirective(UID uid) {
041: this .uid = uid;
042: }
043:
044: public UID getUID() {
045: return uid;
046: }
047:
048: public static class Add extends RelayDirective {
049: private Object content;
050: private Relay.TargetFactory tf;
051:
052: public Add(UID uid, Object content, Relay.TargetFactory tf) {
053: super (uid);
054: this .content = content;
055: this .tf = tf;
056: }
057:
058: public Object getContent() {
059: return content;
060: }
061:
062: public Relay.TargetFactory getTargetFactory() {
063: return tf;
064: }
065:
066: public String toString() {
067: return "(add uid=" + uid + " content=" + content + ")";
068: }
069: }
070:
071: public static class Change extends RelayDirective {
072: private Object content;
073: private Relay.TargetFactory tf;
074:
075: public Change(UID uid, Object content, Relay.TargetFactory tf) {
076: super (uid);
077: this .content = content;
078: this .tf = tf;
079: }
080:
081: public Object getContent() {
082: return content;
083: }
084:
085: public Relay.TargetFactory getTargetFactory() {
086: return tf;
087: }
088:
089: public String toString() {
090: return "(change uid=" + uid + " content=" + content + ")";
091: }
092: }
093:
094: public static class Remove extends RelayDirective {
095: public Remove(UID uid) {
096: super (uid);
097: }
098:
099: public String toString() {
100: return "(remove uid=" + uid + ")";
101: }
102: }
103:
104: public static class Response extends RelayDirective {
105: private Object response;
106:
107: public Response(UID uid, Object response) {
108: super (uid);
109: this .response = response;
110: }
111:
112: public Object getResponse() {
113: return response;
114: }
115:
116: public String toString() {
117: return "(response uid=" + uid + " response=" + response
118: + ")";
119: }
120: }
121: }
|