View Javadoc

1   /* (c) Copyright 2003 Caleigo AB, All rights reserved. 
2    * 
3    * This library is free software; you can redistribute it and/or
4    * modify it under the terms of the GNU Lesser General Public
5    * License as published by the Free Software Foundation; either
6    * version 2.1 of the License, or (at your option) any later version.
7    * 
8    * This library is distributed in the hope that it will be useful,
9    * but WITHOUT ANY WARRANTY; without even the implied warranty of
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   * Lesser General Public License for more details.
12   * 
13   * You should have received a copy of the GNU Lesser General Public
14   * License along with this library; if not, write to the Free Software
15   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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      // Constants ---------------------------------------------------------------
38      
39      // Methods -----------------------------------------------------------------
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  }