Package org.faceless.publisher.resource
Class Http1URLConnectionFactory
java.lang.Object
org.faceless.publisher.resource.Http1URLConnectionFactory
- All Implemented Interfaces:
URLConnectionFactory
A URLConnectionFactory that handles the "http", "https", "ftp"
URLs, ie. those handled by Java by default
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(URL2 uri, URL2Connection con) Close the specified URLConnection and free any resources allocated by this factory.int
Return the connection timeout, as set bysetConnectTimeout(int)
long
getExpiry
(URL2 uri, URL2Connection con) Return the absolute expiry time of the resource reeturned by the specified URLConnection, or Long.MAX_VALUE for forever.int
Return the minimum validity , as set bysetMinimumValidity(int)
int
Return the read timeout, as set bysetReadTimeout(int)
getURLConnection
(URL2 uri, ReportFactory reportFactory) Return a URLConnection for the specified URI, or null if not possible with this factory.Return the list ofURLConnectionProcessor
objects that will be run on any network connections that are made by thisURLConnectionFactory
.Return the "User-Agent" HTTP header, as set bysetUserAgent(java.lang.String)
boolean
isUnchanged
(URL2 uri, URL2Connection con) 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.void
setConnectTimeout
(int timeout) Set the period in milliseconds after which an attempt to connect to a URL is considered to have failed.void
setMinimumValidity
(int validity) Set the minimum period for which an HTTP/HTTPS resource is considered valid.void
setReadTimeout
(int timeout) Set the period in milliseconds after which an attempt to read from a URL is considered to have failed.void
setURLConnectionProcessors
(List<URLConnectionProcessor> processors) Set the list ofURLConnectionProcessor
objects that will be run on any network connections that are made by thisURLConnectionFactory
void
setUserAgent
(String userAgent) Set the "User-Agent" HTTP header, or null to use the system default.boolean
Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)toString()
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.faceless.publisher.resource.URLConnectionFactory
isTrusted
-
Constructor Details
-
Http1URLConnectionFactory
public Http1URLConnectionFactory()
-
-
Method Details
-
setURLConnectionProcessors
Description copied from interface:URLConnectionFactory
Set the list ofURLConnectionProcessor
objects that will be run on any network connections that are made by thisURLConnectionFactory
- Specified by:
setURLConnectionProcessors
in interfaceURLConnectionFactory
- Parameters:
processors
- the list of processors - the default implementation ignores this.
-
getURLConnectionProcessors
Description copied from interface:URLConnectionFactory
Return the list ofURLConnectionProcessor
objects that will be run on any network connections that are made by thisURLConnectionFactory
. The default implementation always returns an empty list.- Specified by:
getURLConnectionProcessors
in interfaceURLConnectionFactory
- Returns:
- processors the list of processors
-
getURLConnection
Description copied from interface:URLConnectionFactory
Return a URLConnection for the specified URI, or null if not possible with this factory.- Specified by:
getURLConnection
in interfaceURLConnectionFactory
- Parameters:
uri
- the URIreportFactory
- the ReportFactory that owns this connection- Throws:
IOException
-
getConnectTimeout
public int getConnectTimeout()Return the connection timeout, as set bysetConnectTimeout(int)
-
getReadTimeout
public int getReadTimeout()Return the read timeout, as set bysetReadTimeout(int)
-
getMinimumValidity
public int getMinimumValidity()Return the minimum validity , as set bysetMinimumValidity(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
Set the "User-Agent" HTTP header, or null to use the system default. The initial value is "BFO Publisher/" + the version number -
getUserAgent
Return the "User-Agent" HTTP header, as set bysetUserAgent(java.lang.String)
-
toString
-
supports
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 interfaceURLConnectionFactory
- Parameters:
uri
- the URI
-
isUnchanged
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 interfaceURLConnectionFactory
- Parameters:
uri
- the URIcon
- the URL connection- Throws:
IOException
-
close
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 interfaceURLConnectionFactory
- Parameters:
uri
- the URIcon
- the URL connection- Throws:
IOException
-
getExpiry
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 interfaceURLConnectionFactory
- Parameters:
uri
- the URIcon
- the URL connection- Throws:
IOException
-