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.mts.base;
028:
029: import org.cougaar.core.mts.MessageAddress;
030: import org.cougaar.core.mts.MessageAttributes;
031: import org.cougaar.mts.std.AttributedMessage;
032:
033: /**
034: * The fifth station for outgoing messages. Each LinkProtocol has its
035: * own DestinationLink implementation class. DestinationLinks are
036: * made by the protocols, acting as factories.
037: * <p>
038: * The previous station is DestinationQueue. If the protocol uses
039: * Java serialization, the next station is MessageWriter.
040: * If there is no serialization, MessageDeliverer on the receiving
041: * side is the next stop.
042: *
043: * @see LinkProtocol
044: * @see SendLink
045: * @see SendQueue
046: * @see Router
047: * @see DestinationQueue
048: * @see MessageWriter
049: * @see MessageReader
050: * @see MessageDeliverer
051: * @see ReceiveLink
052: *
053: * Javadoc contributions from George Mount.
054: */
055: public interface DestinationLink {
056:
057: /**
058: * This method is used to request the associated transport to do
059: * its thing with the given message. Only called during
060: * processing of messages in DestinationQueueImpl.
061: *
062: * @see DestinationQueue#dispatchNextMessage(AttributedMessage)
063: */
064: MessageAttributes forwardMessage(AttributedMessage message)
065: throws UnregisteredNameException, NameLookupException,
066: CommFailureException, MisdeliveredMessageException;
067:
068: /**
069: * This method returns a simple measure of the cost of sending the
070: * given message via the associated transport. Only called during
071: * processing of messages in DestinationQueueImpl.
072: *
073: * @see DestinationQueue#dispatchNextMessage(AttributedMessage)
074: * @see LinkSelectionPolicy
075: * @see MinCostLinkSelectionPolicy
076: */
077: int cost(AttributedMessage message);
078:
079: /**
080: * @return the class of corresponding LinkProtocol.
081: */
082: Class getProtocolClass();
083:
084: /**
085: * Is this link currently legitimate and functional? The default
086: * is true for loopback and would ordinarily be true for remote
087: * calls if the stub (or whatever) is accessible. Aspects can
088: * alter this behavior, for example to disable unencrypted rmi.
089: * This method in invoked on every loaded link before the link
090: * selection policy is run; the policy will not see invalid links
091: * at all. As a side-effect, cost() will not always be run (as
092: * it was before 11_0).
093: */
094: boolean isValid();
095:
096: /**
097: * Ask Link whether or not further retries should be attempted.
098: */
099: boolean retryFailedMessage(AttributedMessage message, int retryCount);
100:
101: /**
102: * Return the target/destination of this link.
103: */
104: MessageAddress getDestination();
105:
106: /**
107: * Return some form of remote reference for the destination, if it
108: * has one (rmi server stub, smtp url, CORBA ior, etc) */
109: Object getRemoteReference();
110:
111: /**
112: * Allows the DestinationLink to add attributes before forwarding
113: * the message.
114: *
115: * @see DestinationQueue#dispatchNextMessage(AttributedMessage)
116: */
117: void addMessageAttributes(MessageAttributes attrs);
118:
119: }
|