1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.caleigo.toolkit.tunnel;
20
21 /*** An ITunnelServer is responsible for accepting connections from ITunnels and
22 * for setting up those connections. Setting up a connection involves creating
23 * an ITunnel that can receive messages from the connecting ITunnel, and configuring
24 * the created ITunnel so that it uses the correct ITunnelCodec and ITunnelPackers.
25 *
26 * @author Mattias Hagstrand
27 * @version 1.00
28 *
29 *//*
30 *
31 * WHEN WHO WHY & WHAT
32 * -----------------------------------------------------------------------------
33 * 2002-07-01 Mattias Hagstrand Creation
34 */
35 public interface ITunnelServer
36 {
37
38
39
40
41 /***
42 * Initializes the ITunnelServer. This method must be called before connections
43 * can be accepted.
44 */
45 public void initialize() throws IllegalStateException, TunnelException;;
46
47 /***
48 * Performs cleanup for this ITunnelServer. This involves closing all connections.
49 * No connections can be accepted after this method has been called.
50 */
51 public void finalize() throws IllegalStateException, TunnelException;;
52
53 /***
54 * Registers an ITunnelPacker that can be used when setting up a connection.
55 */
56 public void registerPacker(Class packer);
57
58 /***
59 * Registers an ITunnelCodec that can be used when setting up a connection.
60 */
61 public void registerCodec(Class codec);
62
63 /***
64 * Adds the IMessageConsumer that receives messages from all connections that
65 * this ITunnelServer has set up. This is a convenience method. Calling this
66 * method has the same effect as calling addMessageConsumer on all of the
67 * individual ITunnels returned by getTunnels. All IMessageConsumers that have
68 * been added with this method will automatically be added to all new ITunnels
69 * that are create.
70 */
71 public void addMessageConsumer(IMessageConsumer consumer);
72
73 /***
74 * Removes the IMessageConsumer all connections that this ITunnelServer has
75 * set up. This is a convenience method. Calling this method has the same
76 * effect as calling removeMessageConsumer on all of the individual ITunnels
77 * returned by getTunnels.
78 */
79 public void removeMessageConsumer(IMessageConsumer consumer);
80
81 /***
82 * Returns the ITunnel with the provided index.
83 */
84 public ITunnel getTunnel(int index);
85
86 /***
87 * Returns an Iterator for all ITunnels that this ITunnelServer has created.
88 */
89 public java.util.Iterator getTunnels();
90
91 /***
92 * Returns the number of ITunnels that this ITunnelServer has created.
93 */
94 public int getTunnelCount();
95
96 public void addTunnelServerListener(ITunnelServerListener listener);
97
98 public void removeTunnelServerListener(ITunnelServerListener listener);
99 }