KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > mcast > UnicastDispatcher


1 package org.sapia.ubik.mcast;
2
3 import org.sapia.ubik.net.ServerAddress;
4
5 import java.io.IOException JavaDoc;
6
7
8 /**
9  * Implementations of this interface dispatch objects over the wire in a
10  * point-to-point fashion. It is important to note that implementations
11  * are expected to behave in a peer-to-peer fashion - they are at once client
12  * and server (for their siblings).
13  *
14  * @author Yanick Duchesne
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
17  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
18  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
19  * </dl>
20  */

21 public interface UnicastDispatcher {
22   /**
23    * Dispatches the given data to the node whose address is given.
24    *
25    * @param addr a <code>ServerAddress</code> that corresponds to the
26    * destination node for the data passed in.
27    * @param type the logical type of the data that is sent - allows the
28    * receiver to perform logic according to the "type".
29    * @param data the <code>Object</code> to send.
30    */

31   public void dispatch(ServerAddress addr, String JavaDoc type, Object JavaDoc data)
32     throws IOException JavaDoc;
33
34   /**
35    * Sends the given data to the node whose address is given, returning the
36    * corresponding response - received from the destination.
37    *
38    * @param addr a <code>ServerAddress</code> that corresponds to the
39    * destination node for the data passed in.
40    * @param type the logical type of the data that is sent - allows the
41    * receiver to perform logic according to the "type".
42    * @param data the <code>Object</code> to send.
43    *
44    * @return a <code>Response</code>.
45    */

46   public Response send(ServerAddress addr, String JavaDoc type, Object JavaDoc data)
47     throws IOException JavaDoc;
48
49   /**
50    * Sends the given data to the list of destinations specified, and returning
51    * the responses received from each destination.
52    *
53    * @param addresses a <code>List</code> of <code>ServerAddress</code> instances.
54    * @param type the logical type of the data that is sent - allows the
55    * receiver to perform logic according to the "type".
56    * @param data the <code>Object</code> to send.
57    *
58    * @return a <code>RespList</code>.
59    */

60   public RespList send(java.util.List JavaDoc addresses, String JavaDoc type, Object JavaDoc data)
61     throws IOException JavaDoc;
62
63   /**
64    * Starts this instance - should be called prior to using this instance.
65    */

66   public void start();
67
68   /**
69    * Closes this instance - which should not be used thereafter.
70    */

71   public void close();
72
73   /**
74    * Sets this instance's "buffer size". The size is specified in bytes, and can
75    * be interpreted differently from one implementation to another - for example, for
76    * UDP-based implementation, it can correspond to the datagram packet size.
77    *
78    * @param the size of this instance's internal buffer, in bytes.
79    */

80   public void setBufsize(int size);
81
82   /**
83    * Allows implementations to notify the passed in listener when a socket timeout occurs - this
84    * applies if the underlying implementation uses a server restricted to blocking IO.
85    *
86    * @see java.net.DatagramSocket#setSoTimeout(int)
87    * @see java.net.ServerSocket#setSoTimeout(int)
88    */

89   public void setSoTimeoutListener(SocketTimeoutListener listener);
90
91   /**
92    * Returns the address of this instance.
93    *
94    * @return a <code>ServerAddress</code>.
95    *
96    * @throws IllegalStateException if the address of this instance is not yet available.
97    * This can be the case if the <code>start()</code> method has not yet been called;
98    * therefore, always call start() before calling this method.
99    *
100    * @see #start()
101    */

102   public ServerAddress getAddress() throws IllegalStateException JavaDoc;
103 }
104
Popular Tags