added a little doc

This commit is contained in:
Athou
2013-07-26 16:00:02 +02:00
parent 68ad6d8b55
commit da94880c53
19 changed files with 85 additions and 3 deletions

View File

@@ -19,6 +19,10 @@ import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.services.ApplicationSettingsService;
/**
* Contains utility methods for cleaning the database
*
*/
public class DatabaseCleaner {
private static Logger log = LoggerFactory.getLogger(DatabaseCleaner.class);

View File

@@ -20,6 +20,10 @@ import liquibase.structure.DatabaseObject;
import com.commafeed.backend.services.ApplicationPropertiesService;
/**
* Executes needed liquibase database schema upgrades
*
*/
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class DatabaseUpdater {

View File

@@ -5,6 +5,11 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* List wrapper that sorts its elements in the order provided by given comparator and ensure a maximum capacity.
*
*
*/
public class FixedSizeSortedSet<E> {
private List<E> inner;

View File

@@ -41,6 +41,10 @@ import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Smart HTTP getter
*
*/
public class HttpGetter {
private static Logger log = LoggerFactory.getLogger(HttpGetter.class);

View File

@@ -13,6 +13,10 @@ import org.slf4j.LoggerFactory;
import com.commafeed.backend.services.ApplicationSettingsService;
/**
* Contains all scheduled tasks
*
*/
@Stateless
public class ScheduledTasks {
protected final static Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
@@ -26,7 +30,9 @@ public class ScheduledTasks {
@PersistenceContext
EntityManager em;
// every day at midnight
/**
* clean old read statuses, runs every day at midnight
*/
@Schedule(hour = "0", persistent = false)
private void cleanupOldStatuses() {
Date threshold = applicationSettingsService.get().getUnreadThreshold();

View File

@@ -25,6 +25,10 @@ import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.backend.services.UserService;
import com.google.api.client.util.Maps;
/**
* Starting point of the application
*
*/
@Startup
@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
@@ -56,14 +60,19 @@ public class StartupBean {
private void init() {
startupTime = System.currentTimeMillis();
// update database schema
databaseUpdater.update();
if (applicationSettingsDAO.getCount() == 0) {
// import initial data
initialData();
}
applicationSettingsService.applyLogLevel();
initSupportedLanguages();
// start fetching feeds
taskGiver.start();
}
@@ -83,6 +92,9 @@ public class StartupBean {
}
}
/**
* create default users
*/
private void initialData() {
log.info("Populating database with default values");

View File

@@ -81,7 +81,7 @@ public class FaviconFetcher {
return bytes;
}
boolean isValidIconResponse(byte[] content, String contentType) {
private boolean isValidIconResponse(byte[] content, String contentType) {
if (content == null) {
return false;
}

View File

@@ -10,6 +10,11 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Wraps a {@link ThreadPoolExecutor} instance. Blocks when queue is full instead of rejecting the task. Allow priority queueing by using
* {@link Task} instead of {@link Runnable}
*
*/
public class FeedRefreshExecutor {
private static Logger log = LoggerFactory.getLogger(FeedRefreshExecutor.class);

View File

@@ -25,6 +25,11 @@ import com.google.api.client.util.Maps;
import com.google.common.collect.Lists;
import com.google.common.collect.Queues;
/**
* Infinite loop fetching feeds from the database and queuing them to the {@link FeedRefreshWorker} pool. Also handles feed database updates
* at the end of the cycle through {@link #giveBack(Feed)}.
*
*/
@ApplicationScoped
public class FeedRefreshTaskGiver {

View File

@@ -22,6 +22,10 @@ import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.sun.syndication.io.FeedException;
/**
* Calls {@link FeedFetcher} and handles its outcome
*
*/
@ApplicationScoped
public class FeedRefreshWorker {

View File

@@ -36,6 +36,10 @@ import com.steadystate.css.parser.CSSOMParser;
import edu.uci.ics.crawler4j.url.URLCanonicalizer;
/**
* Utility methods related to feed handling
*
*/
public class FeedUtils {
protected static Logger log = LoggerFactory.getLogger(FeedUtils.class);

View File

@@ -8,6 +8,10 @@ import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.TableGenerator;
/**
* Abstract model for all entities, defining id and table generator
*
*/
@SuppressWarnings("serial")
@MappedSuperclass
public abstract class AbstractModel implements Serializable {

View File

@@ -22,8 +22,13 @@ import com.commafeed.backend.feeds.FeedRefreshTaskGiver;
import com.commafeed.backend.feeds.FeedUtils;
import com.commafeed.backend.model.Feed;
import com.commafeed.backend.services.ApplicationSettingsService;
import com.commafeed.frontend.rest.resources.PubSubHubbubCallbackREST;
import com.google.common.collect.Lists;
/**
* Sends push subscription requests. Callback is handled by {@link PubSubHubbubCallbackREST}
*
*/
public class SubscriptionHandler {
private static Logger log = LoggerFactory.getLogger(SubscriptionHandler.class);

View File

@@ -4,6 +4,10 @@ import org.jdom.Element;
import com.sun.syndication.feed.opml.Opml;
/**
* Add missing title to the generated OPML
*
*/
public class OPML11Generator extends com.sun.syndication.io.impl.OPML10Generator {
public OPML11Generator() {

View File

@@ -5,6 +5,10 @@ import org.jdom.Element;
import com.sun.syndication.io.impl.OPML10Parser;
/**
* Support for OPML 1.1 parsing
*
*/
public class OPML11Parser extends OPML10Parser {
public OPML11Parser() {

View File

@@ -6,6 +6,10 @@ import com.sun.syndication.feed.synd.SyndContentImpl;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.impl.ConverterForRSS090;
/**
* Support description tag for RSS09
*
*/
public class RSS090DescriptionConverter extends ConverterForRSS090 {
@Override

View File

@@ -6,6 +6,10 @@ import com.sun.syndication.feed.rss.Description;
import com.sun.syndication.feed.rss.Item;
import com.sun.syndication.io.impl.RSS090Parser;
/**
* Support description tag for RSS09
*
*/
public class RSS090DescriptionParser extends RSS090Parser {
@Override

View File

@@ -18,6 +18,10 @@ import org.slf4j.LoggerFactory;
import com.commafeed.backend.model.ApplicationSettings;
import com.commafeed.backend.model.User;
/**
* Mailing service
*
*/
@SuppressWarnings("serial")
public class MailService implements Serializable {

View File

@@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
import com.commafeed.backend.dao.UserDAO;
// http://www.javacodegeeks.com/2012/05/secure-password-storage-donts-dos-and.html
// taken from http://www.javacodegeeks.com/2012/05/secure-password-storage-donts-dos-and.html
@SuppressWarnings("serial")
public class PasswordEncryptionService implements Serializable {