|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectrabbit.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 java.io.OutputStream |
cacheStream
The cache stream if available. |
protected MultiOutputStream |
clientstream
The stream to send data to. |
protected Connection |
con
The Connection handling the request. |
protected HTTPInputStream |
contentstream
The stream to read data from. |
protected NCacheEntry |
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. |
| Fields inherited from interface rabbit.util.Logger |
|---|
ALL, DEBUG, ERROR, FATAL, INFO, MSG, WARN |
| Constructor Summary | |
|---|---|
BaseHandler()
For creating the factory. |
|
BaseHandler(Connection con,
HTTPHeader request,
HTTPHeader response,
HTTPInputStream contentstream,
MultiOutputStream clientstream,
boolean maycache,
boolean mayfilter,
long size)
Create a new BaseHansler for the given request. |
|
| Method Summary | |
|---|---|
protected void |
addCacheStream()
Set up the cache stream if available. |
protected boolean |
clientStreamHasCache()
Check if the client stream also have a cache stream. |
protected void |
finish()
Close nesseccary files and adjust the cached files. |
protected void |
finishStream()
This method is used to finish the stream for the data being sent. |
static HandlerFactory |
getFactory()
Get a HandlerFactory that creates BaseHandlers. |
Handler |
getNewInstance(Connection connection,
HTTPHeader header,
HTTPHeader webheader,
HTTPInputStream contentStream,
MultiOutputStream out,
boolean maycache,
boolean mayfilter,
long size)
Get a new Handler for the given request made. |
void |
handle()
Handle the request. |
void |
logError(int type,
java.lang.String error)
Log an error of given type and with given message. |
void |
logError(java.lang.String error)
Log an error. |
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 void |
prepareStream()
This method is used to prepare the stream for the data being sent. |
protected void |
removeCache(java.lang.Exception e)
Remove the cachestream and the cache entry. |
protected void |
send()
Send the actual data. |
protected void |
setPartialContent(long got,
long shouldbe)
Mark the current response as a partial response. |
void |
setup(Logger logger,
SProperties properties)
Setup the factory, this method does nothing in this class. |
protected void |
writeData(byte[] v,
int off,
int len)
Write the data to the client. |
protected void |
writeHeader()
Write the response header |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Connection con
protected HTTPHeader request
protected HTTPHeader response
protected HTTPInputStream contentstream
protected MultiOutputStream clientstream
protected boolean maycache
protected boolean mayfilter
protected NCacheEntry entry
protected java.io.OutputStream cacheStream
protected long size
| Constructor Detail |
|---|
public BaseHandler()
public BaseHandler(Connection con,
HTTPHeader request,
HTTPHeader response,
HTTPInputStream contentstream,
MultiOutputStream clientstream,
boolean maycache,
boolean mayfilter,
long size)
con - the Connection handling the request.request - the actual request made.response - the actual response.contentstream - the stream to read data from.clientstream - the stream to write data to.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 connection,
HTTPHeader header,
HTTPHeader webheader,
HTTPInputStream contentStream,
MultiOutputStream out,
boolean maycache,
boolean mayfilter,
long size)
HandlerFactory
getNewInstance in interface HandlerFactoryconnection - the Connection handling the request.header - the request.webheader - the response.contentStream - the data to read.out - the client (and possibly the cache).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).public static HandlerFactory getFactory()
protected void writeHeader()
throws java.io.IOException
java.io.IOException - if writing the response fails.protected boolean mayCacheFromSize()
protected boolean mayRestrictCacheSize()
protected void addCacheStream()
throws java.io.IOException
java.io.IOException - if a cachestream couldnt be set up.
protected void prepareStream()
throws java.io.IOException
java.io.IOException
protected void writeData(byte[] v,
int off,
int len)
throws java.io.IOException
java.io.IOException
protected void send()
throws java.io.IOException
java.io.IOException - if reading or writing of the data fails.
protected void setPartialContent(long got,
long shouldbe)
protected void finishStream()
throws java.io.IOException
java.io.IOExceptionprotected boolean clientStreamHasCache()
protected void finish()
throws java.io.IOException
java.io.IOException - if closing the files does.
public void handle()
throws java.io.IOException
handle in interface Handlerjava.io.IOException - if any of the underlying methods does.protected void removeCache(java.lang.Exception e)
e - the Exception that happened
public void setup(Logger logger,
SProperties properties)
setup in interface HandlerFactorypublic void logError(java.lang.String error)
LoggerlogError (ERROR, error);
logError in interface Logger
public void logError(int type,
java.lang.String error)
Logger
logError in interface Loggertype - the error level.error - the error message.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||