Interface URLConnectionFactory

All Known Implementing Classes:
AboutURLConnectionFactory, ClasspathConnectionFactory, DataURLConnectionFactory, FileURLConnectionFactory, FontDirURLConnectionFactory, Http1URLConnectionFactory, LocalFontURLConnectionFactory, MemoryURLConnectionFactory, PKCS11ConnectionFactory, ZipURLConnectionFactory

public interface URLConnectionFactory
The URLConnectionFactory interface defines a method of requesting and loading content from a particular type of URL. It's analagous to URLStreamHandler but not as awful. Subclasses exist for most standard URL schemes, and custom schemes could theoretically be added by end-users if required.
  • Method Details

    • setURLConnectionProcessors

      default void setURLConnectionProcessors(List<URLConnectionProcessor> processors)
      Set the list of URLConnectionProcessor objects that will be run on any network connections that are made by this URLConnectionFactory
      Parameters:
      processors - the list of processors - the default implementation ignores this.
    • getURLConnectionProcessors

      default List<URLConnectionProcessor> getURLConnectionProcessors()
      Return the list of URLConnectionProcessor objects that will be run on any network connections that are made by this URLConnectionFactory. The default implementation always returns an empty list.
      Returns:
      processors the list of processors
    • getURLConnection

      URL2Connection getURLConnection(URL2 uri, ReportFactory reportFactory) throws IOException
      Return a URLConnection for the specified URI, or null if not possible with this factory.
      Parameters:
      uri - the URI
      reportFactory - the ReportFactory that owns this connection
      Throws:
      IOException
    • supports

      boolean supports(URL2 uri)
      Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)
      Parameters:
      uri - the URI
    • isUnchanged

      default boolean isUnchanged(URL2 uri, URL2Connection con) throws IOException
      Return true if a previous resource loaded by this factory should be considered valid, based on the supplied response for a subsequent request for the same resource. As an example this method should return true if a web server returned a 304 (Not Modified). There is a default implementation which returns true.
      Parameters:
      uri - the URI
      con - the URL connection
      Throws:
      IOException
    • close

      default void close(URL2 uri, URL2Connection con) throws IOException
      Close the specified URLConnection and free any resources allocated by this factory. There is a default implementation which does nothing.
      Parameters:
      uri - the URI
      con - the URL connection
      Throws:
      IOException
    • getExpiry

      default long getExpiry(URL2 uri, URL2Connection con) throws IOException
      Return the absolute expiry time of the resource reeturned by the specified URLConnection, or Long.MAX_VALUE for forever. If this is not specified by the headers, the factory may still return a non-zero value to prevent content being cached forever. There is a default implementation which returns Long.MAX_VALUE;
      Parameters:
      uri - the URI
      con - the URL connection
      Throws:
      IOException
    • isTrusted

      default boolean isTrusted(URL2 uri)
      Return true if the supplied URL (which will be loadable by this Factory) should be considered trusted. The default implementation returns false.
      Since:
      1.3
      See Also: