org.apache.camel.impl
Class ConsumerCache

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

public class ConsumerCache
extends ServiceSupport

Cache containing created Consumer.

Version:

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()
           
protected  void doStop()
           
 CamelContext getCamelContext()
           
 int getCapacity()
          Gets the maximum cache size (capacity).
 PollingConsumer getConsumer(Endpoint endpoint)
           
 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.impl.ServiceSupport
addChildService, doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, removeChildService, resume, shutdown, start, 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 LRUSoftCache 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

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
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception


Apache CAMEL