Class AsyncFetcher

  • All Implemented Interfaces:
    Fetcher, Interruptible, java.lang.AutoCloseable

    public final class AsyncFetcher
    extends java.lang.Object
    implements Fetcher
    This class holds the implementation to provide how items are fetched from the web, to validate the item and to store it if specified.
    Author:
    Maksim Tkachenko, Truong Quoc Tuan, Ween Jiann Lee
    • Method Detail

      • buildDefault

        public static AsyncFetcher buildDefault()
        Create an instance of async fetcher with default options.
        Returns:
        A new instance of async fetcher
      • builder

        public static AsyncFetcher.Builder builder()
        Create an instance of builder.
        Returns:
        A new instance of builder
      • fetch

        public java.util.concurrent.Future<Response> fetch​(Request request)
        Description copied from interface: Fetcher
        Fetch the desired HTTP page given in Request.
        Specified by:
        fetch in interface Fetcher
        Parameters:
        request - information for the page to fetch.
        Returns:
        Response future
      • fetch

        public java.util.concurrent.Future<Response> fetch​(Request request,
                                                           Callback callback)
        Description copied from interface: Fetcher
        Fetch the desired HTTP page given in Request. Executes callback upon completion.
        Specified by:
        fetch in interface Fetcher
        Parameters:
        request - information for the page to fetch.
        callback - callback
        Returns:
        Response future
      • start

        public void start()
        Description copied from interface: Fetcher
        Fetcher starter.
        Specified by:
        start in interface Fetcher
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException