org.apache.camel.spi
Interface ServicePool<Key,Service>

All Known Implementing Classes:
DefaultProducerServicePool, DefaultServicePool, SharedProducerServicePool

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 interface ServicePoolAware.

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.

Version:
$Revision: 18643 $

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 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

setCapacity

void setCapacity(int capacity)
Sets the capacity, which is capacity per key.

Parameters:
capacity - the capacity per key

getCapacity

int getCapacity()
Gets the capacity per key.

Returns:
the capacity per key

addAndAcquire

Service addAndAcquire(Key key,
                      Service service)
Adds the given service to the pool and acquires it.

Parameters:
key - the key
service - the service
Returns:
the acquired service, is newer null
Throws:
IllegalStateException - if the queue is full (capacity has been reached)

acquire

Service acquire(Key key)
Tries to acquire the service with the given key

Parameters:
key - the key
Returns:
the acquired service, or null if no free in pool

release

void release(Key key,
             Service service)
Releases the service back to the pool

Parameters:
key - the key
service - the service

size

int size()
Returns the current size of the pool

Returns:
the current size of the pool


Apache CAMEL