org.xmlecho.palomar.cache
Class AbstractCache

java.lang.Object
  extended byorg.xmlecho.palomar.cache.AbstractCache
All Implemented Interfaces:
Cache, org.xmlecho.palomar.cron.Job, org.xmlecho.palomar.cron.Refreshable
Direct Known Subclasses:
DumbCache, SmartCache

public abstract class AbstractCache
extends java.lang.Object
implements Cache

Abstract class for common implementations of IrisCache.


Field Summary
protected  java.lang.String _type
          identifier for this cache
protected  long lastRefreshTime
           
protected  java.util.Properties myProperties
           
protected  long refreshFrequency
          Refresh frequency.
 
Constructor Summary
AbstractCache()
           
 
Method Summary
 java.lang.String getCacheDir()
          returns the directory to be used for caching
 java.lang.String getCronExpr()
          get cron expression for this job, returns a empty string as all cache jobs are type refreshable i.e.
 java.lang.String getJobGroupName()
          get group name for this cron job, several jobs can belong to a group
 java.lang.String getJobName()
          get name for this cron job
 java.util.Iterator getKeys(java.util.Map typeMap)
          Method for getting an Iterator on keys for a particular Collection object
 int getMaxCacheSize()
          returns the maximum holding capacity of this cache instance
 long getNextRefreshTime()
          Returns the next refreshing time in milliseconds from now
 java.util.Iterator getObjects(java.util.Map typeMap)
          Method for getting an Iterator on values for a particular Collection object
 java.util.Properties getProperties()
          Return the characteristics of a specific implementation of IrisCache
 long getRefreshFreq()
           
 long getRefreshInterval()
          get refresh interval for this cache
 java.lang.String getType()
          Get the object type this cache is holding
 boolean isEmpty(java.util.Map typeMap)
          Method for testing the capacity of a passed Map.
 boolean isTimeToRefresh()
          Checks to see if it is the right time to refresh
 void runJob()
          run this cron job
 void setMaxCacheSize(int maxCacheSize)
          setter for maximum capacity this cache can hold
 void setRefreshFreq(long refreshFrequency)
          The default refresh period
protected  void setRefreshTime(long refreshedAt)
           
protected  void setType(java.lang.String type)
          Set the object type this cache has to hold
protected  boolean shouldNotify(java.lang.String cacheName)
           
protected  void trimProperties(java.util.Properties initialProperties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xmlecho.palomar.cache.Cache
clear, get, invalidate, put, putMutable, remove, setProperties
 
Methods inherited from interface org.xmlecho.palomar.cron.Refreshable
getRunnable, refresh, willWantRefresh
 

Field Detail

refreshFrequency

protected long refreshFrequency
Refresh frequency. Will be set as part of initialization.


_type

protected java.lang.String _type
identifier for this cache


lastRefreshTime

protected long lastRefreshTime

myProperties

protected java.util.Properties myProperties
Constructor Detail

AbstractCache

public AbstractCache()
Method Detail

isTimeToRefresh

public boolean isTimeToRefresh()
Checks to see if it is the right time to refresh

Specified by:
isTimeToRefresh in interface org.xmlecho.palomar.cron.Refreshable
Returns:
boolean true, if it is time to refresh

getType

public java.lang.String getType()
Get the object type this cache is holding

Specified by:
getType in interface Cache

setType

protected void setType(java.lang.String type)
Set the object type this cache has to hold

Parameters:
type - can only be set by subclasses

getNextRefreshTime

public long getNextRefreshTime()
Returns the next refreshing time in milliseconds from now

Specified by:
getNextRefreshTime in interface org.xmlecho.palomar.cron.Refreshable

setRefreshTime

protected void setRefreshTime(long refreshedAt)

setRefreshFreq

public void setRefreshFreq(long refreshFrequency)
Description copied from interface: Cache
The default refresh period

Specified by:
setRefreshFreq in interface Cache

getRefreshFreq

public long getRefreshFreq()

setMaxCacheSize

public void setMaxCacheSize(int maxCacheSize)
Description copied from interface: Cache
setter for maximum capacity this cache can hold

Specified by:
setMaxCacheSize in interface Cache

getMaxCacheSize

public int getMaxCacheSize()
Description copied from interface: Cache
returns the maximum holding capacity of this cache instance

Specified by:
getMaxCacheSize in interface Cache

getCacheDir

public java.lang.String getCacheDir()
returns the directory to be used for caching

Specified by:
getCacheDir in interface Cache

trimProperties

protected void trimProperties(java.util.Properties initialProperties)

getProperties

public java.util.Properties getProperties()
Description copied from interface: Cache
Return the characteristics of a specific implementation of IrisCache

Specified by:
getProperties in interface Cache
Returns:
Properties

isEmpty

public boolean isEmpty(java.util.Map typeMap)
Method for testing the capacity of a passed Map.

Parameters:
typeMap - a Collection object
Returns:
boolean flag on the capacity of a particular Map.

getKeys

public java.util.Iterator getKeys(java.util.Map typeMap)
Method for getting an Iterator on keys for a particular Collection object


getObjects

public java.util.Iterator getObjects(java.util.Map typeMap)
Method for getting an Iterator on values for a particular Collection object


shouldNotify

protected boolean shouldNotify(java.lang.String cacheName)

getRefreshInterval

public long getRefreshInterval()
get refresh interval for this cache

Specified by:
getRefreshInterval in interface org.xmlecho.palomar.cron.Refreshable

runJob

public void runJob()
            throws java.lang.Exception
run this cron job

Specified by:
runJob in interface org.xmlecho.palomar.cron.Job
Throws:
java.lang.Exception

getCronExpr

public java.lang.String getCronExpr()
get cron expression for this job, returns a empty string as all cache jobs are type refreshable i.e. scheduled to repeat after specified refresh interval

Specified by:
getCronExpr in interface org.xmlecho.palomar.cron.Job

getJobName

public java.lang.String getJobName()
get name for this cron job

Specified by:
getJobName in interface org.xmlecho.palomar.cron.Job

getJobGroupName

public java.lang.String getJobGroupName()
get group name for this cron job, several jobs can belong to a group

Specified by:
getJobGroupName in interface org.xmlecho.palomar.cron.Job