|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.octo.captcha.engine.bufferedengine.BufferedEngineContainer
public abstract class BufferedEngineContainer
Abstact class that encapsulate a CaptchaEngine to allow buffering. A BufferedEngineContainer has mainly one function : to provide cached captchas to increase performances. This is done through two embedded buffers : a disk buffer and a memory buffer. When captchas are requested, the bufferedEngine take them either from the memory buffer if not empty or directly from the engine. Some good periods are defined with a scheduler to feed the disk buffer with captchas and some others to swap captchas from the disk buffer to the memory buffer.
Field Summary | |
---|---|
protected ContainerConfiguration |
config
|
protected CaptchaEngine |
engine
|
protected CaptchaBuffer |
persistentBuffer
|
protected int |
persistentFeedings
|
protected int |
persistentMemoryHits
|
protected int |
persistentToVolatileSwaps
|
protected CaptchaBuffer |
volatileBuffer
|
protected int |
volatileMemoryHits
|
Constructor Summary | |
---|---|
BufferedEngineContainer(CaptchaEngine engine,
CaptchaBuffer volatileBuffer,
CaptchaBuffer persistentBuffer,
ContainerConfiguration containerConfiguration)
Construct an BufferedEngineContainer with and Captcha engine, a memory buffer, a diskBuffer and a ContainerConfiguration. |
Method Summary | |
---|---|
void |
closeBuffers()
|
void |
feedPersistentBuffer()
Method launch by a scheduler to feed the disk buffer with captcha. |
ContainerConfiguration |
getConfig()
|
CaptchaFactory[] |
getFactories()
|
Captcha |
getNextCaptcha()
This return a new captcha. |
Captcha |
getNextCaptcha(java.util.Locale locale)
This return a new captcha. |
CaptchaBuffer |
getPersistentBuffer()
|
java.lang.Integer |
getPersistentFeedings()
|
java.lang.Integer |
getPersistentMemoryHits()
|
java.lang.Integer |
getPersistentToVolatileSwaps()
|
CaptchaBuffer |
getVolatileBuffer()
|
java.lang.Integer |
getVolatileMemoryHits()
|
void |
setFactories(CaptchaFactory[] factories)
|
void |
swapCaptchasFromPersistentToVolatileMemory()
Method launch by a scheduler to swap captcha from disk buffer to the memory buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected CaptchaBuffer persistentBuffer
protected CaptchaBuffer volatileBuffer
protected CaptchaEngine engine
protected ContainerConfiguration config
protected int volatileMemoryHits
protected int persistentMemoryHits
protected int persistentToVolatileSwaps
protected int persistentFeedings
Constructor Detail |
---|
public BufferedEngineContainer(CaptchaEngine engine, CaptchaBuffer volatileBuffer, CaptchaBuffer persistentBuffer, ContainerConfiguration containerConfiguration)
engine
- engine to generate captcha for buffersvolatileBuffer
- the memory buffer, which store captcha and provide a fast access to thempersistentBuffer
- the disk buffer which store captchas not in a volatil and memory consuming waycontainerConfiguration
- the container configurationMethod Detail |
---|
public Captcha getNextCaptcha()
CaptchaEngine
getNextCaptcha
in interface CaptchaEngine
CaptchaEngine.getNextCaptcha()
public Captcha getNextCaptcha(java.util.Locale locale)
CaptchaEngine
getNextCaptcha
in interface CaptchaEngine
locale
- the desired locale
CaptchaEngine.getNextCaptcha(java.util.Locale)
public CaptchaFactory[] getFactories()
getFactories
in interface CaptchaEngine
public void setFactories(CaptchaFactory[] factories)
setFactories
in interface CaptchaEngine
factories
- new captcha factories for this enginepublic void swapCaptchasFromPersistentToVolatileMemory()
public void feedPersistentBuffer()
public ContainerConfiguration getConfig()
public CaptchaBuffer getPersistentBuffer()
public java.lang.Integer getPersistentFeedings()
public java.lang.Integer getPersistentMemoryHits()
public java.lang.Integer getPersistentToVolatileSwaps()
public CaptchaBuffer getVolatileBuffer()
public java.lang.Integer getVolatileMemoryHits()
public void closeBuffers()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |