|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object rabbit.handler.BaseHandler rabbit.handler.ImageHandler
public class ImageHandler
This handler first downloads the image runs convert on it and then serves the smaller image.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class rabbit.handler.BaseHandler |
---|
BaseHandler.MainBlockListener |
Field Summary |
---|
Fields inherited from class rabbit.handler.BaseHandler |
---|
cacheChannel, clientHandle, con, content, entry, mayCache, mayFilter, request, response, size, tlh, totalRead |
Constructor Summary | |
---|---|
ImageHandler()
For creating the factory. |
|
ImageHandler(Connection con,
TrafficLoggerHandler tlh,
HttpHeader request,
BufferHandle clientHandle,
HttpHeader response,
ResourceSource content,
boolean mayCache,
boolean mayFilter,
long size,
SProperties config,
boolean doConvert,
int minSizeToConvert)
Create a new ImageHandler for the given request. |
Method Summary | |
---|---|
protected void |
addCache()
Set up the cache stream if available. |
boolean |
changesContentSize()
®return true this handler modifies the content. |
protected void |
convertImage()
Convert the image into a small low quality image (normally a jpeg). |
protected void |
finish(boolean good)
clear up the mess we made (remove intermediate files etc). |
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()
Try to convert the image before letting the superclass handle it. |
protected void |
internalConvertImage()
|
protected boolean |
mayCacheFromSize()
Images needs to be cacheable to be compressed. |
protected boolean |
mayRestrictCacheSize()
Check if this handler may force the cached resource to be less than the cache max size. |
protected void |
readImage()
Read in the image |
protected void |
removeCache()
Remove the cachestream and the cache entry. |
void |
setup(Logger logger,
SProperties prop)
setup the handler factory. |
protected void |
tryconvert()
Try to convert the image. |
Methods inherited from class rabbit.handler.BaseHandler |
---|
blockSent, bufferRead, failed, finishData, finishedRead, getLogger, getTaskRunner, httpHeaderSent, mayTransfer, prepare, prepareStream, send, sendHeader, setPartialContent, timeout, writeCache |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ImageHandler()
public ImageHandler(Connection con, TrafficLoggerHandler tlh, HttpHeader request, BufferHandle clientHandle, HttpHeader response, ResourceSource content, boolean mayCache, boolean mayFilter, long size, SProperties config, boolean doConvert, int minSizeToConvert)
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
getNewInstance
in class BaseHandler
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).public boolean changesContentSize()
changesContentSize
in interface Handler
changesContentSize
in class BaseHandler
protected boolean mayCacheFromSize()
mayCacheFromSize
in class BaseHandler
protected boolean mayRestrictCacheSize()
mayRestrictCacheSize
in class BaseHandler
public void handle()
handle
in interface Handler
handle
in class BaseHandler
protected void addCache()
BaseHandler
addCache
in class BaseHandler
protected void finish(boolean good)
finish
in class BaseHandler
good
- if true then the connection may be restarted,
if false then the connection may not be restaredprotected void removeCache()
removeCache
in class BaseHandler
protected void tryconvert() throws IOException
IOException
protected void readImage() throws IOException
IOException
- if reading of the image fails.protected void convertImage()
IOException
- if conversion fails.protected void internalConvertImage() throws IOException
IOException
public void setup(Logger logger, SProperties prop)
HandlerFactory
setup
in interface HandlerFactory
setup
in class BaseHandler
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |