Update of /cvsroot/roller/roller/src/org/roller/presentation/caching
In directory sc8-pr-cvs1:/tmp/cvs-serv16534/src/org/roller/presentation/caching
Modified Files:
CommonsPageCache.java
Log Message:
Updating usage of Jakarta Commons Cache.
Index: CommonsPageCache.java
===================================================================
RCS file:
/cvsroot/roller/roller/src/org/roller/presentation/caching/CommonsPageCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** CommonsPageCache.java 14 Feb 2003 18:36:13 -0000 1.7
--- CommonsPageCache.java 16 Feb 2003 04:47:29 -0000 1.8
***************
*** 8,11 ****
--- 8,12 ----
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
+ import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
***************
*** 22,28 ****
--- 23,31 ----
import org.apache.commons.cache.MemoryStash;
import org.apache.commons.cache.SimpleCache;
+ import org.apache.commons.cache.config.CacheConfig;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.roller.model.UserData;
+ import org.roller.presentation.RollerContext;
import org.roller.presentation.RollerRequest;
***************
*** 40,44 ****
LogFactory.getFactory().getInstance(CommonsPageCache.class);
! private static String mCacheName = "PageCache";
private FilterConfig mFilterConfig = null;
--- 43,47 ----
LogFactory.getFactory().getInstance(CommonsPageCache.class);
! private static final String CACHENAME = "PageCache";
private FilterConfig mFilterConfig = null;
***************
*** 152,177 ****
/**
! * Get the cache for the ServerHost.code passed in.
! * If none, create one.
**/
public synchronized Cache getCache()
{
! if(CacheSingleton.hasCache(mCacheName))
{
! return CacheSingleton.getCache(mCacheName);
}
! SimpleCache cache = new SimpleCache(
new MemoryStash( mMaxObjects ),
new LRUEvictionPolicy(),
null,
new GroupMapImpl() );
if(null != cache)
{
! CacheSingleton.putCache(mCacheName, cache);
! return cache;
}
! return null;
}
--- 155,205 ----
/**
! * Get the cache for Pages. If none, create one.
! * Uses Commons Cache CacheConfig object to read a configuration file,
! * failing that creates one using the values from the Filter's
initialization.
! *
**/
public synchronized Cache getCache()
{
! if(CacheSingleton.hasCache(CACHENAME))
{
! return CacheSingleton.getCache(CACHENAME);
}
+
+ Cache cache = null;
+ java.io.InputStream in = null;
+ String fileName = "CommonsCache" + CACHENAME + ".config";
+ try
+ {
+ ServletContext app = RollerContext.getServletContext();
+ in = app.getResourceAsStream("/WEB-INF/" + fileName);
! CacheConfig cConfig = CacheConfig.getInstance( CACHENAME, in );
! cache = cConfig.getCache();
! }
! catch( Exception e)
! {
! mLogger.warn("Unable to load config file: " + fileName);
! cache = new SimpleCache(
new MemoryStash( mMaxObjects ),
new LRUEvictionPolicy(),
null,
new GroupMapImpl() );
+ }
+ finally
+ {
+ try {
+ if (in != null) in.close();
+ } catch (java.io.IOException ioe) {
+ mLogger.warn("CommonsPageCache.getCache() unable to close
InputStream");
+ }
+ }
+
if(null != cache)
{
! CacheSingleton.putCache(CACHENAME, cache);
}
! return cache;
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf