org.apache.camel.impl
Class DefaultServicePool<Key,Service>
java.lang.Object
org.apache.camel.impl.ServiceSupport
org.apache.camel.impl.DefaultServicePool<Key,Service>
- All Implemented Interfaces:
- Service, ServicePool<Key,Service>
- Direct Known Subclasses:
- DefaultProducerServicePool
public abstract class DefaultServicePool<Key,Service>
- extends ServiceSupport
- implements ServicePool<Key,Service>
Default implementation to inherit for a basic service pool.
- Version:
- $Revision: 779038 $
Methods inherited from class org.apache.camel.impl.ServiceSupport |
addChildService, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, start, stop |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected final org.apache.commons.logging.Log log
pool
protected final ConcurrentHashMap<Key,BlockingQueue<Service>> pool
capacity
protected final int capacity
DefaultServicePool
public DefaultServicePool(int capacity)
- The capacity, note this is per key.
- Parameters:
capacity
- the capacity per key.
addAndAcquire
public Service addAndAcquire(Key key,
Service service)
- Description copied from interface:
ServicePool
- Adds the given service to the pool and acquires it.
- Specified by:
addAndAcquire
in interface ServicePool<Key,Service>
- Parameters:
key
- the keyservice
- the service
- Returns:
- the acquired service, is newer null
acquire
public Service acquire(Key key)
- Description copied from interface:
ServicePool
- Tries to acquire the service with the given key
- Specified by:
acquire
in interface ServicePool<Key,Service>
- Parameters:
key
- the key
- Returns:
- the acquired service, or null if no free in pool
release
public void release(Key key,
Service service)
- Description copied from interface:
ServicePool
- Releases the service back to the pool
- Specified by:
release
in interface ServicePool<Key,Service>
- Parameters:
key
- the keyservice
- the service
doStart
protected void doStart()
throws Exception
- Specified by:
doStart
in class ServiceSupport
- Throws:
Exception
doStop
protected void doStop()
throws Exception
- Specified by:
doStop
in class ServiceSupport
- Throws:
Exception
Copyright © 2007-2009 The Apache Software Foundation. All Rights Reserved.