[#2326] Add constructor to NioServerSocketChannel which accepts a ServerSocketChannel

Motivation:
Allow the user to create a NioServerSocketChannel from an existing ServerSocketChannel.

Modifications:
Add an extra constructor

Result:
Now the user is be able to create a NioServerSocketChannel from an existing ServerSocketChannel, like he can do with all the other Nio*Channel implemntations.
This commit is contained in:
Norman Maurer 2014-03-16 07:00:44 -07:00
parent 535b024913
commit a17d28605a

View File

@ -66,7 +66,14 @@ public class NioServerSocketChannel extends AbstractNioMessageChannel
* Create a new instance * Create a new instance
*/ */
public NioServerSocketChannel() { public NioServerSocketChannel() {
super(null, newSocket(), SelectionKey.OP_ACCEPT); this(newSocket());
}
/**
* Create a new instance using the given {@link ServerSocketChannel}.
*/
public NioServerSocketChannel(ServerSocketChannel channel) {
super(null, channel, SelectionKey.OP_ACCEPT);
config = new DefaultServerSocketChannelConfig(this, javaChannel().socket()); config = new DefaultServerSocketChannelConfig(this, javaChannel().socket());
} }