logo       

roller/src/org/roller/presentation/newsfeeds NewsfeedCache.java,1.8,1.9: msg#00019

Subject: roller/src/org/roller/presentation/newsfeeds NewsfeedCache.java,1.8,1.9
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


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
web.pylons.gene...    hurd.l4/2002-10...    kernel.commits....    user-groups.lin...    yellowdog.gener...    java.drools.use...    security.openva...    package-managem...    linux.debian.us...    qnx.openqnx.dev...    genealogy.gramp...    file-systems.if...    voip.wengophone...    tex.context/200...    ietf.smime/2003...    audio.csound.de...    culture.region....    xfree86.devel/2...    mobile.kannel.u...    distributed.con...    education.engli...    org.user-groups...    bug-tracking.gn...    recreation.bicy...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe