Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2004 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.content
Class ContentCache

    java.lang.Object
      com.bea.p13n.content.ContentCache

All Implemented Interfaces:
  EventListener, HttpSessionBindingListener, Serializable

public class ContentCache
extends Object
implements HttpSessionBindingListener, Serializable

An object to help with caching content.

This object can placed anywhere for use as a cache. For convience, the `getContentCache` method can be used with a JSP PageContext to create and utilize ContentCaches.

Additionally, this is what the `<cm:select>` and `<cm:selectById>` tags use when useCache="true".

See Also:
  Serialized Form

Field Summary
`protected Map` | `cache` Deprecated. The cache of id to ContentHolder.
`static String` | `DEF_CACHE_NAME` Deprecated. The default name of the ContentCache in the various locations ("wlps.content.cache").
`static String` | `SESSION_NAME` Deprecated. Use DEF_CACHE_NAME instead.

Constructor Summary
`ContentCache()` Deprecated. Constructor.

Method Summary
`static void` | `bindToSession(ContentCache cache, HttpSession session)` Deprecated. Bind a ContentCache into an HttpSession.
`void` | `clear()` Deprecated. Clear the entire cache.
`static Object` | `getAttribute(PageContext ctx, String name, int scope)` Deprecated. Get a scoped attribute correctly from the JSP page context.
`long` | `getCachedTime(String id)` Deprecated. Get the UTC time (in ms.) of when the Content at id was cached.
`List` | `getCacheIds()` Deprecated. Get an unordered list of all the cache ids.
`long` | `getCacheSize()` Deprecated. Get the total number of Content objects cached (across all ids).
`Content[]` | `getContent(String id, long timeout)` Deprecated. Check the cache for the content.
`static ContentCache` | `getContentCache(PageContext ctx, int scope, boolean create)` Deprecated. Get a ContentCache from the specified JSP context.
`static ContentCache` | `getContentCache(PageContext ctx, String scopeStr, boolean create)` Deprecated. Get a ContentCache from the specified JSP context.
`static ContentCache` | `getFromSession(HttpSession session, boolean create)` Deprecated. Get a ContentCache from an HttpSession.
`int` | `getNumCacheIds()` Deprecated. Get the number of cache ids in the cache.
`static String` | `getScopeName(int scope)` Deprecated. Get the scope name based upon the scope id.
`Content[]` | `remove(String id)` Deprecated. Clear a particular entry from the cache.
`static void` | `removeAttribute(PageContext ctx, String name, int scope)` Deprecated. Remove a scoped attribute correctly from the JSP page context.
`static void` | `setAttribute(PageContext ctx, String name, Object val, int scope)` Deprecated. Set a scoped attribute correctly in the JSP page context.
`void` | `update(String id, Content[] content)` Deprecated. Update the cache with the content.
`void` | `valueBound(HttpSessionBindingEvent evt)` Deprecated. Called when we're bound into an HttpSession.
`void` | `valueUnbound(HttpSessionBindingEvent evt)` Deprecated. Called when we're unbound from an HttpSession, and clears the cache.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### cache

    protected Map cache

  Deprecated.
  The cache of id to ContentHolder.

### DEF_CACHE_NAME

    public static final String DEF_CACHE_NAME

  Deprecated.
  The default name of the ContentCache in the various locations ("wlps.content.cache").

  When the `getContentCache` method is used, this is the name which will used.

  See Also:
    Constant Field Values

### SESSION_NAME

    public static final String SESSION_NAME

  Deprecated. Use DEF_CACHE_NAME instead.

  The old name of the ContentCache.

  This is set to `DEF_CACHE_NAME`.

  See Also:
    Constant Field Values

Constructor Detail

### ContentCache

    public ContentCache()

  Deprecated.
  Constructor.

Method Detail

### bindToSession

    public static void bindToSession(ContentCache cache,
                                     HttpSession session)

  Deprecated.
  Bind a ContentCache into an HttpSession.

  This will use `DEF_CACHE_NAME` as the session attribute name for the cache.

  Parameters:
    `cache` - the content cache object.
    `session` - the http session.

### clear

    public void clear()

  Deprecated.
  Clear the entire cache.

### getAttribute

    public static Object getAttribute(PageContext ctx,
                                      String name,
                                      int scope)

  Deprecated.
  Get a scoped attribute correctly from the JSP page context.

  Parameters:
    `ctx` - the JSP page context.
    `name` - the attribute name.
    `scope` - the attribute scope (PageContext.APPLICATION_SCOPE, PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE, PageContext.SESSION_SCOPE).

### getCachedTime

    public long getCachedTime(String id)

  Deprecated.
  Get the UTC time (in ms.) of when the Content at id was cached.

  Parameters:
    `id` - the cache id of the content.
  Returns:
    the time, or -1 if id is not a valid cache id.

### getCacheIds

    public List getCacheIds()

  Deprecated.
  Get an unordered list of all the cache ids.

  Since the keys will all be Strings, this can be sorted with `Collections.sort(java.util.List)`.

### getCacheSize

    public long getCacheSize()

  Deprecated.
  Get the total number of Content objects cached (across all ids).

### getContent

    public Content[] getContent(String id,
                                long timeout)

  Deprecated.
  Check the cache for the content.

  Getting content from the cache does not update its time in terms of a timeout. Only using the `update(java.lang.String, com.bea.p13n.content.Content[])` method to update the cache will do that.

  Parameters:
    `id` - the cache id of the content.
    `timeout` - the timeout in ms. for the content (less than 0 for no timeout).
  Returns:
    the array of Content, or null if not found or has timed out.

### getContentCache

    public static ContentCache getContentCache(PageContext ctx,
                                               int scope,
                                               boolean create)

  Deprecated.
  Get a ContentCache from the specified JSP context.

  This will retrieve the ContentCache from the JSP context based upon the specified scope at the attribute named `DEF_CACHE_NAME`. If that is set and is not a ContentCache, it will be removed.

  Parameters:
    `ctx` - the JSP page context.
    `scope` - the cache scope (one of PageContext.APPLICATION_SCOPE, PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE, or PageContext.SESSION_SCOPE).
    `create` - true to create a ContentCache if it's not there, false to not and return null.
  Returns:
    the cache if it exists or create was true, null if it didn't exist and create was false.

### getContentCache

    public static ContentCache getContentCache(PageContext ctx,
                                               String scopeStr,
                                               boolean create)

  Deprecated.
  Get a ContentCache from the specified JSP context.

  If scopeStr is "application", then PageContext.APPLICATION_SCOPE is used; if scopeStr is "page", then PageContext.PAGE_SCOPE is used; if scopeStr is "request", then PageContext.REQUEST_SCOPE is used; if scopeStr is "session", then PageContext.SESSION_SCOPE is used; otherwise, scopeStr is passed to ctx.getAttributesScope() which will determine the scope to use.

  Parameters:
    `ctx` - the JSP page context.
    `scopeStr` - the scope name.
    `create` - true to create a ContentCache if it's not there, false to not and return null.
  Returns:
    the cache if it exists or create was true, null if it didn't exist and create was false.

### getFromSession

    public static ContentCache getFromSession(HttpSession session,
                                              boolean create)

  Deprecated.
  Get a ContentCache from an HttpSession.

  This will retrieve the cache from the session attribute named `DEF_CACHE_NAME`. If that is set and is not a ContentCache, it will be removed.

  Parameters:
    `session` - the http session.
    `create` - true to create a ContentCache if it's not there, false to not and return null.
  Returns:
    the cache if it exists or create was true, null if it didn't exist and create was false.

### getNumCacheIds

    public int getNumCacheIds()

  Deprecated.
  Get the number of cache ids in the cache.

### getScopeName

    public static String getScopeName(int scope)

  Deprecated.
  Get the scope name based upon the scope id.

### remove

    public Content[] remove(String id)

  Deprecated.
  Clear a particular entry from the cache.

  Parameters:
    `id` - the cache id of the content.
  Returns:
    the cached Content at the id, or null if none.

### removeAttribute

    public static void removeAttribute(PageContext ctx,
                                       String name,
                                       int scope)

  Deprecated.
  Remove a scoped attribute correctly from the JSP page context.

  Parameters:
    `ctx` - the JSP page context.
    `name` - the attribute name.
    `scope` - the attribute scope (PageContext.APPLICATION_SCOPE, PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE, PageContext.SESSION_SCOPE).

### setAttribute

    public static void setAttribute(PageContext ctx,
                                    String name,
                                    Object val,
                                    int scope)

  Deprecated.
  Set a scoped attribute correctly in the JSP page context.

  Parameters:
    `ctx` - the JSP page context.
    `name` - the attribute name.
    `val` - the attribute value.
    `scope` - the attribute scope (PageContext.APPLICATION_SCOPE, PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE, PageContext.SESSION_SCOPE).

### update

    public void update(String id,
                       Content[] content)

  Deprecated.
  Update the cache with the content.

  This can be used for new or existing content in the cache.

  Parameters:
    `id` - cache id of the content.
    `content` - the Content (null to remove).

### valueBound

    public void valueBound(HttpSessionBindingEvent evt)

  Deprecated.
  Called when we're bound into an HttpSession.

  Specified by:
    `valueBound` in interface `HttpSessionBindingListener`

### valueUnbound

    public void valueUnbound(HttpSessionBindingEvent evt)

  Deprecated.
  Called when we're unbound from an HttpSession, and clears the cache.

  Specified by:
    `valueUnbound` in interface `HttpSessionBindingListener`
  See Also:
    `clear()`

Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2004 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2004 BEA Systems, Inc. All Rights Reserved