public abstract class URLRetriever extends WWObjectImpl implements Retriever
| Modifier and Type | Field and Description |
|---|---|
protected long |
beginTime |
protected java.nio.ByteBuffer |
byteBuffer |
protected java.net.URLConnection |
connection |
protected int |
connectTimeout |
protected int |
contentLength |
protected java.util.concurrent.atomic.AtomicInteger |
contentLengthRead |
protected java.lang.String |
contentType |
protected long |
endTime |
protected java.util.concurrent.atomic.AtomicLong |
expiration |
static java.lang.String |
EXTRACT_ZIP_ENTRY
Applications never need to use this constant.
|
protected RetrievalPostProcessor |
postProcessor |
protected int |
readTimeout |
protected int |
staleRequestLimit |
protected java.lang.String |
state |
protected long |
submitTime |
protected java.net.URL |
url |
RETRIEVER_STATE_CONNECTING, RETRIEVER_STATE_ERROR, RETRIEVER_STATE_INTERRUPTED, RETRIEVER_STATE_NOT_STARTED, RETRIEVER_STATE_READING, RETRIEVER_STATE_STARTED, RETRIEVER_STATE_SUCCESSFUL| Constructor and Description |
|---|
URLRetriever(java.net.URL url,
RetrievalPostProcessor postProcessor) |
| Modifier and Type | Method and Description |
|---|---|
Retriever |
call() |
protected void |
configureSSLContext(javax.net.ssl.HttpsURLConnection connection) |
static URLRetriever |
createRetriever(java.net.URL url,
RetrievalPostProcessor postProcessor)
Create the appropriate retriever for a URL's protocol.
|
protected java.nio.ByteBuffer |
doRead(java.net.URLConnection connection) |
protected void |
end() |
boolean |
equals(java.lang.Object o) |
long |
getBeginTime() |
java.nio.ByteBuffer |
getBuffer() |
protected java.net.URLConnection |
getConnection() |
int |
getConnectTimeout() |
int |
getContentLength() |
int |
getContentLengthRead() |
java.lang.String |
getContentType() |
long |
getEndTime() |
protected long |
getExpiration(java.net.URLConnection connection)
Indicates the expiration time specified by either the Expires header or the max-age directive of the
Cache-Control header.
|
long |
getExpirationTime()
Indicates the expiration time of the resource retrieved by this Retriever.
|
java.lang.String |
getName() |
RetrievalPostProcessor |
getPostProcessor() |
int |
getReadTimeout() |
int |
getStaleRequestLimit() |
java.lang.String |
getState() |
long |
getSubmitTime() |
java.net.URL |
getUrl() |
java.net.URL |
getURL() |
int |
hashCode() |
protected boolean |
interrupted() |
protected java.net.URLConnection |
openConnection() |
protected java.nio.ByteBuffer |
read() |
protected java.nio.ByteBuffer |
readNonSpecificStream(java.io.InputStream inputStream,
java.net.URLConnection connection) |
protected java.nio.ByteBuffer |
readNonSpecificStreamUnknownLength(java.io.InputStream inputStream) |
protected java.nio.ByteBuffer |
readZipStream(java.io.InputStream inputStream,
java.net.URL url) |
void |
setBeginTime(long beginTime) |
void |
setConnectTimeout(int connectTimeout) |
protected void |
setContentLengthRead(int length) |
void |
setEndTime(long endTime) |
void |
setReadTimeout(int readTimeout) |
void |
setStaleRequestLimit(int staleRequestLimit) |
protected void |
setState(java.lang.String state) |
void |
setSubmitTime(long submitTime) |
java.lang.String |
toString() |
onMessage, propertyChangeaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValuesonMessageprotected long beginTime
protected volatile java.nio.ByteBuffer byteBuffer
protected volatile java.net.URLConnection connection
protected int connectTimeout
protected volatile int contentLength
protected java.util.concurrent.atomic.AtomicInteger contentLengthRead
protected volatile java.lang.String contentType
protected long endTime
protected java.util.concurrent.atomic.AtomicLong expiration
public static final java.lang.String EXTRACT_ZIP_ENTRY
protected final RetrievalPostProcessor postProcessor
protected int readTimeout
protected int staleRequestLimit
protected volatile java.lang.String state
protected long submitTime
protected final java.net.URL url
public URLRetriever(java.net.URL url,
RetrievalPostProcessor postProcessor)
url - the URL of the resource to retrieve.postProcessor - the retrieval post-processor to invoke when the resource is retrieved. May be null.java.lang.IllegalArgumentException - if url.public final Retriever call() throws java.lang.Exception
call in interface java.util.concurrent.Callable<Retriever>java.lang.Exceptionprotected void configureSSLContext(javax.net.ssl.HttpsURLConnection connection)
public static URLRetriever createRetriever(java.net.URL url, RetrievalPostProcessor postProcessor)
url - the url that will be the source of the retrieval.postProcessor - the retriever's post-processor.java.lang.IllegalArgumentException - if the url is null.protected java.nio.ByteBuffer doRead(java.net.URLConnection connection)
throws java.lang.Exception
connection - the connection to read from.java.lang.Exception - if connection is null or an exception occurs during reading.java.lang.IllegalArgumentException - if connection is nullprotected void end()
throws java.lang.Exception
java.lang.Exceptionpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic long getBeginTime()
getBeginTime in interface Retrieverpublic final java.nio.ByteBuffer getBuffer()
protected final java.net.URLConnection getConnection()
public final int getConnectTimeout()
getConnectTimeout in interface Retrieverpublic final int getContentLength()
getContentLength in interface Retrieverpublic final int getContentLengthRead()
getContentLengthRead in interface Retrieverpublic final java.lang.String getContentType()
getContentType in interface Retrieverpublic long getEndTime()
getEndTime in interface Retrieverprotected long getExpiration(java.net.URLConnection connection)
If both the Expires and Date headers are present then the expiration time is calculated as current time + (expires - date). This helps guard against clock skew between the client and server.
connection - Connection for which to get expiration time.public long getExpirationTime()
getExpirationTime in interface Retrieverpublic final RetrievalPostProcessor getPostProcessor()
public int getReadTimeout()
getReadTimeout in interface Retrieverpublic int getStaleRequestLimit()
getStaleRequestLimit in interface Retrieverpublic long getSubmitTime()
getSubmitTime in interface Retrieverpublic final java.net.URL getUrl()
public final java.net.URL getURL()
public int hashCode()
hashCode in class java.lang.Objectprotected boolean interrupted()
protected java.net.URLConnection openConnection()
throws java.io.IOException
java.io.IOExceptionprotected java.nio.ByteBuffer read()
throws java.lang.Exception
java.lang.Exceptionprotected java.nio.ByteBuffer readNonSpecificStream(java.io.InputStream inputStream,
java.net.URLConnection connection)
throws java.io.IOException
java.io.IOExceptionprotected java.nio.ByteBuffer readNonSpecificStreamUnknownLength(java.io.InputStream inputStream)
throws java.io.IOException
java.io.IOExceptionprotected java.nio.ByteBuffer readZipStream(java.io.InputStream inputStream,
java.net.URL url)
throws java.io.IOException
inputStream - a stream to the zip connection.url - the URL of the zip resource.java.io.IOException - if the stream does not refer to a zip resource or an exception occurs during
reading.java.lang.IllegalArgumentException - if inputStream is nullpublic void setBeginTime(long beginTime)
setBeginTime in interface Retrieverpublic final void setConnectTimeout(int connectTimeout)
setConnectTimeout in interface Retrieverprotected void setContentLengthRead(int length)
public void setEndTime(long endTime)
setEndTime in interface Retrieverpublic void setReadTimeout(int readTimeout)
setReadTimeout in interface Retrieverpublic void setStaleRequestLimit(int staleRequestLimit)
setStaleRequestLimit in interface Retrieverprotected void setState(java.lang.String state)
public void setSubmitTime(long submitTime)
setSubmitTime in interface Retrieverpublic java.lang.String toString()
toString in class java.lang.Object