KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > net > mplex > ServerSocketAdapter


1 package org.sapia.ubik.net.mplex;
2
3 import java.io.IOException JavaDoc;
4
5 import java.net.InetAddress JavaDoc;
6 import java.net.ServerSocket JavaDoc;
7 import java.net.Socket JavaDoc;
8 import java.net.SocketAddress JavaDoc;
9 import java.net.SocketException JavaDoc;
10
11
12 /**
13  * This utility class adapts a <code>MultiplexSocketConnector</code> to a
14  * <code>java.net.ServerSocket<code>. That means that a socket connector, that
15  * was previously created with a multiplex server socket, can be used as
16  * a traditionnal server socket. This adapter can be useful when integrating
17  * the multiplex module into existing code that rely on the <code>java.net.ServerSocket<code>
18  * object.<p>
19  *
20  * Note that the following methods are not supported:
21  * <ul>
22  * <li>bind(SocketAddress endpoint)</li>
23  * <li>bind(SocketAddress endpoint, int backlog)</li>
24  * <li>setSoTimeout(int timeout)</li>
25  * <li>setReuseAddress(boolean on)</li>
26  * <li>setReceiveBufferSize(int size)</li>
27  * </ul><p>
28  *
29  * Calling any of these methods will result in an <code>UnsupportedOperationException</code>
30  * beign thrown.
31  *
32  *
33  * @author <a HREF="mailto:jc@sapia-oss.org">Jean-Cedric Desrochers</a>
34  * <dl>
35  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2004 <a HREF="http://www.sapia-oss.org">
36  * Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
37  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
38  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a>
39  * at the Sapia OSS web site</dd></dt>
40  * </dl>
41  */

42 public class ServerSocketAdapter extends ServerSocket JavaDoc {
43   /** The socket connector wrapped by this adapter. */
44   private MultiplexSocketConnector _theDelegate;
45
46   /**
47    * Creates a new ServerSocketAdapter instance.
48    */

49   public ServerSocketAdapter(MultiplexSocketConnector anInterceptor)
50     throws IOException JavaDoc {
51     super();
52     _theDelegate = anInterceptor;
53   }
54
55   /**
56    * @see java.net.ServerSocket#bind(java.net.SocketAddress)
57    */

58   public void bind(SocketAddress JavaDoc endpoint) throws IOException JavaDoc {
59     throw new UnsupportedOperationException JavaDoc();
60   }
61
62   /**
63    * @see java.net.ServerSocket#bind(java.net.SocketAddress, int)
64    */

65   public void bind(SocketAddress JavaDoc endpoint, int backlog)
66     throws IOException JavaDoc {
67     throw new UnsupportedOperationException JavaDoc();
68   }
69
70   /**
71    * @see java.net.ServerSocket#getInetAddress()
72    */

73   public InetAddress JavaDoc getInetAddress() {
74     return _theDelegate.getInetAddress();
75   }
76
77   /**
78    * @see java.net.ServerSocket#getLocalPort()
79    */

80   public int getLocalPort() {
81     return _theDelegate.getLocalPort();
82   }
83
84   /**
85    * @see java.net.ServerSocket#getLocalSocketAddress()
86    */

87   public SocketAddress JavaDoc getLocalSocketAddress() {
88     return _theDelegate.getLocalSocketAddress();
89   }
90
91   /**
92    * @see java.net.ServerSocket#accept()
93    */

94   public Socket JavaDoc accept() throws IOException JavaDoc {
95     return _theDelegate.accept();
96   }
97
98   /**
99    * @see java.net.ServerSocket#close()
100    */

101   public void close() throws IOException JavaDoc {
102     _theDelegate.close();
103   }
104
105   /**
106    * @see java.net.ServerSocket#isBound()
107    */

108   public boolean isBound() {
109     return _theDelegate.isBound();
110   }
111
112   /**
113    * @see java.net.ServerSocket#isClosed()
114    */

115   public boolean isClosed() {
116     return _theDelegate.isClosed();
117   }
118
119   /**
120    * @see java.net.ServerSocket#setSoTimeout(int)
121    */

122   public void setSoTimeout(int timeout) throws SocketException JavaDoc {
123     throw new UnsupportedOperationException JavaDoc();
124   }
125
126   /**
127    * @see java.net.ServerSocket#getSoTimeout()
128    */

129   public int getSoTimeout() throws IOException JavaDoc {
130     return _theDelegate.getSoTimeout();
131   }
132
133   /**
134    * @see java.net.ServerSocket#setReuseAddress(boolean)
135    */

136   public void setReuseAddress(boolean on) throws SocketException JavaDoc {
137     throw new UnsupportedOperationException JavaDoc();
138   }
139
140   /**
141    * @see java.net.ServerSocket#getReuseAddress()
142    */

143   public boolean getReuseAddress() throws SocketException JavaDoc {
144     return _theDelegate.getReuseAddress();
145   }
146
147   /**
148    * @see java.net.ServerSocket#setReceiveBufferSize(int)
149    */

150   public void setReceiveBufferSize(int size) throws SocketException JavaDoc {
151     throw new UnsupportedOperationException JavaDoc();
152   }
153
154   /**
155    * @see java.net.ServerSocket#getReceiveBufferSize()
156    */

157   public int getReceiveBufferSize() throws SocketException JavaDoc {
158     return _theDelegate.getReceiveBufferSize();
159   }
160 }
161
Popular Tags