org.apache.openejb.core.stateful
Class SimpleCache<K,V>

java.lang.Object
  extended by org.apache.openejb.core.stateful.SimpleCache<K,V>
All Implemented Interfaces:
Cache<K,V>

public class SimpleCache<K,V>
extends Object
implements Cache<K,V>


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.openejb.core.stateful.Cache
Cache.CacheFilter<V>, Cache.CacheListener<V>, Cache.TimeOut
 
Field Summary
static Logger logger
           
 
Constructor Summary
SimpleCache()
           
SimpleCache(Cache.CacheListener<V> listener, PassivationStrategy passivator, int capacity, int bulkPassivate, Duration timeOut)
           
 
Method Summary
 void add(K key, V value)
          Add a new entry to the cache.
 void checkIn(K key)
          Marks the entry available, so it can be accessed again.
 V checkOut(K key, boolean loadEntryIfNotFound)
          Marks the entry checked-out, so this entry can not be accessed until checked-in.
 void destroy()
          Destroy the cache.
 int getBulkPassivate()
           
 int getCapacity()
           
 long getFrequency()
           
 Cache.CacheListener<V> getListener()
          Gets the listener for cache events.
 PassivationStrategy getPassivator()
           
 ScheduledExecutorService getScheduledExecutorService()
           
 long getTimeOut()
           
 void init()
          Initialize the cache.
 void processLRU()
           
 V remove(K key)
          Removes the entry from the cache.
 void removeAll(Cache.CacheFilter<V> filter)
          Removes all of the entries that match the specified filter.
 void setBulkPassivate(int bulkPassivate)
           
 void setCapacity(int capacity)
           
 void setFrequency(String frequency)
           
 void setListener(Cache.CacheListener<V> listener)
          Sets the listener for cache events.
 void setPassivator(Class<? extends PassivationStrategy> passivatorClass)
           
 void setPassivator(PassivationStrategy passivator)
           
 void setPoolSize(int capacity)
           
 void setScheduledExecutorService(ScheduledExecutorService executor)
           
 void setTimeOut(String timeOut)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static final Logger logger
Constructor Detail

SimpleCache

public SimpleCache()

SimpleCache

public SimpleCache(Cache.CacheListener<V> listener,
                   PassivationStrategy passivator,
                   int capacity,
                   int bulkPassivate,
                   Duration timeOut)
Method Detail

init

public void init()
Description copied from interface: Cache
Initialize the cache.

Specified by:
init in interface Cache<K,V>

destroy

public void destroy()
Description copied from interface: Cache
Destroy the cache.

Specified by:
destroy in interface Cache<K,V>

getListener

public Cache.CacheListener<V> getListener()
Description copied from interface: Cache
Gets the listener for cache events.

Specified by:
getListener in interface Cache<K,V>

setListener

public void setListener(Cache.CacheListener<V> listener)
Description copied from interface: Cache
Sets the listener for cache events. This should be called by the container before using the cache.

Specified by:
setListener in interface Cache<K,V>

getPassivator

public PassivationStrategy getPassivator()

setPassivator

public void setPassivator(PassivationStrategy passivator)

setPassivator

public void setPassivator(Class<? extends PassivationStrategy> passivatorClass)
                   throws Exception
Throws:
Exception

getCapacity

public int getCapacity()

setCapacity

public void setCapacity(int capacity)

setPoolSize

public void setPoolSize(int capacity)

getBulkPassivate

public int getBulkPassivate()

setBulkPassivate

public void setBulkPassivate(int bulkPassivate)

getTimeOut

public long getTimeOut()

setTimeOut

public void setTimeOut(String timeOut)

setScheduledExecutorService

public void setScheduledExecutorService(ScheduledExecutorService executor)

getScheduledExecutorService

public ScheduledExecutorService getScheduledExecutorService()

setFrequency

public void setFrequency(String frequency)

getFrequency

public long getFrequency()

add

public void add(K key,
                V value)
Description copied from interface: Cache
Add a new entry to the cache. The entry is marked checked-out and can not be accessed again until checked-in.

Specified by:
add in interface Cache<K,V>

checkOut

public V checkOut(K key,
                  boolean loadEntryIfNotFound)
           throws Exception
Description copied from interface: Cache
Marks the entry checked-out, so this entry can not be accessed until checked-in.

Specified by:
checkOut in interface Cache<K,V>
Throws:
IllegalStateException - if the entry is already checked out.
Exception - if an entry is loaded and the afterLoad method threw an exception

checkIn

public void checkIn(K key)
Description copied from interface: Cache
Marks the entry available, so it can be accessed again.

Specified by:
checkIn in interface Cache<K,V>

remove

public V remove(K key)
Description copied from interface: Cache
Removes the entry from the cache.

Specified by:
remove in interface Cache<K,V>

removeAll

public void removeAll(Cache.CacheFilter<V> filter)
Description copied from interface: Cache
Removes all of the entries that match the specified filter.

Specified by:
removeAll in interface Cache<K,V>

processLRU

public void processLRU()


Copyright © 1999–2015 The Apache Software Foundation. All rights reserved.