001: /*
002: * <copyright>
003: *
004: * Copyright 1997-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.tools.server;
028:
029: import java.net.URL;
030:
031: /**
032: * Snapshot for RemoteListenable creation.
033: * <p>
034: * @see RemoteHost#createRemoteProcess
035: */
036: public final class RemoteListenableConfig implements
037: java.io.Serializable {
038:
039: // FIXME:
040: //
041: // currently just contains a single OutputListener
042: // and single URL, where the expectation is that
043: // the URL is null.
044: //
045: // enhance to contain both:
046: // List of URLs
047: // Map of (String-id, OutputListener) pairs
048: //
049: // should still be an immutable class, if possible...
050:
051: // rmi has special handling for this "ol"
052: private final transient OutputListener ol;
053:
054: private final String id;
055:
056: private final URL url;
057:
058: private final OutputPolicy op;
059:
060: public RemoteListenableConfig(OutputListener ol, OutputPolicy op) {
061: this (ol, "default", null, op);
062: }
063:
064: public RemoteListenableConfig(URL url, OutputPolicy op) {
065: this (null, null, url, op);
066: }
067:
068: // for serializer use:
069: public RemoteListenableConfig(OutputListener ol,
070: RemoteListenableConfig rlc) {
071: this (ol, rlc.getId(), rlc.getURL(), rlc.getOutputPolicy());
072: }
073:
074: public RemoteListenableConfig(OutputListener ol, String id,
075: URL url, OutputPolicy op) {
076: this .ol = ol;
077: this .id = id;
078: this .url = url;
079: this .op = op;
080: }
081:
082: public OutputListener getOutputListener() {
083: return ol;
084: }
085:
086: public String getId() {
087: return id;
088: }
089:
090: public URL getURL() {
091: return url;
092: }
093:
094: public OutputPolicy getOutputPolicy() {
095: return op;
096: }
097:
098: public String toString() {
099: StringBuffer buf = new StringBuffer();
100: buf.append("RemoteListenableConfig {\n ");
101: buf.append(op);
102: buf.append("\n URLs[");
103: if (url != null) {
104: buf.append("1]");
105: buf.append("\n [0/1]: ");
106: buf.append(url);
107: buf.append("\n }");
108: } else {
109: buf.append("0]");
110: }
111: buf.append("\n OutputListener[");
112: if (ol != null) {
113: buf.append("1] {");
114: buf.append("\n [0/1]: ");
115: buf.append(id);
116: buf.append("\n }");
117: } else {
118: buf.append("0]");
119: }
120: buf.append("\n}");
121: return buf.toString();
122: }
123:
124: private static final long serialVersionUID = 7981771236710932098L;
125: }
|