org.logicblaze.lingo.util
Class DefaultTimeoutMap

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

public class DefaultTimeoutMap
extends java.lang.Object
implements TimeoutMap, java.lang.Runnable

Version:
$Revision$

Constructor Summary
DefaultTimeoutMap()
           
DefaultTimeoutMap(edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService executor, long requestMapPollTimeMillis)
           
 
Method Summary
protected  long currentTime()
           
 java.lang.Object get(java.lang.Object key)
          Looks up the value in the map by the given key.
 edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService getExecutor()
           
 java.lang.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(java.lang.Object key, java.lang.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(java.lang.Object id)
           
 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(edu.emory.mathcs.backport.java.util.concurrent.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
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(edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService executor,
                         long requestMapPollTimeMillis)
Method Detail

get

public java.lang.Object get(java.lang.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(java.lang.Object key,
                java.lang.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(java.lang.Object id)
Specified by:
remove in interface TimeoutMap

getKeys

public java.lang.Object[] getKeys()
Returns a copy of the keys in the map

Specified by:
getKeys in interface TimeoutMap

run

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

Specified by:
run in interface java.lang.Runnable

purge

public void purge()
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 edu.emory.mathcs.backport.java.util.concurrent.ScheduledExecutorService getExecutor()

setExecutor

public void setExecutor(edu.emory.mathcs.backport.java.util.concurrent.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

Parameters:
entry -
Returns:

updateExpireTime

protected void updateExpireTime(TimeoutMapEntry entry)

currentTime

protected long currentTime()


Copyright © 2009 LogicBlaze, Inc.. All Rights Reserved.