org.enhydra.shark
Class ActivityCache

java.lang.Object
  extended by org.enhydra.shark.ActivityCache

public class ActivityCache
extends java.lang.Object

Cache for storing process's activities.

Author:
Sasa Bojanic

Field Summary
protected  boolean allLoaded
           
protected  java.util.Map cache
          Activity cache.
protected  boolean openLoaded
           
protected  WfProcessInternal proc
           
 
Constructor Summary
ActivityCache(WfProcessInternal proc, boolean newProcessInstance)
          Creates activity cache for the process instance.
 
Method Summary
 void add(java.lang.String actId, WfActivityInternal act)
          Adds activity to the cache.
 void clear()
          Removes all the activities from the cache.
 void clearOpen(WMSessionHandle shandle)
          Removes only the open activities from the cache.
 ActivityCache duplicate(WfProcessInternal p)
          Duplicates this cache to be used in another process instance.
protected  WfActivityInternal get(java.lang.String actId)
          Returns specific activity from the cache.
 java.util.List getAll(WMSessionHandle shandle)
          Returns all the activities for the process.
 WfActivityInternal getAny(WMSessionHandle shandle, java.lang.String procId, java.lang.String actId)
          Returns the activity for the given Id.
 java.util.List getOpen(WMSessionHandle shandle)
          Returns all the open activities for the process.
 WfActivityInternal getOpen(WMSessionHandle shandle, java.lang.String actId)
          Returns the open activity for the given Id.
 int howManyEntries()
          Returns how many activities are currently in the cache.
 void loadAll(WMSessionHandle shandle)
          Loads all the activities for the process from DB into the cache.
protected  void loadAny(WMSessionHandle shandle, java.lang.String procId, java.lang.String actId)
          Loads specific activity from DB into the cache.
 void loadOpen(WMSessionHandle shandle)
          Loads all the open activities for the process from DB into the cache.
 WfActivityInternal remove(java.lang.String actId)
          Removes activity from the cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected java.util.Map cache
Activity cache.


proc

protected WfProcessInternal proc

openLoaded

protected boolean openLoaded

allLoaded

protected boolean allLoaded
Constructor Detail

ActivityCache

public ActivityCache(WfProcessInternal proc,
                     boolean newProcessInstance)
Creates activity cache for the process instance.

Method Detail

add

public void add(java.lang.String actId,
                WfActivityInternal act)
Adds activity to the cache.

Parameters:
actId - Activity id.
act - WfActivityInternal object to be added to the cache.

remove

public WfActivityInternal remove(java.lang.String actId)
Removes activity from the cache.

Parameters:
actId - Activity id.

get

protected WfActivityInternal get(java.lang.String actId)
Returns specific activity from the cache.

Parameters:
actId - Activity id.
Returns:
Activity from the cache for the given Id if exists, otherwise null.

howManyEntries

public int howManyEntries()
Returns how many activities are currently in the cache.


clear

public void clear()
Removes all the activities from the cache.


clearOpen

public void clearOpen(WMSessionHandle shandle)
               throws java.lang.Exception
Removes only the open activities from the cache.

Throws:
java.lang.Exception

getAll

public java.util.List getAll(WMSessionHandle shandle)
                      throws java.lang.Exception
Returns all the activities for the process. If there was no query to DB in order to get all the activities (and this is not a cache for the new process instance), the query will be performed, and cache will be filled before returning the result.

Throws:
java.lang.Exception

getOpen

public java.util.List getOpen(WMSessionHandle shandle)
                       throws java.lang.Exception
Returns all the open activities for the process. If there was no query to DB in order to get all the open activities (and this is not a cache for the new process instance), the query will be performed, and cache will be filled before returning the result.

Throws:
java.lang.Exception

getAny

public WfActivityInternal getAny(WMSessionHandle shandle,
                                 java.lang.String procId,
                                 java.lang.String actId)
                          throws java.lang.Exception
Returns the activity for the given Id. If there is no such activity in the cache, there will be a query on DB that will fill the cache with the given activity if it exists.

Throws:
java.lang.Exception

getOpen

public WfActivityInternal getOpen(WMSessionHandle shandle,
                                  java.lang.String actId)
                           throws java.lang.Exception
Returns the open activity for the given Id. If there is no such activity in the cache, there will be a query on DB that will fill the cache with all open activities.

Throws:
java.lang.Exception

loadAll

public void loadAll(WMSessionHandle shandle)
             throws java.lang.Exception
Loads all the activities for the process from DB into the cache.

Throws:
java.lang.Exception

loadOpen

public void loadOpen(WMSessionHandle shandle)
              throws java.lang.Exception
Loads all the open activities for the process from DB into the cache.

Throws:
java.lang.Exception

loadAny

protected void loadAny(WMSessionHandle shandle,
                       java.lang.String procId,
                       java.lang.String actId)
                throws java.lang.Exception
Loads specific activity from DB into the cache.

Throws:
java.lang.Exception

duplicate

public ActivityCache duplicate(WfProcessInternal p)
                        throws java.lang.Exception
Duplicates this cache to be used in another process instance.

Throws:
java.lang.Exception