org.jboss.xnio.nio
Class NioTcpServer

java.lang.Object
  extended by org.jboss.xnio.nio.NioTcpServer
All Implemented Interfaces:
java.io.Closeable, BoundServer<java.net.SocketAddress,BoundChannel<java.net.SocketAddress>>, Configurable

public final class NioTcpServer
extends java.lang.Object
implements BoundServer<java.net.SocketAddress,BoundChannel<java.net.SocketAddress>>


Nested Class Summary
 class NioTcpServer.MBean
           
 class NioTcpServer.NioTcpServerChannel
           
 
Method Summary
 IoFuture<BoundChannel<java.net.SocketAddress>> bind(java.net.SocketAddress address)
          Add a binding.
 void close()
           
 java.util.Collection<BoundChannel<java.net.SocketAddress>> getChannels()
          Get the channels representing the individual bound servers.
<T> T
getOption(ChannelOption<T> option)
          Get the value of a channel option.
 java.util.Set<ChannelOption<?>> getOptions()
          Get the options that may be set on this channel.
<T> NioTcpServer
setOption(ChannelOption<T> option, T value)
          Set an option for this channel.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getChannels

public java.util.Collection<BoundChannel<java.net.SocketAddress>> getChannels()
Description copied from interface: BoundServer
Get the channels representing the individual bound servers. The collection is a snapshot view of the bound channels; modifications to the collection are not allowed. However the channels within the collection are live references to the bindings that exist at the time this method is called; these channels may be closed to unbind the channel.

Specified by:
getChannels in interface BoundServer<java.net.SocketAddress,BoundChannel<java.net.SocketAddress>>
Returns:
the channels

bind

public IoFuture<BoundChannel<java.net.SocketAddress>> bind(java.net.SocketAddress address)
Description copied from interface: BoundServer
Add a binding. The returned channel may be used to close the binding.

Specified by:
bind in interface BoundServer<java.net.SocketAddress,BoundChannel<java.net.SocketAddress>>
Parameters:
address - the address to bind to
Returns:
a future channel representing the binding

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

getOption

public <T> T getOption(ChannelOption<T> option)
            throws UnsupportedOptionException,
                   java.io.IOException
Description copied from interface: Configurable
Get the value of a channel option.

Specified by:
getOption in interface Configurable
Type Parameters:
T - the type of the option value
Parameters:
option - the option to get
Returns:
the value of the option
Throws:
UnsupportedOptionException - if the option is not supported by this channel
java.io.IOException - if an I/O error occurred when reading the option

getOptions

public java.util.Set<ChannelOption<?>> getOptions()
Description copied from interface: Configurable
Get the options that may be set on this channel.

Specified by:
getOptions in interface Configurable
Returns:
an unmodifiable set of options

setOption

public <T> NioTcpServer setOption(ChannelOption<T> option,
                                  T value)
                       throws java.lang.IllegalArgumentException,
                              java.io.IOException
Description copied from interface: Configurable
Set an option for this channel.

Specified by:
setOption in interface Configurable
Type Parameters:
T - the type of the option value
Parameters:
option - the option to set
value - the value of the option to set
Returns:
this channel
Throws:
UnsupportedOptionException - if the option is not supported by this channel
java.lang.IllegalArgumentException - if the value is not acceptable for this option
java.io.IOException - if an I/O error occured when modifying the option

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object