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, propertyChange
addPropertyChangeListener, 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, setValues
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
onMessage
protected 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.Exception
protected 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.Exception
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public long getBeginTime()
getBeginTime
in interface Retriever
public final java.nio.ByteBuffer getBuffer()
protected final java.net.URLConnection getConnection()
public final int getConnectTimeout()
getConnectTimeout
in interface Retriever
public final int getContentLength()
getContentLength
in interface Retriever
public final int getContentLengthRead()
getContentLengthRead
in interface Retriever
public final java.lang.String getContentType()
getContentType
in interface Retriever
public long getEndTime()
getEndTime
in interface Retriever
protected long getExpiration(java.net.URLConnection connection)
connection
- Connection for which to get expiration time.public long getExpirationTime()
getExpirationTime
in interface Retriever
public final RetrievalPostProcessor getPostProcessor()
public int getReadTimeout()
getReadTimeout
in interface Retriever
public int getStaleRequestLimit()
getStaleRequestLimit
in interface Retriever
public long getSubmitTime()
getSubmitTime
in interface Retriever
public final java.net.URL getUrl()
public final java.net.URL getURL()
public int hashCode()
hashCode
in class java.lang.Object
protected boolean interrupted()
protected java.net.URLConnection openConnection() throws java.io.IOException
java.io.IOException
protected java.nio.ByteBuffer read() throws java.lang.Exception
java.lang.Exception
protected java.nio.ByteBuffer readNonSpecificStream(java.io.InputStream inputStream, java.net.URLConnection connection) throws java.io.IOException
java.io.IOException
protected java.nio.ByteBuffer readNonSpecificStreamUnknownLength(java.io.InputStream inputStream) throws java.io.IOException
java.io.IOException
protected 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 Retriever
public final void setConnectTimeout(int connectTimeout)
setConnectTimeout
in interface Retriever
protected void setContentLengthRead(int length)
public void setEndTime(long endTime)
setEndTime
in interface Retriever
public void setReadTimeout(int readTimeout)
setReadTimeout
in interface Retriever
public void setStaleRequestLimit(int staleRequestLimit)
setStaleRequestLimit
in interface Retriever
protected void setState(java.lang.String state)
public void setSubmitTime(long submitTime)
setSubmitTime
in interface Retriever
public java.lang.String toString()
toString
in class java.lang.Object