org.activeio.net
Class NIOAsyncChannel

java.lang.Object
  extended by org.activeio.net.NIOBaseChannel
      extended by org.activeio.net.NIOAsyncChannel
All Implemented Interfaces:
AsyncChannel, Channel, Disposable, InputAsyncChannel, SocketMetadata, OutputChannel, Service

public final class NIOAsyncChannel
extends NIOBaseChannel
implements AsyncChannel

Version:
$Revision$

Field Summary
 
Fields inherited from class org.activeio.net.NIOBaseChannel
socket, socketChannel
 
Fields inherited from interface org.activeio.Service
NO_WAIT_TIMEOUT, WAIT_FOREVER_TIMEOUT
 
Fields inherited from interface org.activeio.Service
NO_WAIT_TIMEOUT, WAIT_FOREVER_TIMEOUT
 
Constructor Summary
NIOAsyncChannel(SocketChannel socketChannel, boolean useDirect)
           
 
Method Summary
 void dispose()
          This method should not throw any exceptions.
 void flush()
          Some channels may buffer data which may be sent down if flush() is called.
 AsyncChannelListener getAsyncChannelListener()
           
 void setAsyncChannelListener(AsyncChannelListener channelListener)
          Registers the ChannelConsumer that the protcol will use to deliver packets coming 'up' the channel.
 void start()
          Starts the channel.
 void stop(long timeout)
          Stops the channel.
 void write(Packet packet)
          Sends a packet down the channel towards the media.
 
Methods inherited from class org.activeio.net.NIOBaseChannel
allocateBuffer, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, narrow, setKeepAlive, setOOBInline, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.activeio.Channel
narrow
 
Methods inherited from interface org.activeio.Channel
narrow
 

Constructor Detail

NIOAsyncChannel

public NIOAsyncChannel(SocketChannel socketChannel,
                       boolean useDirect)
                throws IOException
Throws:
IOException
Method Detail

write

public void write(Packet packet)
           throws IOException
Description copied from interface: OutputChannel
Sends a packet down the channel towards the media.

Specified by:
write in interface OutputChannel
Throws:
IOException

flush

public void flush()
           throws IOException
Description copied from interface: OutputChannel
Some channels may buffer data which may be sent down if flush() is called.

Specified by:
flush in interface OutputChannel
Overrides:
flush in class NIOBaseChannel
Throws:
IOException
See Also:
org.activeio.Channel#flush()

setAsyncChannelListener

public void setAsyncChannelListener(AsyncChannelListener channelListener)
Description copied from interface: InputAsyncChannel
Registers the ChannelConsumer that the protcol will use to deliver packets coming 'up' the channel.

Specified by:
setAsyncChannelListener in interface InputAsyncChannel

getAsyncChannelListener

public AsyncChannelListener getAsyncChannelListener()
Specified by:
getAsyncChannelListener in interface InputAsyncChannel
Returns:
the registered Packet consumer

dispose

public void dispose()
Description copied from interface: Disposable
This method should not throw any exceptions. Cleaning up a Disposable object should be easy of an end user therefore do not make him have to handle an Exception.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class NIOBaseChannel

start

public void start()
           throws IOException
Description copied from interface: Service
Starts the channel. Once started, the channel is in the running state.

Specified by:
start in interface Service
Throws:
IOException

stop

public void stop(long timeout)
          throws IOException
Description copied from interface: Service
Stops the channel. Once stopped, the channel is in the stopped state.

Specified by:
stop in interface Service
Parameters:
timeout - The amount of time the channel is allowed to take to gracefully stop. If the timeout is exceeded, the channel should do a forcefull stop.
Throws:
IOException


Copyright © -2009 The ActiveIO Project. All Rights Reserved.