public abstract class DefaultServicePool<Key,Service> extends ServiceSupport implements ServicePool<Key,Service>
| Modifier and Type | Field and Description |
|---|---|
protected int |
capacity |
protected org.slf4j.Logger |
log |
protected ConcurrentMap<Key,BlockingQueue<Service>> |
pool |
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Modifier | Constructor and Description |
|---|---|
protected |
DefaultServicePool() |
|
DefaultServicePool(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
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
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspendprotected final org.slf4j.Logger log
protected final ConcurrentMap<Key,BlockingQueue<Service>> pool
protected int capacity
protected DefaultServicePool()
public DefaultServicePool(int capacity)
public int getCapacity()
ServicePoolgetCapacity in interface ServicePool<Key,Service>public void setCapacity(int capacity)
ServicePoolsetCapacity in interface ServicePool<Key,Service>capacity - the capacity per keypublic int size()
ServicePoolsize in interface ServicePool<Key,Service>public Service addAndAcquire(Key key, Service service)
ServicePooladdAndAcquire in interface ServicePool<Key,Service>key - the keyservice - the servicepublic Service acquire(Key key)
ServicePoolacquire in interface ServicePool<Key,Service>key - the keypublic void release(Key key, Service service)
ServicePoolrelease in interface ServicePool<Key,Service>key - the keyservice - the servicepublic void purge()
ServicePoolpurge in interface ServicePool<Key,Service>protected void doStart()
throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop()
throws Exception
ServiceSupportServiceSupport.doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.doStop in class ServiceSupportExceptionServiceSupport.doStart()Apache Camel