Update of /cvsroot/roller/roller/src/org/roller/presentation/newsfeeds
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29227/src/org/roller/presentation/newsfeeds
Modified Files:
NewsfeedCache.java
Log Message:
Removed last vestiges of OSCache and Commons Cache
Index: NewsfeedCache.java
===================================================================
RCS file:
/cvsroot/roller/roller/src/org/roller/presentation/newsfeeds/NewsfeedCache.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** NewsfeedCache.java 9 Feb 2004 02:40:03 -0000 1.8
--- NewsfeedCache.java 5 Aug 2004 02:16:17 -0000 1.9
***************
*** 1,14 ****
package org.roller.presentation.newsfeeds;
! //import net.sourceforge.flock.FlockFeedI;
! //import net.sourceforge.flock.FlockResourceException;
! //import net.sourceforge.flock.parser.FlockFeedFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.roller.pojos.RollerConfig;
!
! import com.opensymphony.oscache.base.NeedsRefreshException;
! import com.opensymphony.oscache.general.GeneralCacheAdministrator;
import de.nava.informa.core.ChannelIF;
--- 1,11 ----
package org.roller.presentation.newsfeeds;
! import java.io.IOException;
! import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.roller.pojos.RollerConfig;
! import org.roller.util.LRUCache2;
import de.nava.informa.core.ChannelIF;
***************
*** 17,26 ****
import de.nava.informa.parsers.RSSParser;
- import java.io.IOException;
- import java.net.URL;
-
/**
! * Returns parsed RSS feed by pulling one from a cache or by retrieving
! * and parging the specified feed using the Flock RSS parser.
*
* @author Lance Lavandowska
--- 14,20 ----
import de.nava.informa.parsers.RSSParser;
/**
! * Returns parsed RSS feed by pulling one from a cache or by retrieving and
! * parging the specified feed using the Flock RSS parser.
*
* @author Lance Lavandowska
***************
*** 29,114 ****
public class NewsfeedCache
{
! private static Log mLogger =
! LogFactory.getFactory().getInstance(NewsfeedCache.class);
!
! /** Static singleton **/
! public static NewsfeedCache mInstance = null;
!
! /** Instance vars **/
! private RollerConfig mConfig = null;
! private GeneralCacheAdministrator mCacheAdmin = null;
! /** Constructor **/
public NewsfeedCache(RollerConfig config)
{
mConfig = config;
! mCacheAdmin = new GeneralCacheAdministrator();
}
!
! /** static singleton retriever **/
! public static NewsfeedCache getInstance(RollerConfig config)
! {
! if (mInstance == null)
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Instantiating new NewsfeedCache");
}
!
! synchronized(NewsfeedCache.class)
! {
! mInstance = new NewsfeedCache( config );
! }
! }
! return mInstance;
! }
!
! /**
! * Returns a Channel object for the supplied RSS newsfeed URL.
! * @param feedUrl RSS newsfeed URL.
! * @return FlockFeedI for specified RSS newsfeed URL.
! */
! public ChannelIF getChannel(String feedUrl)
! {
ChannelIF channel = null;
//FlockFeed feed = null;
! try
! {
//FlockFeedFactory factory = new FlockFeedFactory();
!
// If aggregator has been disable return null
boolean enabled = mConfig.getEnableAggregator().booleanValue();
! if ( !enabled )
{
return null;
}
!
! if ( mConfig.getRssUseCache().booleanValue() )
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Newsfeed: use Cache for " +
feedUrl);
}
-
- boolean needsRefresh = false;
- try
- {
- // Get pre-parsed feed from the cache
- channel = (ChannelIF)mCacheAdmin.getFromCache(
- feedUrl, mConfig.getRssCacheTime().intValue());
- //channel = (FlockFeedI)mCacheAdmin.getFromCache(
- //feedUrl, mConfig.getRssCacheTime());
-
- if (mLogger.isDebugEnabled())
- {
- mLogger.debug("Newsfeed: got from Cache");
- }
- }
- catch (NeedsRefreshException nre)
- {
- needsRefresh = true;
- }
! if (needsRefresh)
{
try
--- 23,101 ----
public class NewsfeedCache
{
! private static Log mLogger = LogFactory.getFactory().getInstance(
! NewsfeedCache.class);
! /** Static singleton * */
! public static NewsfeedCache mInstance = null;
!
! /** Instance vars * */
! private RollerConfig mConfig = null;
!
! /** LRU cache */
! LRUCache2 mCache = null;
!
! /** Constructor * */
public NewsfeedCache(RollerConfig config)
{
mConfig = config;
! // TODO: make cache size configurable
! mCache = new LRUCache2(100, mConfig.getRssCacheTime().intValue());
}
!
! /** static singleton retriever * */
! public static NewsfeedCache getInstance(RollerConfig config)
! {
! if (mInstance == null)
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Instantiating new NewsfeedCache");
}
!
! synchronized (NewsfeedCache.class)
! {
! mInstance = new NewsfeedCache(config);
! }
! }
! return mInstance;
! }
!
! /**
! * Returns a Channel object for the supplied RSS newsfeed URL.
! *
! * @param feedUrl
! * RSS newsfeed URL.
! * @return FlockFeedI for specified RSS newsfeed URL.
! */
! public ChannelIF getChannel(String feedUrl)
! {
ChannelIF channel = null;
//FlockFeed feed = null;
! try
! {
//FlockFeedFactory factory = new FlockFeedFactory();
!
// If aggregator has been disable return null
boolean enabled = mConfig.getEnableAggregator().booleanValue();
! if (!enabled)
{
return null;
}
!
! if (mConfig.getRssUseCache().booleanValue())
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Newsfeed: use Cache for " + feedUrl);
}
! // Get pre-parsed feed from the cache
! channel = (ChannelIF) mCache.get(feedUrl);
! if (mLogger.isDebugEnabled())
! {
! mLogger.debug("Newsfeed: got from Cache");
! }
!
! if (channel == null)
{
try
***************
*** 116,166 ****
// Parse the feed
channel = RSSParser.parse(
! new ChannelBuilder(), new URL(feedUrl));
}
catch (ParseException e1)
{
! mLogger.info("Error parsing RSS: "+feedUrl);
}
}
!
//channel = factory.createFeed(new URL(feedUrl));
!
// Store parsed feed in the cache
! mCacheAdmin.putInCache(feedUrl, channel);
mLogger.debug("Newsfeed: not in Cache");
! }
! else
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Newsfeed: not using Cache
for " + feedUrl);
}
try
{
// Parse the feed
! channel = RSSParser.parse(
! new ChannelBuilder(), new URL(feedUrl));
}
catch (ParseException e1)
{
! mLogger.info("Error parsing RSS: "+feedUrl);
}
! }
! }
! catch (IOException ioe)
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Newsfeed: Unexpected exception",ioe);
}
! }
! // catch (FlockResourceException e)
! // {
! // if (mLogger.isDebugEnabled())
! // {
! // mLogger.debug("Newsfeed: Flock parsing exception",e);
! // }
! // }
! return channel;
! }
! }
--- 103,153 ----
// Parse the feed
channel = RSSParser.parse(
! new ChannelBuilder(), new URL(feedUrl));
}
catch (ParseException e1)
{
! mLogger.info("Error parsing RSS: " + feedUrl);
}
}
!
//channel = factory.createFeed(new URL(feedUrl));
!
// Store parsed feed in the cache
! mCache.put(feedUrl, channel);
mLogger.debug("Newsfeed: not in Cache");
! }
! else
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Newsfeed: not using Cache for " + feedUrl);
}
try
{
// Parse the feed
! channel = RSSParser.parse(new ChannelBuilder(), new URL(
! feedUrl));
}
catch (ParseException e1)
{
! mLogger.info("Error parsing RSS: " + feedUrl);
}
! }
! }
! catch (IOException ioe)
! {
if (mLogger.isDebugEnabled())
{
! mLogger.debug("Newsfeed: Unexpected exception", ioe);
}
! }
! // catch (FlockResourceException e)
! // {
! // if (mLogger.isDebugEnabled())
! // {
! // mLogger.debug("Newsfeed: Flock parsing
exception",e);
! // }
! // }
! return channel;
! }
! }
\ No newline at end of file
-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on
Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now,
one more big change to announce. We are now OSTG- Open Source Technology
Group. Come see the changes on the new OSTG site. www.ostg.com
|