Package org.faceless.publisher.resource
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 Summary
Modifier and TypeMethodDescriptiondefault voidclose(URL2 uri, URL2Connection con) Close the specified URLConnection and free any resources allocated by this factory.default longgetExpiry(URL2 uri, URL2Connection con) Return the absolute expiry time of the resource reeturned by the specified URLConnection, or Long.MAX_VALUE for forever.getURLConnection(URL2 uri, ReportFactory reportFactory) Return a URLConnection for the specified URI, or null if not possible with this factory.default List<URLConnectionProcessor>Return the list ofURLConnectionProcessorobjects that will be run on any network connections that are made by thisURLConnectionFactory.default booleanisEgressRequired(URL2 uri) Return true if egress is potentially required to retrieve this URL.default booleanReturn true if the supplied URL (which will be loadable by this Factory) should be considered trusted.default booleanisUnchanged(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.default voidsetURLConnectionProcessors(List<URLConnectionProcessor> processors) Set the list ofURLConnectionProcessorobjects that will be run on any network connections that are made by thisURLConnectionFactorybooleanReturn true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)
-
Method Details
-
setURLConnectionProcessors
Set the list ofURLConnectionProcessorobjects that will be run on any network connections that are made by thisURLConnectionFactory- Parameters:
processors- the list of processors - the default implementation ignores this.
-
getURLConnectionProcessors
Return the list ofURLConnectionProcessorobjects that will be run on any network connections that are made by thisURLConnectionFactory. The default implementation always returns an empty list.- Returns:
- processors the list of processors
-
getURLConnection
Return a URLConnection for the specified URI, or null if not possible with this factory.- Parameters:
uri- the URIreportFactory- the ReportFactory that owns this connection- Throws:
IOException
-
supports
Return true if this factory can load the specified URI schema (eg http, ftp, jar, jdbc)- Parameters:
uri- the URI- Returns:
- whether the URL is supported by this factory
-
isEgressRequired
Return true if egress is potentially required to retrieve this URL. There is a default implementation which returns true.- Parameters:
uri- the URI- Returns:
- whether egress is required
-
isUnchanged
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 URIcon- the URL connection- Throws:
IOException
-
close
Close the specified URLConnection and free any resources allocated by this factory. There is a default implementation which does nothing.- Parameters:
uri- the URIcon- the URL connection- Throws:
IOException
-
getExpiry
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 URIcon- the URL connection- Throws:
IOException
-
isTrusted
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:
-