Package org.apache.ivy.util.url
Interface TimeoutConstrainedURLHandler
-
- All Superinterfaces:
URLHandler
- All Known Implementing Classes:
BasicURLHandler
,HttpClientHandler
,URLHandlerDispatcher
public interface TimeoutConstrainedURLHandler extends URLHandler
A enhanced version ofURLHandler
which respectsTimeoutConstraint
s on the operations dealing with download, upload, reachability checks etc...
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ivy.util.url.URLHandler
URLHandler.URLInfo
-
-
Field Summary
-
Fields inherited from interface org.apache.ivy.util.url.URLHandler
REQUEST_METHOD_GET, REQUEST_METHOD_HEAD, UNAVAILABLE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
download(java.net.URL src, java.io.File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint)
Downloads the resource available atsrc
to the targetdest
long
getContentLength(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns the number of bytes of data that's available for the resource at the passedurl
.long
getLastModified(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns the last modified timestamp of the resource accessible at the passedurl
.URLHandler.URLInfo
getURLInfo(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns theURLHandler.URLInfo
extracted from the given url, orURLHandler.UNAVAILABLE
when the url is not reachable.boolean
isReachable(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns true if the passedURL
is reachable.java.io.InputStream
openStream(java.net.URL url, TimeoutConstraint timeoutConstraint)
Opens and returns anInputStream
to the passedurl
.void
upload(java.io.File src, java.net.URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint)
Uploads thesrc
File
to the targetdest
URL
-
Methods inherited from interface org.apache.ivy.util.url.URLHandler
download, getContentLength, getContentLength, getLastModified, getLastModified, getURLInfo, getURLInfo, isReachable, isReachable, openStream, setRequestMethod, upload
-
-
-
-
Method Detail
-
isReachable
boolean isReachable(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns true if the passedURL
is reachable. Else returns false. Uses the passedtimeoutConstraint
for determining the connectivity to the URL.Please use
getURLInfo(URL, TimeoutConstraint)
if more one information about theurl
is needed- Parameters:
url
- The URL to accesstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- boolean
- Since:
- 2.5
-
getContentLength
long getContentLength(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns the number of bytes of data that's available for the resource at the passedurl
. Returns 0 if the passedurl
isn't reachable- Parameters:
url
- The URL to accesstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- long
- Since:
- 2.5
-
getLastModified
long getLastModified(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns the last modified timestamp of the resource accessible at the passedurl
.Please use
getURLInfo(URL, TimeoutConstraint)
if more one information about theurl
is needed- Parameters:
url
- The URL to accesstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- long
- Since:
- 2.5
-
getURLInfo
URLHandler.URLInfo getURLInfo(java.net.URL url, TimeoutConstraint timeoutConstraint)
Returns theURLHandler.URLInfo
extracted from the given url, orURLHandler.UNAVAILABLE
when the url is not reachable. Never returns null.- Parameters:
url
- The URL for which the information is to be retrievedtimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- URLInfo
- Since:
- 2.5
-
openStream
java.io.InputStream openStream(java.net.URL url, TimeoutConstraint timeoutConstraint) throws java.io.IOException
Opens and returns anInputStream
to the passedurl
.- Parameters:
url
- The URL to which anInputStream
has to be openedtimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Returns:
- InputStream
- Throws:
java.io.IOException
- if something goes wrong- Since:
- 2.5
-
download
void download(java.net.URL src, java.io.File dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws java.io.IOException
Downloads the resource available atsrc
to the targetdest
- Parameters:
src
- The source URL to download the resource fromdest
- The destinationFile
to download the resource tolistener
- The listener that will be notified of the download progresstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Throws:
java.io.IOException
- if something goes wrong- Since:
- 2.5
-
upload
void upload(java.io.File src, java.net.URL dest, CopyProgressListener listener, TimeoutConstraint timeoutConstraint) throws java.io.IOException
Uploads thesrc
File
to the targetdest
URL
- Parameters:
src
- The sourceFile
to uploaddest
- The target URL where theFile
has to be uploadedlistener
- The listener that will be notified of the upload progresstimeoutConstraint
- The connectivity timeout constraints. Can be null, in which case the timeouts are implementation specific- Throws:
java.io.IOException
- if something goes wrong- Since:
- 2.5
-
-