Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

boolean net::sourceforge::jnlp::cache::ResourceTracker::checkCache ( Resource  resource,
UpdatePolicy  updatePolicy 
) [inline, private]

Check the cache for a resource, and initialize the resource as already downloaded if found.

Parameters:
updatePolicy whether to check for updates if already in cache
Returns:
whether the resource are already downloaded

Definition at line 222 of file ResourceTracker.java.

References net::sourceforge::jnlp::cache::UpdatePolicy::ALWAYS, net::sourceforge::jnlp::cache::Resource::changeStatus(), net::sourceforge::jnlp::cache::Resource::downloadVersion, fireDownloadEvent(), net::sourceforge::jnlp::cache::UpdatePolicy::FORCE, net::sourceforge::jnlp::cache::CacheEntry::isCached(), net::sourceforge::jnlp::cache::Resource::localFile, net::sourceforge::jnlp::cache::Resource::location, net::sourceforge::jnlp::cache::UpdatePolicy::shouldUpdate(), net::sourceforge::jnlp::cache::Resource::size, and net::sourceforge::jnlp::cache::Resource::transferred.

Referenced by addResource().

                                                                             {
        if (!CacheUtil.isCacheable(resource.location, resource.downloadVersion)) {
            // pretend that they are already downloaded; essentially
            // they will just 'pass through' the tracker as if they were
            // never added (for example, not affecting the total download size).
            synchronized (resource) {
                resource.changeStatus(0, DOWNLOADED|CONNECTED|STARTED);
            }
            fireDownloadEvent(resource);
            return true;
        }

        if (updatePolicy != UpdatePolicy.ALWAYS && updatePolicy != UpdatePolicy.FORCE) { // save loading entry props file
            CacheEntry entry = new CacheEntry(resource.location, resource.downloadVersion);

            if (entry.isCached() && !updatePolicy.shouldUpdate(entry)) {
                if (JNLPRuntime.isDebug())
                    System.out.println("not updating: "+resource.location);

                synchronized (resource) {
                    resource.localFile = CacheUtil.getCacheFile(resource.location, resource.downloadVersion);
                    resource.size = resource.localFile.length();
                    resource.transferred = resource.localFile.length();
                    resource.changeStatus(0, DOWNLOADED|CONNECTED|STARTED);
                }
                fireDownloadEvent(resource);
                return true;
            }
        }

        if (updatePolicy == UpdatePolicy.FORCE) { // ALWAYS update
            // When we are "always" updating, we update for each instance. Reset resource status.
            resource.changeStatus(Integer.MAX_VALUE, 0);
        }

        // may or may not be cached, but check update when connection
        // is open to possibly save network communication time if it
        // has to be downloaded, and allow this call to return quickly
        return false;
    }


Generated by  Doxygen 1.6.0   Back to index