org/sonews/feed/PullFeeder.java
changeset 26 407c428adb5b
parent 15 f2293e8566f5
     1.1 --- a/org/sonews/feed/PullFeeder.java	Thu Aug 20 18:41:21 2009 +0200
     1.2 +++ b/org/sonews/feed/PullFeeder.java	Tue Apr 27 21:51:12 2010 +0200
     1.3 @@ -27,9 +27,13 @@
     1.4  import java.net.UnknownHostException;
     1.5  import java.util.ArrayList;
     1.6  import java.util.HashMap;
     1.7 +import java.util.HashSet;
     1.8  import java.util.List;
     1.9  import java.util.Map;
    1.10 +import java.util.Set;
    1.11 +import java.util.logging.Level;
    1.12  import org.sonews.config.Config;
    1.13 +import org.sonews.daemon.AbstractDaemon;
    1.14  import org.sonews.util.Log;
    1.15  import org.sonews.storage.StorageBackendException;
    1.16  import org.sonews.storage.StorageManager;
    1.17 @@ -43,20 +47,23 @@
    1.18   * @author Christian Lins
    1.19   * @since sonews/0.5.0
    1.20   */
    1.21 -class PullFeeder extends AbstractFeeder
    1.22 +class PullFeeder extends AbstractDaemon
    1.23  {
    1.24    
    1.25    private Map<Subscription, Integer> highMarks = new HashMap<Subscription, Integer>();
    1.26    private BufferedReader             in;
    1.27    private PrintWriter                out;
    1.28 +  private Set<Subscription>          subscriptions = new HashSet<Subscription>();
    1.29    
    1.30 -  @Override
    1.31 -  public void addSubscription(final Subscription sub)
    1.32 +  private void addSubscription(final Subscription sub)
    1.33    {
    1.34 -    super.addSubscription(sub);
    1.35 -    
    1.36 -    // Set a initial highMark
    1.37 -    this.highMarks.put(sub, 0);
    1.38 +    subscriptions.add(sub);
    1.39 +
    1.40 +    if(!highMarks.containsKey(sub))
    1.41 +    {
    1.42 +      // Set a initial highMark
    1.43 +      this.highMarks.put(sub, 0);
    1.44 +    }
    1.45    }
    1.46    
    1.47    /**
    1.48 @@ -167,6 +174,21 @@
    1.49  
    1.50        try
    1.51        {
    1.52 +        this.subscriptions.clear();
    1.53 +        List<Subscription> subsPull = StorageManager.current()
    1.54 +          .getSubscriptions(FeedManager.TYPE_PULL);
    1.55 +        for(Subscription sub : subsPull)
    1.56 +        {
    1.57 +          addSubscription(sub);
    1.58 +        }
    1.59 +      }
    1.60 +      catch(StorageBackendException ex)
    1.61 +      {
    1.62 +        Log.get().log(Level.SEVERE, host, ex);
    1.63 +      }
    1.64 +
    1.65 +      try
    1.66 +      {
    1.67          for(Subscription sub : this.subscriptions)
    1.68          {
    1.69            host = sub.getHost();