Apache Tomcat 7.0.28

org.apache.tomcat.util.net
Class NioChannel

java.lang.Object
  extended by org.apache.tomcat.util.net.NioChannel
All Implemented Interfaces:
Closeable, ByteChannel, Channel, ReadableByteChannel, WritableByteChannel
Direct Known Subclasses:
SecureNioChannel

public class NioChannel
extends Object
implements ByteChannel

Base class for a SocketChannel wrapper used by the endpoint. This way, logic for a SSL socket channel remains the same as for a non SSL, making sure we don't need to code for any exception cases.

Version:
1.0
Author:
Filip Hanik

Field Summary
protected  SecureNioChannel.ApplicationBufferHandler bufHandler
           
protected static ByteBuffer emptyBuf
           
protected  NioEndpoint.Poller poller
           
protected  SocketChannel sc
           
protected  boolean sendFile
           
 
Constructor Summary
NioChannel(SocketChannel channel, SecureNioChannel.ApplicationBufferHandler bufHandler)
           
 
Method Summary
 void close()
          Closes this channel.
 void close(boolean force)
           
 boolean flush(boolean block, Selector s, long timeout)
          Returns true if the network buffer has been flushed out and is empty.
 boolean flushOutbound()
          Return true if the buffer wrote data
 Object getAttachment(boolean remove)
           
 int getBufferSize()
           
 SecureNioChannel.ApplicationBufferHandler getBufHandler()
          getBufHandler
 SocketChannel getIOChannel()
          getIOChannel
 int getOutboundRemaining()
           
 NioEndpoint.Poller getPoller()
           
 int handshake(boolean read, boolean write)
           
 boolean isClosing()
          isClosing
 boolean isHandshakeComplete()
          isInitHandshakeComplete
 boolean isOpen()
          Tells whether or not this channel is open.
 boolean isSendFile()
           
 int read(ByteBuffer dst)
          Reads a sequence of bytes from this channel into the given buffer.
 void reset()
           
 void setIOChannel(SocketChannel IOChannel)
           
 void setPoller(NioEndpoint.Poller poller)
           
 void setSendFile(boolean s)
           
 String toString()
           
 int write(ByteBuffer src)
          Writes a sequence of bytes to this channel from the given buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

emptyBuf

protected static ByteBuffer emptyBuf

sc

protected SocketChannel sc

bufHandler

protected SecureNioChannel.ApplicationBufferHandler bufHandler

poller

protected NioEndpoint.Poller poller

sendFile

protected boolean sendFile
Constructor Detail

NioChannel

public NioChannel(SocketChannel channel,
                  SecureNioChannel.ApplicationBufferHandler bufHandler)
           throws IOException
Throws:
IOException
Method Detail

reset

public void reset()
           throws IOException
Throws:
IOException

getBufferSize

public int getBufferSize()

flush

public boolean flush(boolean block,
                     Selector s,
                     long timeout)
              throws IOException
Returns true if the network buffer has been flushed out and is empty.

Parameters:
block - Unused. May be used when overridden
s - Unused. May be used when overridden
timeout - Unused. May be used when overridden
Returns:
Always returns true since there is no network buffer in the regular channel
Throws:
IOException

close

public void close()
           throws IOException
Closes this channel.

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Throws:
IOException - If an I/O error occurs TODO Implement this java.nio.channels.Channel method

close

public void close(boolean force)
           throws IOException
Throws:
IOException

isOpen

public boolean isOpen()
Tells whether or not this channel is open.

Specified by:
isOpen in interface Channel
Returns:
true if, and only if, this channel is open TODO Implement this java.nio.channels.Channel method

write

public int write(ByteBuffer src)
          throws IOException
Writes a sequence of bytes to this channel from the given buffer.

Specified by:
write in interface WritableByteChannel
Parameters:
src - The buffer from which bytes are to be retrieved
Returns:
The number of bytes written, possibly zero
Throws:
IOException - If some other I/O error occurs TODO Implement this java.nio.channels.WritableByteChannel method

read

public int read(ByteBuffer dst)
         throws IOException
Reads a sequence of bytes from this channel into the given buffer.

Specified by:
read in interface ReadableByteChannel
Parameters:
dst - The buffer into which bytes are to be transferred
Returns:
The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream
Throws:
IOException - If some other I/O error occurs TODO Implement this java.nio.channels.ReadableByteChannel method

getAttachment

public Object getAttachment(boolean remove)

getBufHandler

public SecureNioChannel.ApplicationBufferHandler getBufHandler()
getBufHandler

Returns:
ApplicationBufferHandler TODO Implement this org.apache.tomcat.util.net.SecureNioChannel method

getPoller

public NioEndpoint.Poller getPoller()

getIOChannel

public SocketChannel getIOChannel()
getIOChannel

Returns:
SocketChannel TODO Implement this org.apache.tomcat.util.net.SecureNioChannel method

isClosing

public boolean isClosing()
isClosing

Returns:
boolean TODO Implement this org.apache.tomcat.util.net.SecureNioChannel method

isHandshakeComplete

public boolean isHandshakeComplete()
isInitHandshakeComplete

Returns:
boolean

handshake

public int handshake(boolean read,
                     boolean write)
              throws IOException
Throws:
IOException

setPoller

public void setPoller(NioEndpoint.Poller poller)

setIOChannel

public void setIOChannel(SocketChannel IOChannel)

toString

public String toString()
Overrides:
toString in class Object

getOutboundRemaining

public int getOutboundRemaining()

flushOutbound

public boolean flushOutbound()
                      throws IOException
Return true if the buffer wrote data

Throws:
IOException

isSendFile

public boolean isSendFile()

setSendFile

public void setSendFile(boolean s)

Apache Tomcat 7.0.28

Copyright © 2000-2012 Apache Software Foundation. All Rights Reserved.