|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rabbit.handler.BaseHandler
public class BaseHandler
This class is an implementation of the Handler interface. This handler does no filtering, it only sends the data as effective as it can.
Field Summary | |
---|---|
protected WritableByteChannel |
cacheChannel
The cache channel. |
protected BufferHandle |
clientHandle
The client buffer. |
protected Connection |
con
The Connection handling the request. |
protected ResourceSource |
content
The resource |
protected CacheEntry<HttpHeader,HttpHeader> |
entry
The cache entry if available. |
protected boolean |
mayCache
May we cache this request. |
protected boolean |
mayFilter
May we filter this request |
protected HttpHeader |
request
The actual request made. |
protected HttpHeader |
response
The actual response. |
protected long |
size
The length of the data beeing handled or -1 if unknown. |
protected TrafficLoggerHandler |
tlh
The traffic logger handler. |
protected long |
totalRead
The total amount of data that we read. |
Constructor Summary | |
---|---|
BaseHandler()
For creating the factory. |
|
BaseHandler(Connection con,
TrafficLoggerHandler tlh,
HttpHeader request,
BufferHandle clientHandle,
HttpHeader response,
ResourceSource content,
boolean mayCache,
boolean mayFilter,
long size)
Create a new BaseHandler for the given request. |
Method Summary | |
---|---|
protected void |
addCache()
Set up the cache stream if available. |
void |
blockSent()
The http header has been sent. |
void |
bufferRead(BufferHandle bufHandle)
A buffer has been read, the buffer has been flip:ed before this call is made so position and remaining are valid. |
boolean |
changesContentSize()
®return false if this handler never modifies the content. |
protected void |
deleteFile(File f)
|
void |
failed(Exception cause)
Reading failed |
protected void |
finish(boolean good)
Close nesseccary channels and adjust the cached files. |
protected void |
finishData()
This method is used to finish the data for the resource being sent. |
void |
finishedRead()
The resource have been fully transferred |
protected Logger |
getLogger()
|
Handler |
getNewInstance(Connection con,
TrafficLoggerHandler tlh,
HttpHeader header,
BufferHandle bufHandle,
HttpHeader webHeader,
ResourceSource content,
boolean mayCache,
boolean mayFilter,
long size)
Get a new Handler for the given request made. |
void |
handle()
Handle the request. |
void |
httpHeaderSent()
The http header has been sent. |
protected boolean |
mayCacheFromSize()
Try to use the resource size to decide if we may cache or not. |
protected boolean |
mayRestrictCacheSize()
Check if this handler may force the cached resource to be less than the cache max size. |
protected boolean |
mayTransfer()
Check if this handler supports direct transfers. |
protected void |
prepare()
This method is used to prepare the data for the resource being sent. |
protected void |
prepareStream()
This method is used to prepare the stream for the data being sent. |
protected void |
removeCache()
|
protected void |
send()
|
protected void |
sendHeader()
|
protected void |
setPartialContent(long got,
long shouldbe)
Mark the current response as a partial response. |
void |
setup(SProperties properties)
setup the handler factory. |
void |
timeout()
The operation timed out |
protected void |
writeCache(ByteBuffer buf)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Connection con
protected TrafficLoggerHandler tlh
protected HttpHeader request
protected BufferHandle clientHandle
protected HttpHeader response
protected ResourceSource content
protected CacheEntry<HttpHeader,HttpHeader> entry
protected WritableByteChannel cacheChannel
protected boolean mayCache
protected boolean mayFilter
protected long size
protected long totalRead
Constructor Detail |
---|
public BaseHandler()
public BaseHandler(Connection con, TrafficLoggerHandler tlh, HttpHeader request, BufferHandle clientHandle, HttpHeader response, ResourceSource content, boolean mayCache, boolean mayFilter, long size)
con
- the Connection handling the request.request
- the actual request made.clientHandle
- the client side buffer.response
- the actual response.content
- the resource.mayCache
- May we cache this request?mayFilter
- May we filter this request?size
- the size of the data beeing handled.Method Detail |
---|
public Handler getNewInstance(Connection con, TrafficLoggerHandler tlh, HttpHeader header, BufferHandle bufHandle, HttpHeader webHeader, ResourceSource content, boolean mayCache, boolean mayFilter, long size)
HandlerFactory
getNewInstance
in interface HandlerFactory
con
- the Connection handling the request.tlh
- the Traffic logger handler.header
- the request.bufHandle
- the client side buffer handle (may contain the next request).webHeader
- the response.content
- the resource.mayCache
- if the handler may cache the response.mayFilter
- if the handler may filter the response.size
- the Size of the data beeing handled (-1 = unknown length).protected Logger getLogger()
public void handle()
handle
in interface Handler
public boolean changesContentSize()
changesContentSize
in interface Handler
protected void sendHeader()
public void httpHeaderSent()
HttpHeaderSentListener
httpHeaderSent
in interface HttpHeaderSentListener
protected void prepare()
protected void finishData()
protected void setPartialContent(long got, long shouldbe)
protected void finish(boolean good)
good
- if true then the connection may be restarted,
if false then the connection may not be restaredprotected boolean mayCacheFromSize()
protected boolean mayRestrictCacheSize()
protected void addCache()
protected void prepareStream()
protected boolean mayTransfer()
protected void send()
protected void writeCache(ByteBuffer buf) throws IOException
IOException
public void bufferRead(BufferHandle bufHandle)
BlockListener
bufferRead
in interface BlockListener
public void blockSent()
BlockSentListener
blockSent
in interface BlockSentListener
public void finishedRead()
BlockListener
finishedRead
in interface BlockListener
protected void deleteFile(File f)
protected void removeCache()
public void failed(Exception cause)
AsyncListener
failed
in interface AsyncListener
cause
- the real reason the operation failed.public void timeout()
AsyncListener
timeout
in interface AsyncListener
public void setup(SProperties properties)
HandlerFactory
setup
in interface HandlerFactory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |