KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > planet > RefreshEntriesTask


1 package org.roller.presentation.planet;
2
3 import java.util.TimerTask JavaDoc;
4
5 import org.apache.commons.logging.Log;
6 import org.apache.commons.logging.LogFactory;
7 import org.roller.RollerException;
8 import org.roller.model.Roller;
9 import org.roller.model.RollerFactory;
10 import org.roller.model.ScheduledTask;
11
12 /**
13  * Run the Planet Roller refresh-entries method to fetch and parse newsfeeds.
14  * @author Dave Johnson
15  */

16 public class RefreshEntriesTask extends TimerTask JavaDoc implements ScheduledTask
17 {
18     private static Log logger =
19         LogFactory.getFactory().getInstance(RefreshEntriesTask.class);
20     private Roller roller = null;
21     
22     /** Task may be run from the command line */
23     public static void main(String JavaDoc[] args) throws Exception JavaDoc
24     {
25         RollerFactory.setRoller(
26             "org.roller.business.hibernate.HibernateRollerImpl");
27         RefreshEntriesTask task = new RefreshEntriesTask();
28         task.init(RollerFactory.getRoller(), "dummy");
29         task.run();
30     }
31     public void init(Roller roller, String JavaDoc realPath) throws RollerException
32     {
33         this.roller = (Roller)roller;
34     }
35     public void run()
36     {
37         try
38         {
39             roller.begin();
40             roller.getPlanetManager().refreshEntries();
41             roller.commit();
42             roller.release();
43         }
44         catch (RollerException e)
45         {
46             logger.error("ERROR refreshing entries", e);
47         }
48     }
49 }
50
51
Popular Tags