|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ServicePool<Key,Service>
A service pool is like a connection pool but can pool any kind of objects.
Services that is capable of being pooled should implement the marker interfaceServicePoolAware
.
Notice the capacity is per key which means that each key can contain at most
(the capacity) services. The pool can contain an unbounded number of keys.
By default the capacity is set to 100.
Method Summary | |
---|---|
Service |
acquire(Key key)
Tries to acquire the service with the given key |
Service |
addAndAcquire(Key key,
Service service)
Adds the given service to the pool and acquires it. |
int |
getCapacity()
Gets the capacity per key. |
void |
purge()
Purges the pool. |
void |
release(Key key,
Service service)
Releases the service back to the pool |
void |
setCapacity(int capacity)
Sets the capacity, which is capacity per key. |
int |
size()
Returns the current size of the pool |
Method Detail |
---|
void setCapacity(int capacity)
capacity
- the capacity per keyint getCapacity()
Service addAndAcquire(Key key, Service service)
key
- the keyservice
- the service
java.lang.IllegalStateException
- if the queue is full (capacity has been reached)Service acquire(Key key)
key
- the key
void release(Key key, Service service)
key
- the keyservice
- the serviceint size()
void purge()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |