rabbit.httpio
Class WebConnectionResourceSource

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

public class WebConnectionResourceSource
extends Object
implements ResourceSource, SocketHandler, ChunkDataFeeder

A resource source that gets the data from a WebConnection

Author:
Robert Olofsson

Constructor Summary
WebConnectionResourceSource(ConnectionHandler con, Selector selector, WebConnection wc, BufferHandle bufHandle, Logger logger, TrafficLogger tl, boolean isChunked, long dataSize, boolean strictHttp)
           
 
Method Summary
 void addBlockListener(BlockListener listener)
          Add a ByteBuffer listener.
 void finishedRead()
          Chunk reading has been completed.
 String getDescription()
          Get a string description.
 long length()
          Get the length of the resource in bytes.
 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.
 void run()
           
 boolean supportsTransfer()
          FileChannels can not be used, will always return false.
 void timeout()
          Signal that the select operation timed out.
 long transferTo(long position, long count, WritableByteChannel target)
          Transfers bytes from this channel's file to the given writable byte channel.
 boolean useSeparateThread()
          Check if this handler needs to run in a separate thread.
 
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,
                                   Selector selector,
                                   WebConnection wc,
                                   BufferHandle bufHandle,
                                   Logger logger,
                                   TrafficLogger tl,
                                   boolean isChunked,
                                   long dataSize,
                                   boolean strictHttp)
Method Detail

getDescription

public String getDescription()
Description copied from interface: SocketHandler
Get a string description.

Specified by:
getDescription in interface SocketHandler

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

run

public void run()
Specified by:
run in interface Runnable

useSeparateThread

public boolean useSeparateThread()
Description copied from interface: SocketHandler
Check if this handler needs to run in a separate thread.

Specified by:
useSeparateThread in interface SocketHandler

timeout

public void timeout()
Description copied from interface: SocketHandler
Signal that the select operation timed out.

Specified by:
timeout in interface SocketHandler

release

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

Specified by:
release in interface ResourceSource