mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
only allow one thread to update entries for a feed, avoids duplicates if two feeds containing the same entry are updating at the same time
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.commafeed.backend.feeds;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Asynchronous;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
|
||||
import com.commafeed.backend.dao.FeedDAO;
|
||||
import com.commafeed.backend.model.Feed;
|
||||
import com.commafeed.backend.model.FeedEntry;
|
||||
import com.commafeed.backend.services.FeedUpdateService;
|
||||
|
||||
@Stateless
|
||||
public class FeedRefreshUpdater {
|
||||
|
||||
@Inject
|
||||
FeedUpdateService feedUpdateService;
|
||||
|
||||
@Inject
|
||||
FeedDAO feedDAO;
|
||||
|
||||
@Asynchronous
|
||||
public void updateEntries(Feed feed, Collection<FeedEntry> entries) {
|
||||
if (CollectionUtils.isNotEmpty(entries)) {
|
||||
feedUpdateService.updateEntries(feed, entries);
|
||||
}
|
||||
feedDAO.update(feed);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user