Methods Summary |
---|
public void | addCacheHelperDef(java.lang.String name, java.util.HashMap helperDef)add a CacheHelper definition
helperDefs.put(name, helperDef);
|
public void | addCacheManagerListener(CacheManagerListener listener)add CacheManagerListener object
synchronized (listeners) {
listeners.add(listener);
}
|
public void | addCacheMapping(java.lang.String name, com.sun.appserv.web.cache.mapping.CacheMapping mapping)add cache mapping
cacheMappings.put(name, mapping);
|
public void | addProperty(java.lang.String name, java.lang.String value)add generic property
if (name.equalsIgnoreCase("cacheClassName")) {
cacheClassName = value;
} else {
if (cacheProps == null) {
cacheProps = new Properties();
}
cacheProps.setProperty(name, value);
}
|
public com.sun.appserv.util.cache.Cache | createCache()create the designated cache object
return createCache(maxEntries, DEFAULT_CACHE_CLASSNAME);
|
public com.sun.appserv.util.cache.Cache | createCache(int cacacity, java.lang.String className)create the designated cache object
// use the context class loader to load class so that any
// user-defined classes in WEB-INF can also be loaded.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class cacheClass = cl.loadClass(className);
Cache cacheImpl = (Cache)cacheClass.newInstance();
cacheImpl.init(maxEntries, cacheProps);
return cacheImpl;
|
public void | disable()enable the cache manager (and all the listeners)
for (int i = 0; i < listeners.size(); i++) {
CacheManagerListener listener = (CacheManagerListener)
listeners.get(i);
listener.cacheManagerDisabled();
}
|
public void | enable()enable the cache manager (and all the listeners)
for (int i = 0; i < listeners.size(); i++) {
CacheManagerListener listener = (CacheManagerListener)
listeners.get(i);
listener.cacheManagerEnabled();
}
|
public java.lang.String | getCacheClassName()get the underlying cache name
return cacheClassName;
|
public CacheHelper | getCacheHelper(java.lang.String name)get the helper by name
return (CacheHelper)cacheHelpers.get(name);
|
public CacheHelper | getCacheHelperByFilterName(java.lang.String filterName)get the helper by filter name
return (CacheHelper)cacheHelpersByFilterName.get(filterName);
|
public com.sun.appserv.web.cache.mapping.CacheMapping | getCacheMapping(java.lang.String name)get cacheMapping given its name
return (CacheMapping)cacheMappings.get(name);
|
public com.sun.appserv.util.cache.Cache | getDefaultCache()get the default application-wide cache
return defaultCache;
|
public int | getDefaultTimeout()get the application wide default cache expiry timeout
return defaultTimeout;
|
public boolean | isEnabled()
return enabled;
|
private CacheHelper | loadCacheHelper(java.lang.String className)load the helper class
// use the context class loader to load class so that any
// user-defined classes in WEB-INF can also be loaded.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class helperClass = cl.loadClass(className);
CacheHelper helper = (CacheHelper) helperClass.newInstance();
return helper;
|
public void | removeCacheManagerListener(CacheManagerListener listener)remove CacheManagerListener object
synchronized (listeners) {
listeners.remove(listener);
}
|
public void | setDefaultHelperProps(java.util.Map map)set the default-helper's properties
this.defaultHelperProps = map;
|
public void | setDefaultTimeout(int defaultTimeout)set the defaultTimeout of this cache
this.defaultTimeout = defaultTimeout;
|
public void | setEnabled(boolean enabled)set the whether this is enabled
this.enabled = enabled;
|
public void | setMaxEntries(int maxEntries)set the maximum number of entries of this cache
this.maxEntries = maxEntries;
|
public void | setServletContext(javax.servlet.ServletContext context)set the ServletContext of this application
this.context = context;
|
public void | start()Start this Context component.
if (!enabled)
return;
// web container logger
_logger = LogDomains.getLogger(LogDomains.PWC_LOGGER);
_rb = _logger.getResourceBundle();
// create the default cache
try {
defaultCache = createCache(maxEntries, cacheClassName);
} catch (Exception e) {
_logger.log(Level.WARNING, "cache.manager.excep_createCache", e);
String msg = _rb.getString("cache.manager.excep_createCache");
throw new LifecycleException(msg, e);
}
// initialize the "default" helper
defaultHelper = new DefaultCacheHelper();
defaultHelper.setCacheManager(this);
defaultHelper.init(context, defaultHelperProps);
// initialize the custom cache-helpers
Iterator helperNames = helperDefs.keySet().iterator();
while(helperNames.hasNext()) {
String name = (String) helperNames.next();
HashMap map = (HashMap)helperDefs.get(name);
try {
String className = (String)map.get("class-name");
CacheHelper helper = loadCacheHelper(className);
helper.init(context, map);
cacheHelpers.put(name, helper);
} catch (Exception e) {
String msg = _rb.getString("cache.manager.excep_initCacheHelper");
Object[] params = { name };
msg = MessageFormat.format(msg, params);
throw new LifecycleException(msg, e);
}
}
// cache-mappings are ordered by the associated filter name
Iterator filterNames = cacheMappings.keySet().iterator();
while(filterNames.hasNext()) {
String name = (String) filterNames.next();
CacheMapping mapping = (CacheMapping)cacheMappings.get(name);
String helperNameRef = mapping.getHelperNameRef();
CacheHelper helper;
if (helperNameRef == null || helperNameRef.equals("default")) {
helper = defaultHelper;
} else {
helper = (CacheHelper) cacheHelpers.get(helperNameRef);
}
cacheHelpersByFilterName.put(name, helper);
}
|
public void | stop()Stop this Context component.
destroy all the caches created and flush/clear the cached content
disable();
try {
defaultHelper.destroy();
} catch (Exception e) {
// XXX: ignore
}
// destroy the cache-helpers
Enumeration helpers = Collections.enumeration(cacheHelpers.values());
while(helpers.hasMoreElements()) {
CacheHelper cacheHelper = (CacheHelper)helpers.nextElement();
try {
cacheHelper.destroy();
} catch (Exception e) {
// XXX: ignore
}
}
cacheHelpers.clear();
cacheMappings.clear();
cacheHelpersByFilterName.clear();
listeners.clear();
|