rabbit.handler
Interface ResourceSource

All Superinterfaces:
Transferable
All Known Implementing Classes:
CacheResourceSource, FileResourceSource, RandomCacheResourceSource, WebConnectionResourceSource

public interface ResourceSource
extends Transferable

A resource source. Use supportsTransfer to check if this resource supports transfer, if it does then use the transferTo method. A resource that does not support transfer will listen for blocks that are read, using a BlockListener.

Author:
Robert Olofsson

Method Summary
 void addBlockListener(BlockListener bl)
          Add a ByteBuffer listener.
 long length()
          Get the length of the resource in bytes.
 void release(Connection con)
          Release any held resources.
 boolean supportsTransfer()
          Return true if FileChannel.transferTo can be used.
 
Methods inherited from interface rabbit.proxy.Transferable
transferTo
 

Method Detail

supportsTransfer

boolean supportsTransfer()
Return true if FileChannel.transferTo can be used. Will generally only be true if the resource is served from a FileChannel.


length

long length()
Get the length of the resource in bytes.

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

addBlockListener

void addBlockListener(BlockListener bl)
Add a ByteBuffer listener.


release

void release(Connection con)
Release any held resources.

Parameters:
con - the Connection handling the resource.