Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
@Provides
@Singleton
public Hub buildHub() {
    FeedFetcher fetcher = new HttpURLFeedFetcher(new HashMapFeedInfoCacheDeltaFeedInfoCache());
    Hub hub = new Hub(new InMemoryHubDAO(), new UnthreadedVerifier(), new UnthreadedNotifier(), fetcher);

    return hub;
}

...

Code Block
@Provides
@Singleton
public Subscriptions buildSubs(){
    Subscriptions subs = new Subscriptions(new HashMapFeedInfoCache(), new AsyncRequester(),
            "http://localhost/webapp/subscriptions/", new InMemorySubDAO());
    return subs;
}


First we need a FeedInfoCache implementation. This will be updated as notifications come in, so in your web app, you want to make sure this is shared with the FeedFetcher implementation you are using to read feeds. Next you need a Requester, this is a network class that makes subscription requests to remote hubs. Next, a URL prefix for where the callbacks will live. This really means the URL to the SubServlet that is resolvable externally. Finally, a DAO for storing and retrieving Subscription objects.

...

Code Block
@Singleton
public class SubServlet extends AbstractSubServlet {

    @Inject
    public SubServlet(final Subscriptions subscriptions){
        super(subscriptions);
    }
}

// In the ServerModule...
serve("/subscriptions/*").with(SubServlet.class)

Now if we want to subscribe to a feed, we get a reference to the Subscriptions object, and pass in either the SyndFeed (with appropriate rel="hub" and rel="self" links) or simply a couple of URLs:

...