|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectorg.makumba.db.makumba.ResourcePool
public abstract class ResourcePool
Keeps a number of identical creation-expensive resources. Avoids resource re-creation/deletion TODO: this class should be replaced by one more generic pool that exists out there
| Field Summary | |
|---|---|
(package private) Vector<Object> |
all
|
(package private) WeakReference<ResourcePool> |
poolRef
a weak reference to ourselves, for usage by foreign objects |
(package private) long |
sleeping
|
(package private) Stack<Object> |
stack
|
(package private) long |
stale
|
(package private) Thread |
stalePreventionThread
|
(package private) Stack<Date> |
timeStack
|
| Constructor Summary | |
|---|---|
ResourcePool()
|
|
| Method Summary | |
|---|---|
void |
close()
clear all resource containers. if we have a stale prevention thread, we interrupt it |
void |
close(Object o)
close a resource |
abstract Object |
create()
re-define this method to express how to create a resource |
(package private) Object |
createAndCount()
create a new resource |
protected void |
finalize()
|
Object |
get()
get one resource |
int |
getSize()
|
void |
init(int n)
initialize the pool with n resources |
void |
put(Object o)
put back one resource |
void |
renew(Object o)
refresh a resource that was unused for a long time to prevent it from staling |
protected void |
renewAll()
check for stale resources and renew the rotten ones |
void |
startStalePreventionThread(long sleepingTime,
long staleTime)
start a stale prevention thread |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
Stack<Object> stack
Stack<Date> timeStack
Vector<Object> all
WeakReference<ResourcePool> poolRef
long sleeping
long stale
Thread stalePreventionThread
| Constructor Detail |
|---|
public ResourcePool()
| Method Detail |
|---|
public abstract Object create()
throws Exception
Exception
Object createAndCount()
throws Exception
Exception
public void init(int n)
throws Exception
Exception
public Object get()
throws Exception
Exceptionpublic void put(Object o)
public void close()
protected void finalize()
finalize in class Objectpublic void renew(Object o)
public void close(Object o)
public void startStalePreventionThread(long sleepingTime,
long staleTime)
protected void renewAll()
public int getSize()
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||