|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jalios.jcms.db.BasicDBListener com.jalios.jcms.db.BasicDBListenerStoreListener com.jalios.jcms.CacheManager
public class CacheManager
This class manages the cache of content fragements.
Cache entries can be invalidated either manually (see clearContent() method), or when a timeout is reached or when a mutation occurs on a set of (Storable) classes.
Nested Class Summary | |
---|---|
class |
CacheManager.CacheEntry
|
Field Summary | |
---|---|
protected Channel |
channel
|
protected Map<Class<?>,HashSet<String>> |
classMap
|
protected Map<String,CacheManager.CacheEntry> |
contentMap
|
protected boolean |
isDisabled
|
protected int |
maxServersCacheNbr
|
static String |
REVISION
|
protected Map<String,String> |
serversCacheIdMap
|
Fields inherited from interface com.jalios.util.JaliosConstants |
---|
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR |
Constructor Summary | |
---|---|
|
CacheManager()
Constructs a new CacheManager |
protected |
CacheManager(boolean failsafeMode)
|
Method Summary | |
---|---|
String |
addEntry(String contentId,
javax.servlet.http.HttpSession session,
boolean sessionScope,
String content,
Class<?>[] classes,
long timeout,
Map<?,?> extraInfoMap)
Add a new cache entry |
String |
buildEntryId(String contentId,
String sessionId)
Build the entry id given the content's id and the associated session id. |
Collection<CacheManager.CacheEntry> |
getCacheEntries()
Get all the cache entries |
CacheManager.CacheEntry |
getCacheEntry(String id)
Get the CacheEntry from a given entry's id. |
static CacheManager |
getFailSafeModeInstance()
|
int |
getMaxServersCacheNbr()
|
int |
getSize()
Get the size of the cache (ie the count of cache entries). |
void |
handleCommitUpdate(Storable storable,
Storable oldStorable,
boolean firstTime)
This method gets called when after a storable has been updated. |
void |
handleCreate(Storable storable,
boolean firstTime)
This method gets called when a storable is created. |
void |
handleDelete(Storable storable,
boolean firstTime)
This method gets called when a storable is deleted. |
void |
invalidateClass(Class<?> clazz)
Invalidate the content of all entries bound to the given class |
boolean |
isCached(String id)
Check if their is a cache entry associated with the given id. |
boolean |
isDisabled()
|
void |
onPostDelete(DBData data,
org.hibernate.event.PostDeleteEvent event,
boolean firstTime)
|
void |
onPostInsert(DBData data,
org.hibernate.event.PostInsertEvent event,
boolean firstTime)
|
void |
onPostUpdate(DBData data,
org.hibernate.event.PostUpdateEvent event,
boolean firstTime)
|
void |
reinitialize()
Reinitialize the CacheManager. |
void |
removeAllEntries()
Clear all the cache entries. |
void |
removeAllSessionEntries()
Clear all the session cache entries. |
void |
removeEntry(String id)
Remove a cache entry referenced with is id. |
void |
removeSessionEntries(javax.servlet.http.HttpSession session)
Clear all the session cache entries for a given session |
void |
valueBound(javax.servlet.http.HttpSessionBindingEvent event)
|
void |
valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
|
Methods inherited from class com.jalios.jcms.db.BasicDBListenerStoreListener |
---|
handlePrepareUpdate |
Methods inherited from class com.jalios.jcms.db.BasicDBListener |
---|
getAdateFromState, getAuthorIdFromState, getCdateFromState, getEdateFromState, getMdateFromState, getPdateFromState, getPrePstatus, getPrePstatus, getPstatusFromState, hasNoChange, hasNoChange, init, onPreUpdate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String REVISION
protected transient boolean isDisabled
protected transient Channel channel
protected final transient Map<String,CacheManager.CacheEntry> contentMap
protected final transient Map<Class<?>,HashSet<String>> classMap
protected transient int maxServersCacheNbr
protected transient Map<String,String> serversCacheIdMap
Constructor Detail |
---|
public CacheManager()
protected CacheManager(boolean failsafeMode)
Method Detail |
---|
public static CacheManager getFailSafeModeInstance()
public void reinitialize()
public boolean isDisabled()
public int getMaxServersCacheNbr()
public String buildEntryId(String contentId, String sessionId)
contentId
- the content idsessionId
- the http session id
public String addEntry(String contentId, javax.servlet.http.HttpSession session, boolean sessionScope, String content, Class<?>[] classes, long timeout, Map<?,?> extraInfoMap)
contentId
- the id of contentsession
- the sessionsessionScope
- should the cache entry be stored for this sessioncontent
- the content to be cachedclasses
- an array of classes to listen. Each time a
mutation occurs on a (visible) instance of the classes
the content of the cache is cleared.timeout
- the timeout of this entry (in minutes)extraInfoMap
- any contextual data to the cache being created
public boolean isCached(String id)
id
- the CacheEntry's id
public int getSize()
public Collection<CacheManager.CacheEntry> getCacheEntries()
public CacheManager.CacheEntry getCacheEntry(String id)
id
- the entry's id
public void removeEntry(String id)
id
- the entry's idpublic void removeAllEntries()
public void removeAllSessionEntries()
public void removeSessionEntries(javax.servlet.http.HttpSession session)
session
- the sessionpublic void invalidateClass(Class<?> clazz)
clazz
- the class for which the entries must be clearedpublic void handleCreate(Storable storable, boolean firstTime)
StoreListener
handleCreate
in interface StoreListener
handleCreate
in class BasicDBListenerStoreListener
storable
- the storablefirstTime
- true if it is the first time this operation is processedStoreListener.handleCreate(Storable, boolean)
public void handleCommitUpdate(Storable storable, Storable oldStorable, boolean firstTime)
StoreListener
handleCommitUpdate
in interface StoreListener
handleCommitUpdate
in class BasicDBListenerStoreListener
storable
- the storable, this instance is the object that was created
at first and that will be stored in jcms until deletion of the storable
with this ID.
You should always manipulate this object if you maintain any index.oldStorable
- the previous version of the storable, it is a clone, do not use
in any index, it should only be used to access old values.firstTime
- true if it is the first time this operation is processedStoreListener.handleCommitUpdate(Storable, Storable, boolean)
public void handleDelete(Storable storable, boolean firstTime)
StoreListener
handleDelete
in interface StoreListener
handleDelete
in class BasicDBListenerStoreListener
storable
- the storablefirstTime
- true if it is the first time this operation is processedStoreListener.handleDelete(Storable, boolean)
public void onPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)
onPostInsert
in interface DBListener
onPostInsert
in class BasicDBListener
DBListener.onPostInsert(DBData, PostInsertEvent, boolean)
public void onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)
onPostUpdate
in interface DBListener
onPostUpdate
in class BasicDBListener
DBListener.onPostUpdate(DBData, PostUpdateEvent, boolean)
public void onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)
onPostDelete
in interface DBListener
onPostDelete
in class BasicDBListener
DBListener.onPostDelete(DBData, PostDeleteEvent, boolean)
public void valueBound(javax.servlet.http.HttpSessionBindingEvent event)
valueBound
in interface javax.servlet.http.HttpSessionBindingListener
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent event)
valueUnbound
in interface javax.servlet.http.HttpSessionBindingListener
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |