|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.beasys.commerce.content.ContentCache
A little cache bean for caching content.
This object is generally placed in an HttpSession (via the bindToSession()
and
getFromSession()
methods).
Internally, this obeys the
ContentHelper.USE_SOFT_HASH_MAP
parameter. If that's false, then a regular HashMap will be used to cache
the Content. In this case, caching should be used judiciously and always
with a max and timeout. If ContentHelper.USE_SOFT_HASH_MAP is true, than a
SoftHashMap
will be used.
This will allow the garbage collector to collect
cached data as memory requirements change and will prevent the
ContentCaches from causing OutOfMemoryErrors. However, under the Solaris
Production VM (1.2.1_04), SoftReferences (and WeakReferences) are almost
immediately collected, thereby nullifying any performance bonus from using
the ContentCache.
Field Summary | |
static java.lang.String |
SESSION_NAME
The name of the ContentCache in the HttpSession ("wlcs.content.cache"). |
Constructor Summary | |
ContentCache()
Constructor. |
Method Summary | |
static void |
bindToSession(ContentCache cache,
javax.servlet.http.HttpSession session)
Bind a ContentCache into an HttpSession. |
Content[] |
getContent(java.lang.String id,
long timeout)
Check the cache for the content. |
static ContentCache |
getFromSession(javax.servlet.http.HttpSession session,
boolean create)
Get a ContentCache from an HttpSession. |
void |
update(java.lang.String id,
Content[] content)
Update the cache with the content. |
void |
valueBound(javax.servlet.http.HttpSessionBindingEvent evt)
Called when we're bound into an HttpSession. |
void |
valueUnbound(javax.servlet.http.HttpSessionBindingEvent evt)
Called when we're unbound from an HttpSession, and clears the cache. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String SESSION_NAME
Constructor Detail |
public ContentCache()
Method Detail |
public Content[] getContent(java.lang.String id, long timeout)
id
- the cache id of the content.timeout
- the timeout in ms. for the content (less than 0 for no
timeout).public void update(java.lang.String id, Content[] content)
This can be used for new or existing content in the cache.
the
- cache id of the content.content
- the Content (null to remove).public void valueBound(javax.servlet.http.HttpSessionBindingEvent evt)
public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent evt)
public static void bindToSession(ContentCache cache, javax.servlet.http.HttpSession session)
This will use SESSION_NAME
as the session
attribute name for the cache.
cache
- the content cache object.session
- the http session.public static ContentCache getFromSession(javax.servlet.http.HttpSession session, boolean create)
This will retrieve the cache from the session attribute named
SESSION_NAME
. If that is set and is not a
ContentCache, it will be removed.
session
- the http session.create
- true to create a ContentCache if it's not there, false to
not and return null.
|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |