01: /*
02: * <copyright>
03: *
04: * Copyright 1997-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: */
26:
27: package org.cougaar.mts.base;
28:
29: import org.cougaar.mts.std.AttributedMessage;
30:
31: /**
32: * The second station for an outgoing message is a SendQueue. In theory a
33: * given Message Transport subsystem can have multiple SendQueues.
34: * For this release we only make one, instantiated as a SendQueueImpl.
35: * Either way, the SendQueues are instantiated by a SendQueueFactory,
36: * accessible to SendLinkImpl as the internal MTS service
37: * <ff>SendQueue</ff>.
38: * <p>
39: * The <strong>sendMessage</strong> method is used to queue messages
40: * in preparation for passing them onto the next station, a Router.
41: * Ordinarily this would only be called from a SendLinkImpl. The
42: * processing of queued messages is assumed to take place in its own
43: * thread, not the caller's thread. In other words, sendMessage is
44: * the final call in the original client's call sequence.
45: * <p>
46: * In a system with multiple SendQueues, the <strong>matches</strong>
47: * method would be used by the SendQueueFactory to avoid making any
48: * particular queue more than once.
49: * <p>
50: * The previous stop is SendLink. The next stop is Router.
51: *
52: * @see SendQueueFactory
53: * @see SendLink
54: * @see Router
55: * @see DestinationQueue
56: * @see DestinationLink
57: * @see MessageWriter
58: * @see MessageReader
59: * @see MessageDeliverer
60: * @see ReceiveLink
61: */
62: public interface SendQueue {
63: /**
64: * Used by SendLinkImpls to queue outgoing messages.
65: *
66: * @param message A message to add to the queue.
67: * @see SendLink#sendMessage(AttributedMessage)
68: *
69: * Javadoc contributions from George Mount.
70: */
71: void sendMessage(AttributedMessage message);
72:
73: /**
74: * Used by a SendQueueFactory in its find-or-make algorithm to
75: * avoid duplicating SendQueues.
76: *
77: * @param name The name of the queue.
78: */
79: boolean matches(String name);
80:
81: /**
82: * Number of messages waiting in the queue.
83: */
84: int size();
85:
86: }
|