2007-05-27
ROME更新RSS类 有什么可以再优化的地方 发现更新还是有点慢的
关键字: ROMEpackage org.zjut.romefunction;
/**
* this class is update the news;
* @author xuhaimin
*
*/
import java.util.Date;
import java.util.Iterator;
import org.zjut.DAOFactory.DAOFactory;
import org.zjut.PO.Feed;
import org.zjut.PO.Item;
import org.zjut.PO.Rss;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
public class UpdateItems {
public void perform(Rss rss) {
System.out.println(rss.getId());
SyndFeed syndfeed = new ParseRss().getSyndFeed(rss);
String title = syndfeed.getTitle();
Feed feed = DAOFactory.getIntance().createFeedDAO().getFeedByTitle(
title);
Date maxdate = getMaxDate(title);
Iterator intor = syndfeed.getEntries().iterator();
while (intor.hasNext()) {
SyndEntry synden = (SyndEntry) intor.next();
Date date = synden.getPublishedDate();
if (date == null)
continue;
if (date.after(maxdate)) {
System.err.println("当前数据库中" + feed.getTitle() + " 最新时间是"
+ maxdate);
System.err.println("当前rss 最新时间是" + date);
/**
* 如果是更新新闻 就入库
*/
Item item = new Item();
item.setTitle(synden.getTitle());
String description=synden.getDescription().getValue().replaceAll("<[.[^<]]*>","");
if(description==null||description.equals(""))
item.setDescription("对不起,没有该新闻的描述");
item.setDescription(description);
item.setAuthor(synden.getAuthor());
item.setSource("");
item.setPubDate(synden.getPublishedDate());
item.setLink(synden.getLink());
item.setFeed(feed);
System.err.println("@ 服务器正在更新" + feed.getTitle()
+ "的内容..........................................");
DAOFactory.getIntance().createItemDAO().saveItem(item);
} else {
break;
}
}
}
public Date getMaxDate(String title) {
Feed feed = DAOFactory.getIntance().createFeedDAO().getFeedByTitle(
title);
Long feedid = feed.getId();
Date date = org.zjut.HibernateUtil.Util.maxDate(feedid);
return date;
}
}
- 21:30
- 浏览 (1132)
- 论坛浏览 (1268)
- 评论 (2)
- 相关推荐
评论
[quote="lordhong"]嗯???
[quote]
import org.zjut.PO.Feed;
import org.zjut.PO.Item;
import org.zjut.PO.Rss;
[/quote]
为什么要封装这些?? ROME本身提供的就很足够了啊...
这个是一些PO对象 是数据库的映射
[quote]
import org.zjut.PO.Feed;
import org.zjut.PO.Item;
import org.zjut.PO.Rss;
[/quote]
为什么要封装这些?? ROME本身提供的就很足够了啊...
这个是一些PO对象 是数据库的映射
嗯???
import org.zjut.PO.Feed;
import org.zjut.PO.Item;
import org.zjut.PO.Rss;
为什么要封装这些?? ROME本身提供的就很足够了啊...
0.9早出来了哦, 更新的是:
1) ROME now supports the final version of the Atom Syndication Format RFC 4287: let's Nuke all these feeds! NEW
2) Enclosure support at the Synd level, for all our podcaster friends
3) Bug fixes and more. Details in the ChangeList
4) Modules galore: Content, iTunes Podcast, Slash, Google Base, Creative Commons, MediaRSS
2 和 4 是比较实用的更新. Enclosure支持等了太久了...
Module这些以前都自己写, 现在有plugin好多了.
引用
import org.zjut.PO.Feed;
import org.zjut.PO.Item;
import org.zjut.PO.Rss;
为什么要封装这些?? ROME本身提供的就很足够了啊...
0.9早出来了哦, 更新的是:
1) ROME now supports the final version of the Atom Syndication Format RFC 4287: let's Nuke all these feeds! NEW
2) Enclosure support at the Synd level, for all our podcaster friends
3) Bug fixes and more. Details in the ChangeList
4) Modules galore: Content, iTunes Podcast, Slash, Google Base, Creative Commons, MediaRSS
2 和 4 是比较实用的更新. Enclosure支持等了太久了...
Module这些以前都自己写, 现在有plugin好多了.
发表评论
该博客是同时发布到论坛的,无法评论在论坛已被锁定的帖子
最近加入圈子
最新评论
-
JAVA对于AJAX 你用的是什 ...
dwr用过觉得还比较不错,不过也可以直接用prototype.js内嵌,觉得他们 ...
-- by cicada_IT -
JAVA对于AJAX 你用的是什 ...
觉得太多的框架搞得人眼花缭乱,不知选哪一个比较好.
-- by kujioon -
JAVA对于AJAX 你用的是什 ...
用DWR+ExtJS,感觉非常好。
-- by fangzhouxing -
JAVA对于AJAX 你用的是什 ...
DWR
-- by jianghao08 -
JAVA对于AJAX 你用的是什 ...
楼上的小心了,准备好挨骂吧
-- by wiwika







评论排行榜