Class Resource
- java.lang.Object
-
- net.adoptopenjdk.icedteaweb.resources.Resource
-
public class Resource extends java.lang.ObjectInformation about a single resource to download. This class tracks the downloading of various resources of a JNLP file to local files. It can be used to download icons, jnlp and extension files, jars, and jardiff files using the version based protocol or any file using the basic download protocol.
Resources can be put into download groups by specifying a part name for the resource. The resource tracker can also be configured to prefetch resources, which are downloaded in the order added to the media tracker.
- Version:
- $Revision: 1.9 $
-
-
Field Summary
Fields Modifier and Type Field Description private DownloadOptionsdownloadOptionsDownload options for this resourceprivate java.util.concurrent.Future<Resource>futureForDownloadedA future to wait for completion of download of this resourceprivate java.io.FilelocalFilethe local file downloaded toprivate java.net.URLlocationthe remote location of the resourceprivate java.beans.PropertyChangeSupportpropertyChangeSupportprivate VersionStringrequestVersionthe requested versionprivate static WeakList<Resource>resourceslist of weak references of resources currently in useprivate longsizetotal size of the resource, or -1 if unknownstatic java.lang.StringSIZE_PROPERTYprivate ResourceStatusstatusthe status of the resourceprivate longtransferredamount in bytes transferredstatic java.lang.StringTRANSFERRED_PROPERTYprivate UpdatePolicyupdatePolicyUpdate policy for this resource
-
Constructor Summary
Constructors Modifier Constructor Description privateResource(java.net.URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy)Create a resource.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)(package private) static ResourcecreateOrGetResource(java.net.URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy)Creates and returns a shared Resource object representing the given location and version.booleanequals(java.lang.Object other)booleanforceUpdateRequested()DownloadOptionsgetDownloadOptions()(package private) java.io.FilegetLocalFile()java.net.URLgetLocation()Returns the remote location of the resource.VersionStringgetRequestVersion()java.lang.StringgetSimpleName()longgetSize()Returns the size of the resource(package private) longgetTransferred()UpdatePolicygetUpdatePolicy()inthashCode()(package private) booleanhasStatus(ResourceStatus flag)Check if the specified flag is set.(package private) booleanisBeingProcessed()(package private) booleanisComplete()(package private) java.util.concurrent.Future<Resource>putIntoCache(java.util.concurrent.Executor downloadExecutor)voidsetLocalFile(java.io.File localFile)Sets the local file to be downloadedvoidsetSize(long size)Sets the size of the resourcevoidsetStatus(ResourceStatus status)Changes the status.voidsetTransferred(long transferred)Sets the amount transferredjava.lang.StringtoString()
-
-
-
Field Detail
-
resources
private static final WeakList<Resource> resources
list of weak references of resources currently in use
-
SIZE_PROPERTY
public static final java.lang.String SIZE_PROPERTY
- See Also:
- Constant Field Values
-
TRANSFERRED_PROPERTY
public static final java.lang.String TRANSFERRED_PROPERTY
- See Also:
- Constant Field Values
-
propertyChangeSupport
private final java.beans.PropertyChangeSupport propertyChangeSupport
-
location
private final java.net.URL location
the remote location of the resource
-
requestVersion
private final VersionString requestVersion
the requested version
-
updatePolicy
private final UpdatePolicy updatePolicy
Update policy for this resource
-
downloadOptions
private final DownloadOptions downloadOptions
Download options for this resource
-
localFile
private java.io.File localFile
the local file downloaded to
-
transferred
private volatile long transferred
amount in bytes transferred
-
size
private volatile long size
total size of the resource, or -1 if unknown
-
futureForDownloaded
private volatile java.util.concurrent.Future<Resource> futureForDownloaded
A future to wait for completion of download of this resource
-
status
private volatile ResourceStatus status
the status of the resource
-
-
Constructor Detail
-
Resource
private Resource(java.net.URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy)Create a resource.
-
-
Method Detail
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
-
createOrGetResource
static Resource createOrGetResource(java.net.URL location, VersionString requestVersion, DownloadOptions downloadOptions, UpdatePolicy updatePolicy)
Creates and returns a shared Resource object representing the given location and version.- Parameters:
location- final location of resourcerequestVersion- final version of resourcedownloadOptions- hint for downloadingupdatePolicy- final policy for updating- Returns:
- new resource, which is already added in resources list
-
getLocation
public java.net.URL getLocation()
Returns the remote location of the resource.- Returns:
- the same location as the one with which this resource was created
-
getLocalFile
java.io.File getLocalFile()
- Returns:
- the local file currently being downloaded
-
setLocalFile
public void setLocalFile(java.io.File localFile)
Sets the local file to be downloaded- Parameters:
localFile- location of stored resource
-
getRequestVersion
public VersionString getRequestVersion()
- Returns:
- the requested version
-
getTransferred
long getTransferred()
- Returns:
- the amount in bytes transferred
-
setTransferred
public void setTransferred(long transferred)
Sets the amount transferred- Parameters:
transferred- set the whole transferred amount to this value
-
getSize
public long getSize()
Returns the size of the resource- Returns:
- size of resource (-1 if unknown)
-
setSize
public void setSize(long size)
Sets the size of the resource- Parameters:
size- desired size of resource
-
isBeingProcessed
boolean isBeingProcessed()
-
hasStatus
boolean hasStatus(ResourceStatus flag)
Check if the specified flag is set.- Parameters:
flag- a status flag- Returns:
- true iff the flag is set
-
isComplete
boolean isComplete()
-
getUpdatePolicy
public UpdatePolicy getUpdatePolicy()
- Returns:
- the update policy for this resource
-
forceUpdateRequested
public boolean forceUpdateRequested()
-
setStatus
public void setStatus(ResourceStatus status)
Changes the status.- Parameters:
status- a collection of status flags to set
-
getDownloadOptions
public DownloadOptions getDownloadOptions()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getSimpleName
public java.lang.String getSimpleName()
-
putIntoCache
java.util.concurrent.Future<Resource> putIntoCache(java.util.concurrent.Executor downloadExecutor)
-
-