org.enhydra.shark.caching
Class LRUProcessCache

java.lang.Object
  extended byorg.enhydra.shark.caching.LRUProcessCache
All Implemented Interfaces:
ObjectCache, ProcessCache

public class LRUProcessCache
extends java.lang.Object
implements ProcessCache

This class is LRU (least recently used mechanism) cache for storing processes.

Author:
Sasa Bojanic, Tanja Jovanovic

Field Summary
protected  org.enhydra.shark.utilities.LRUMap cache
          LRU process cache.
 
Constructor Summary
LRUProcessCache()
           
 
Method Summary
 void add(java.lang.String procId, WfProcessInternal proc)
          Adds process to the process cache.
 void configure(CallbackUtilities cus)
          Configures proccess cache.
 WfProcessInternal get(java.lang.String procId)
          Returns the process from the process cache with id procId.
 java.util.List getAll()
          Returns all processes from the process cache.
 int getSize()
          Returns the size of the process cache.
 int howManyEntries()
           
 void remove(java.lang.String procId)
          Removes process from the process cache.
 void setSize(int size)
          Sets size of the process cache to value size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected org.enhydra.shark.utilities.LRUMap cache
LRU process cache.

Constructor Detail

LRUProcessCache

public LRUProcessCache()
Method Detail

configure

public void configure(CallbackUtilities cus)
               throws java.lang.Exception
Configures proccess cache.

Specified by:
configure in interface ObjectCache
Parameters:
cus - an instance of CallbackUtilities used to get properties for configuring proccess cache.
Throws:
java.lang.Exception - Thrown if an error occurs.

add

public void add(java.lang.String procId,
                WfProcessInternal proc)
         throws java.lang.Exception
Adds process to the process cache.

Specified by:
add in interface ProcessCache
Parameters:
procId - Process id.
proc - WfProcessInternal object to be added to the process cache.
Throws:
java.lang.Exception - Thrown if an error occurs.

remove

public void remove(java.lang.String procId)
            throws java.lang.Exception
Removes process from the process cache.

Specified by:
remove in interface ProcessCache
Parameters:
procId - Process id.
Throws:
java.lang.Exception - Thrown if an error occurs.

get

public WfProcessInternal get(java.lang.String procId)
                      throws java.lang.Exception
Returns the process from the process cache with id procId.

Specified by:
get in interface ProcessCache
Parameters:
procId - Process id.
Returns:
Process from the cache with the id procId if exists, otherwise null.
Throws:
java.lang.Exception - Thrown if an error occurs.

setSize

public void setSize(int size)
             throws java.lang.Exception
Sets size of the process cache to value size. The value 0 means that the cache is disabled. The negative value means that the cache is unbounded. The positive number defines max number of cache entries.

Specified by:
setSize in interface ObjectCache
Parameters:
size - New size of the process cache.
Throws:
java.lang.Exception - Thrown if an error occurs.

getSize

public int getSize()
            throws java.lang.Exception
Returns the size of the process cache.

Specified by:
getSize in interface ObjectCache
Returns:
Size of the process cache.
Throws:
java.lang.Exception - Thrown if an error occurs.

howManyEntries

public int howManyEntries()
                   throws java.lang.Exception
Specified by:
howManyEntries in interface ObjectCache
Throws:
java.lang.Exception

getAll

public java.util.List getAll()
                      throws java.lang.Exception
Returns all processes from the process cache.

Specified by:
getAll in interface ObjectCache
Returns:
All processes from the cache as List.
Throws:
java.lang.Exception - Thrown if an error occurs.