org.apache.camel.util
Class DefaultTimeoutMap

java.lang.Object
  extended by org.apache.camel.util.DefaultTimeoutMap
All Implemented Interfaces:
Runnable, TimeoutMap

public class DefaultTimeoutMap
extends Object
implements TimeoutMap, Runnable

Default implementation of the TimeoutMap.

Version:
$Revision: 747062 $

Constructor Summary
DefaultTimeoutMap()
           
DefaultTimeoutMap(ScheduledExecutorService executor, long requestMapPollTimeMillis)
           
 
Method Summary
protected  long currentTime()
           
 Object get(Object key)
          Looks up the value in the map by the given key.
 ScheduledExecutorService getExecutor()
           
 Object[] getKeys()
          Returns a copy of the keys in the map
 long getPurgePollTime()
           
protected  boolean isValidForEviction(TimeoutMapEntry entry)
          A hook to allow derivations to avoid evicting the current entry
 void purge()
          Purges any old entries from the map
 void put(Object key, Object value, long timeoutMillis)
          Adds the key value pair into the map such that some time after the given timeout the entry will be evicted
 void remove(Object id)
          Removes the object with the given key
 void run()
          The timer task which purges old requests and schedules another poll
protected  void schedulePoll()
          lets schedule each time to allow folks to change the time at runtime
 void setExecutor(ScheduledExecutorService executor)
          Sets the executor used to schedule purge events of inactive requests
 void setPurgePollTime(long purgePollTime)
          Sets the next purge poll time in milliseconds
 int size()
          Returns the size of the map
protected  void updateExpireTime(TimeoutMapEntry entry)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTimeoutMap

public DefaultTimeoutMap()

DefaultTimeoutMap

public DefaultTimeoutMap(ScheduledExecutorService executor,
                         long requestMapPollTimeMillis)
Method Detail

get

public Object get(Object key)
Description copied from interface: TimeoutMap
Looks up the value in the map by the given key.

Specified by:
get in interface TimeoutMap
Parameters:
key - the key of the value to search for
Returns:
the value for the given key or null if it is not present (or has timed out)

put

public void put(Object key,
                Object value,
                long timeoutMillis)
Description copied from interface: TimeoutMap
Adds the key value pair into the map such that some time after the given timeout the entry will be evicted

Specified by:
put in interface TimeoutMap

remove

public void remove(Object id)
Description copied from interface: TimeoutMap
Removes the object with the given key

Specified by:
remove in interface TimeoutMap
Parameters:
id - key for the object to remove

getKeys

public Object[] getKeys()
Description copied from interface: TimeoutMap
Returns a copy of the keys in the map

Specified by:
getKeys in interface TimeoutMap

size

public int size()
Description copied from interface: TimeoutMap
Returns the size of the map

Specified by:
size in interface TimeoutMap

run

public void run()
The timer task which purges old requests and schedules another poll

Specified by:
run in interface Runnable

purge

public void purge()
Description copied from interface: TimeoutMap
Purges any old entries from the map

Specified by:
purge in interface TimeoutMap

getPurgePollTime

public long getPurgePollTime()

setPurgePollTime

public void setPurgePollTime(long purgePollTime)
Sets the next purge poll time in milliseconds


getExecutor

public ScheduledExecutorService getExecutor()

setExecutor

public void setExecutor(ScheduledExecutorService executor)
Sets the executor used to schedule purge events of inactive requests


schedulePoll

protected void schedulePoll()
lets schedule each time to allow folks to change the time at runtime


isValidForEviction

protected boolean isValidForEviction(TimeoutMapEntry entry)
A hook to allow derivations to avoid evicting the current entry


updateExpireTime

protected void updateExpireTime(TimeoutMapEntry entry)

currentTime

protected long currentTime()


Copyright © 2009 Apache Software Foundation. All Rights Reserved.