LoadableHttpResourceBuilder
| Modifier and Type | Class and Description |
|---|---|
| private class | LoadableHttpResource.
InputStream , that helps managing the load count. |
| Modifier and Type | Field and Description |
|---|---|
| private final AtomicInteger | accessCount
How many times this resource was accessed. |
| private final ResourceCache | cache
The cache used. |
| private long | cacheTTLMillis
The time to live (TTL) of cache entries in milliseconds, by default 24 h. |
| private volatile SoftReference | data
The current data array. |
| private final URI | fallbackLocation
The fallback location (classpath). |
| private long | lastLoaded
THe timestamp of the last successful load. |
| private final AtomicInteger | loadCount
How many times this resource was successfully loaded. |
| private final Object | lock
Lock for this instance. |
| private static final Logger | LOG
The logger used. |
| private final Map | properties
The resource configuration. |
| private final List | remoteResources
The remote URLs to be looked up (first wins). |
| private final String | resourceId
resource id. |
| private final LoaderService. | updatePolicy
The required update policy for this resource. |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| protected void | clearCache()
This method is called when the cached data should be removed, e.g. after an explicit fallback reload, or a clear operation. |
| public final int | |
| public final byte[] | |
| public InputStream | Returns: the input stream.Implements org. Get the resource data as input stream. |
| public final URI | |
| public final long | |
| public final int | Returns: the number of successful loads.Get the number of active loads of this resource (InputStream). |
| public Map | Returns: the configuration properties of this resource, never null.Get the configuration properties of this resource. |
| public final List | |
| public final String | |
| public LoaderService. | Returns: the UpdatePolicy of this resource, never null.Get the UpdatePolicy of this resource. |
| public boolean | Returns: true, if load succeeded.Loads the resource, first from the remote resources, if that fails from the fallback location. |
| protected boolean | |
| public boolean | |
| public boolean | |
| public boolean | Returns: true, if data could be read and applied from the cache sucdcessfully.This method is called when the data should be loaded from the cache. |
| public boolean | Returns: true on success.Explicitly override the resource wih the fallback context and resets the load counter. |
| protected final void | |
| private boolean | |
| public String | |
| public void | |
| protected void | writeCache()
This method is called after data could be successfully loaded from a non fallback resource. |
| accessCount | back to summary |
|---|---|
| private final AtomicInteger accessCount How many times this resource was accessed. | |
| cache | back to summary |
|---|---|
| private final ResourceCache cache The cache used. | |
| cacheTTLMillis | back to summary |
|---|---|
| private long cacheTTLMillis The time to live (TTL) of cache entries in milliseconds, by default 24 h. | |
| data | back to summary |
|---|---|
| private volatile SoftReference<byte[]> data The current data array. | |
| fallbackLocation | back to summary |
|---|---|
| private final URI fallbackLocation The fallback location (classpath). | |
| lastLoaded | back to summary |
|---|---|
| private long lastLoaded THe timestamp of the last successful load. | |
| loadCount | back to summary |
|---|---|
| private final AtomicInteger loadCount How many times this resource was successfully loaded. | |
| lock | back to summary |
|---|---|
| private final Object lock Lock for this instance. | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG The logger used. | |
| properties | back to summary |
|---|---|
| private final Map<String, String> properties The resource configuration. | |
| remoteResources | back to summary |
|---|---|
| private final List<URI> remoteResources The remote URLs to be looked up (first wins). | |
| resourceId | back to summary |
|---|---|
| private final String resourceId resource id. | |
| updatePolicy | back to summary |
|---|---|
| private final LoaderService. The required update policy for this resource. | |
| LoadableHttpResource | back to summary |
|---|---|
| pack-priv LoadableHttpResource(ResourceCache cache, LoadDataInformation loadDataInformation) | |
| clearCache | back to summary |
|---|---|
| protected void clearCache() This method is called when the cached data should be removed, e.g. after an explicit fallback reload, or a clear operation. | |
| getAccessCount | back to summary |
|---|---|
| public final int getAccessCount() Get the number of successful accesses.
| |
| getData | back to summary |
|---|---|
| public final byte[] getData() Get the resource data. This will trigger a full load, if the resource is not loaded, e.g. for LAZY resources.
| |
| getDataStream | back to summary |
|---|---|
| public InputStream getDataStream() Implements org. Get the resource data as input stream.
| |
| getFallbackResource | back to summary |
|---|---|
| public final URI getFallbackResource() Return the fallback location.
| |
| getLastLoaded | back to summary |
|---|---|
| public final long getLastLoaded() Get the timestamp of the last succesful load.
| |
| getLoadCount | back to summary |
|---|---|
| public final int getLoadCount() Get the number of active loads of this resource (InputStream).
| |
| getProperties | back to summary |
|---|---|
| public Map Get the configuration properties of this resource. | |
| getRemoteResources | back to summary |
|---|---|
| public final List Get the remote locations. | |
| getResourceId | back to summary |
|---|---|
| public final String getResourceId() Get the resourceId.
| |
| getUpdatePolicy | back to summary |
|---|---|
| public LoaderService. Get the UpdatePolicy of this resource.
| |
| load | back to summary |
|---|---|
| public boolean load() Loads the resource, first from the remote resources, if that fails from the fallback location.
| |
| load | back to summary |
|---|---|
| protected boolean load(URI itemToLoad, boolean fallbackLoad) Tries to load the data from the given location. The location hereby can be a remote location or a local location. Also it can be an URL pointing to a current dataset, or an url directing to fallback resources, e.g. within the current classpath. | |
| loadFallback | back to summary |
|---|---|
| public boolean loadFallback() Try to load the resource from the fallback resources. This will override any remote data already loaded, and also will clear the cached data.
| |
| loadRemote | back to summary |
|---|---|
| public boolean loadRemote() Try to load the resource from the remote locations.
| |
| readCache | back to summary |
|---|---|
| public boolean readCache() This method is called when the data should be loaded from the cache. This method abstracts the effective caching mechanism implemented. By default it tries to read a file from the current user's home directory. If the data could be read, #setData(byte[]) should be called to apply the data read.
| |
| resetToFallback | back to summary |
|---|---|
| public boolean resetToFallback() Explicitly override the resource wih the fallback context and resets the load counter.
| |
| setData | back to summary |
|---|---|
| protected final void setData(byte[] bytes) | |
| shouldReadDataFromFallback | back to summary |
|---|---|
| private boolean shouldReadDataFromFallback() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non-
| |
| unload | back to summary |
|---|---|
| public void unload() | |
| writeCache | back to summary |
|---|---|
| protected void writeCache() throws IOException This method is called after data could be successfully loaded from a non fallback resource. This method by default writes an file containing the data into the user's local home directory, so subsequent or later calls, even after a VM restart, should be able to recover this information. | |
| Modifier and Type | Field and Description |
|---|---|
| private final InputStream |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| wrapped | back to summary |
|---|---|
| private final InputStream wrapped | |
| WrappedInputStream | back to summary |
|---|---|
| pack-priv WrappedInputStream(InputStream wrapped) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |