|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SK.gnome.dwarf.GenericService SK.gnome.dwarf.utils.cache.SimplePool
This class implements simple object pool with a maximum size limit.
This service implements the Pool
interface. The maximum size of the pool may
be specified via the setSize(int)
method. If the size is zero, the pool may grow
forever.
This pool implementation is thread-safe.
Field Summary |
Fields inherited from class SK.gnome.dwarf.GenericService |
initParameters, parent |
Fields inherited from interface SK.gnome.dwarf.Service |
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED |
Constructor Summary | |
SimplePool(java.lang.String name)
Creates a new SimplePool with no size limit. |
Method Summary | |
void |
clear()
Removes all objects from the pool. |
java.lang.Object |
get()
Gets an object from the pool. |
boolean |
put(java.lang.Object obj)
Puts the object to the pool. |
java.lang.String |
report()
Returns the service report. |
void |
setSize(int size)
Sets the maximum pool size limit. |
void |
shutdown()
Shuts down the service; It clears the pool content as well by calling clear() . |
Methods inherited from class SK.gnome.dwarf.GenericService |
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, init, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, start, stop, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimplePool(java.lang.String name)
Method Detail |
public void setSize(int size)
Zero value means no limit, which is the default for newly created SimplePool objects.
size
- the maximum size of the poolput(Object)
public void shutdown()
It clears the pool content as well by calling clear()
.
shutdown
in interface Service
shutdown
in class GenericService
public boolean put(java.lang.Object obj)
The new object is put to the pool only if the maximum size limit is greater than the current pool size.
put
in interface Pool
obj
- the cached object
public java.lang.Object get()
Pool
The object is removed from the pool and returned to the caller.
If an object implementing the Cacheable
interface is being removed from the
pool, the Cacheable.handleCacheEvent(Cacheable.CacheEvent)
method must be
invoked on it with the Cacheable.CacheEvent.REMOVED
value.
get
in interface Pool
public void clear()
Pool
If an object implementing the Cacheable
interface is being removed from the
pool, the Cacheable.handleCacheEvent(Cacheable.CacheEvent)
method must be invoked
on it with the Cacheable.CacheEvent.INVALIDATED
value.
clear
in interface Pool
public java.lang.String report()
Returns the current/peak/total number of cached objects plus the number of pool hits and misses so far.
Note: When clearing the pool via the clear()
method, only the current number
of the cached entries is reset to zero.
report
in interface Reportable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |