rabbit.httpio
Class WebConnectionResourceSource

java.lang.Object
  extended by rabbit.httpio.WebConnectionResourceSource
All Implemented Interfaces:
ReadHandler, SocketChannelHandler, ChunkDataFeeder, ResourceSource, Transferable

public class WebConnectionResourceSource
extends Object
implements ResourceSource, ReadHandler, ChunkDataFeeder

A resource source that gets the data from a WebConnection

Author:
Robert Olofsson

Constructor Summary
WebConnectionResourceSource(ConnectionHandler con, NioHandler nioHandler, WebConnection wc, BufferHandle bufHandle, TrafficLogger tl, boolean isChunked, long dataSize, boolean strictHttp)
           
 
Method Summary
 void addBlockListener(BlockListener listener)
          Add a ByteBuffer listener.
 void closed()
           
 void finishedRead()
          Chunk reading has been completed.
 String getDescription()
           
 Long getTimeout()
           
 long length()
          Get the length of the resource in bytes.
 void read()
           
 void readMore()
          The chunk reader needs to read more data, compact buffer before registering.
 void register()
          The chunk reader needs more data.
 void release()
          Release any held resources.
 boolean supportsTransfer()
          FileChannels can not be used, will always return false.
 void timeout()
           
 long transferTo(long position, long count, WritableByteChannel target)
          Transfers bytes from this channel's file to the given writable byte channel.
 boolean useSeparateThread()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebConnectionResourceSource

public WebConnectionResourceSource(ConnectionHandler con,
                                   NioHandler nioHandler,
                                   WebConnection wc,
                                   BufferHandle bufHandle,
                                   TrafficLogger tl,
                                   boolean isChunked,
                                   long dataSize,
                                   boolean strictHttp)
Method Detail

getDescription

public String getDescription()
Specified by:
getDescription in interface SocketChannelHandler

supportsTransfer

public boolean supportsTransfer()
FileChannels can not be used, will always return false.

Specified by:
supportsTransfer in interface ResourceSource
Returns:
false

length

public long length()
Description copied from interface: Transferable
Get the length of the resource in bytes.

Specified by:
length in interface Transferable
Returns:
the size of the resource or -1 if unknown.

transferTo

public long transferTo(long position,
                       long count,
                       WritableByteChannel target)
                throws IOException
Description copied from interface: Transferable
Transfers bytes from this channel's file to the given writable byte channel.

Specified by:
transferTo in interface Transferable
Parameters:
position - The position within the file at which the transfer is to begin; must be non-negative
count - The maximum number of bytes to be transferred; must be non-negative
target - The target channel
Returns:
The number of bytes, possibly zero, that were actually transferred
Throws:
IOException
See Also:
transferTo

addBlockListener

public void addBlockListener(BlockListener listener)
Description copied from interface: ResourceSource
Add a ByteBuffer listener.

Specified by:
addBlockListener in interface ResourceSource

finishedRead

public void finishedRead()
Description copied from interface: ChunkDataFeeder
Chunk reading has been completed.

Specified by:
finishedRead in interface ChunkDataFeeder

register

public void register()
Description copied from interface: ChunkDataFeeder
The chunk reader needs more data.

Specified by:
register in interface ChunkDataFeeder

readMore

public void readMore()
Description copied from interface: ChunkDataFeeder
The chunk reader needs to read more data, compact buffer before registering.

Specified by:
readMore in interface ChunkDataFeeder

read

public void read()
Specified by:
read in interface ReadHandler

useSeparateThread

public boolean useSeparateThread()
Specified by:
useSeparateThread in interface SocketChannelHandler

closed

public void closed()
Specified by:
closed in interface SocketChannelHandler

timeout

public void timeout()
Specified by:
timeout in interface SocketChannelHandler

getTimeout

public Long getTimeout()
Specified by:
getTimeout in interface SocketChannelHandler

release

public void release()
Description copied from interface: ResourceSource
Release any held resources.

Specified by:
release in interface ResourceSource