Class Http1URLConnectionFactory

java.lang.Object
org.faceless.publisher.resource.Http1URLConnectionFactory
All Implemented Interfaces:
URLConnectionFactory

public class Http1URLConnectionFactory extends Object implements URLConnectionFactory
A URLConnectionFactory that handles the "http", "https", "ftp" URLs, ie. those handled by Java by default
  • Constructor Details

    • Http1URLConnectionFactory

      public Http1URLConnectionFactory()
  • Method Details

    • setURLConnectionProcessors

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

      public List<URLConnectionProcessor> getURLConnectionProcessors()
      Description copied from interface: URLConnectionFactory
      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.
      Specified by:
      getURLConnectionProcessors in interface URLConnectionFactory
      Returns:
      processors the list of processors
    • getURLConnection

      public URL2Connection getURLConnection(URL2 uri, ReportFactory reportFactory) throws IOException
      Description copied from interface: URLConnectionFactory
      Return a URLConnection for the specified URI, or null if not possible with this factory.
      Specified by:
      getURLConnection in interface URLConnectionFactory
      Parameters:
      uri - the URI
      reportFactory - the ReportFactory that owns this connection
      Throws:
      IOException
    • getConnectTimeout

      public int getConnectTimeout()
      Return the connection timeout, as set by setConnectTimeout(int)
    • getReadTimeout

      public int getReadTimeout()
      Return the read timeout, as set by setReadTimeout(int)
    • getMinimumValidity

      public int getMinimumValidity()
      Return the minimum validity , as set by setMinimumValidity(int)
    • setMinimumValidity

      public void setMinimumValidity(int validity)
      Set the minimum period for which an HTTP/HTTPS resource is considered valid. A value of 0 means that whenever the resource is referenced for the first time from a new Document, it's validity will be checked with the server. The default is 5000, which means if another document from the same ReportFactory has requested this resource within the last 5 second, it will be considered valid without asking the server.
    • setConnectTimeout

      public void setConnectTimeout(int timeout)
      Set the period in milliseconds after which an attempt to connect to a URL is considered to have failed. The default is 20000, or 20s
      See Also:
    • setReadTimeout

      public void setReadTimeout(int timeout)
      Set the period in milliseconds after which an attempt to read from a URL is considered to have failed. The default is 20000, or 20s
      See Also:
    • setUserAgent

      public void setUserAgent(String userAgent)
      Set the "User-Agent" HTTP header, or null to use the system default. The initial value is "BFO Publisher/" + the version number
    • getUserAgent

      public String getUserAgent()
      Return the "User-Agent" HTTP header, as set by setUserAgent(java.lang.String)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • supports

      public boolean supports(URL2 uri)
      Description copied from interface: URLConnectionFactory
      Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)
      Specified by:
      supports in interface URLConnectionFactory
      Parameters:
      uri - the URI
    • isUnchanged

      public boolean isUnchanged(URL2 uri, URL2Connection con) throws IOException
      Description copied from interface: URLConnectionFactory
      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.
      Specified by:
      isUnchanged in interface URLConnectionFactory
      Parameters:
      uri - the URI
      con - the URL connection
      Throws:
      IOException
    • close

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

      public long getExpiry(URL2 uri, URL2Connection con) throws IOException
      Description copied from interface: URLConnectionFactory
      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;
      Specified by:
      getExpiry in interface URLConnectionFactory
      Parameters:
      uri - the URI
      con - the URL connection
      Throws:
      IOException