View Javadoc

1   /*
2    * Copyright (C) The Spice Group. All rights reserved.
3    *
4    * This software is published under the terms of the Spice
5    * Software License version 1.1, a copy of which has been included
6    * with this distribution in the LICENSE.txt file.
7    */
8   package org.codehaus.spice.netserve.connection.impl;
9   
10  import java.net.ServerSocket;
11  import org.codehaus.spice.netserve.connection.RequestHandler;
12  
13  /***
14   * A utility class that contains acceptor configuration.
15   *
16   * @author Peter Donald
17   * @version $Revision: 1.2 $ $Date: 2004/03/21 23:42:58 $
18   */
19  class AcceptorConfig
20  {
21      /***
22       * The name of the connection.
23       */
24      private final String m_name;
25  
26      /***
27       * The ServerSocket that we are accepting connections from.
28       */
29      private final ServerSocket m_serverSocket;
30  
31      /***
32       * The ConnectionHandlerManager that we create ConnectionHandlers from.
33       */
34      private final RequestHandler m_handler;
35  
36      /***
37       * Create the acceptor.
38       *
39       * @param name the name that connection was registered using
40       * @param serverSocket the ServerSocket that used to accept connections
41       * @param handler the handler for new connections
42       */
43      AcceptorConfig( final String name,
44                      final ServerSocket serverSocket,
45                      final RequestHandler handler )
46      {
47          if( null == name )
48          {
49              throw new NullPointerException( "name" );
50          }
51          if( null == serverSocket )
52          {
53              throw new NullPointerException( "serverSocket" );
54          }
55          if( null == handler )
56          {
57              throw new NullPointerException( "handler" );
58          }
59          m_name = name;
60          m_serverSocket = serverSocket;
61          m_handler = handler;
62      }
63  
64      /***
65       * Return the name acceptor registered under.
66       *
67       * @return the name acceptor registered under.
68       */
69      String getName()
70      {
71          return m_name;
72      }
73  
74      /***
75       * Return the socket that connections accepted from.
76       *
77       * @return the socket that connections accepted from.
78       */
79      ServerSocket getServerSocket()
80      {
81          return m_serverSocket;
82      }
83  
84      /***
85       * Return the handler the connections are handled by.
86       *
87       * @return the handler the connections are handled by.
88       */
89      RequestHandler getHandler()
90      {
91          return m_handler;
92      }
93  }