org.apache.camel.impl
Class ConsumerCache

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.ConsumerCache
All Implemented Interfaces:
Service, ShutdownableService, StatefulService, SuspendableService

public class ConsumerCache
extends ServiceSupport

Cache containing created Consumer.

Version:

Field Summary
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
ConsumerCache(Object source, CamelContext camelContext)
           
ConsumerCache(Object source, CamelContext camelContext, int cacheSize)
           
ConsumerCache(Object source, CamelContext camelContext, Map<String,PollingConsumer> cache)
           
 
Method Summary
protected static LRUCache<String,PollingConsumer> createLRUCache(int cacheSize)
          Creates the LRUCache to be used.
protected  void doStart()
          Implementations override this method to support customized start/stop.
protected  void doStop()
          Implementations override this method to support customized start/stop.
 CamelContext getCamelContext()
           
 int getCapacity()
          Gets the maximum cache size (capacity).
 PollingConsumer getConsumer(Endpoint endpoint)
           
 long getEvicted()
          Gets the cache evicted statistic

Will return -1 if it cannot determine this if a custom cache was used.

 long getHits()
          Gets the cache hits statistic

Will return -1 if it cannot determine this if a custom cache was used.

 long getMisses()
          Gets the cache misses statistic

Will return -1 if it cannot determine this if a custom cache was used.

 Object getSource()
          Gets the source which uses this cache
 void purge()
          Purges this cache
 Exchange receive(Endpoint endpoint)
           
 Exchange receive(Endpoint endpoint, long timeout)
           
 Exchange receiveNoWait(Endpoint endpoint)
           
 void resetCacheStatistics()
          Resets the cache statistics
 int size()
          Returns the current size of the cache
 String toString()
           
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsumerCache

public ConsumerCache(Object source,
                     CamelContext camelContext)

ConsumerCache

public ConsumerCache(Object source,
                     CamelContext camelContext,
                     int cacheSize)

ConsumerCache

public ConsumerCache(Object source,
                     CamelContext camelContext,
                     Map<String,PollingConsumer> cache)
Method Detail

createLRUCache

protected static LRUCache<String,PollingConsumer> createLRUCache(int cacheSize)
Creates the LRUCache to be used.

This implementation returns a LRUCache instance.

Parameters:
cacheSize - the cache size
Returns:
the cache

getConsumer

public PollingConsumer getConsumer(Endpoint endpoint)

receive

public Exchange receive(Endpoint endpoint)

receive

public Exchange receive(Endpoint endpoint,
                        long timeout)

receiveNoWait

public Exchange receiveNoWait(Endpoint endpoint)

getCamelContext

public CamelContext getCamelContext()

getSource

public Object getSource()
Gets the source which uses this cache

Returns:
the source

size

public int size()
Returns the current size of the cache

Returns:
the current size

getCapacity

public int getCapacity()
Gets the maximum cache size (capacity).

Will return -1 if it cannot determine this if a custom cache was used.

Returns:
the capacity

getHits

public long getHits()
Gets the cache hits statistic

Will return -1 if it cannot determine this if a custom cache was used.

Returns:
the hits

getMisses

public long getMisses()
Gets the cache misses statistic

Will return -1 if it cannot determine this if a custom cache was used.

Returns:
the misses

getEvicted

public long getEvicted()
Gets the cache evicted statistic

Will return -1 if it cannot determine this if a custom cache was used.

Returns:
the evicted

resetCacheStatistics

public void resetCacheStatistics()
Resets the cache statistics


purge

public void purge()
Purges this cache


toString

public String toString()
Overrides:
toString in class Object

doStart

protected void doStart()
                throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: See ServiceSupport.doStop() for more details.

Specified by:
doStart in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStop()

doStop

protected void doStop()
               throws Exception
Description copied from class: ServiceSupport
Implementations override this method to support customized start/stop.

Important: Camel will invoke this ServiceSupport.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.

Specified by:
doStop in class ServiceSupport
Throws:
Exception
See Also:
ServiceSupport.doStart()


Apache CAMEL