Java Reference
In-Depth Information
• The method writeAsRAF treats the file like a random access file and, after having
enlarged it, writes a string at the end of the file. The general-purpose enlargeFile
method tries to enlarge specified files whenever allowed by the JNLP Client.
•Finally, the method testWrite2 is similar to testWrite ,but asks for a
saveAsFileDialog . The method readBytes at line 81 returns the specified file as a big
chunk of bytes in memory.
Resource Management
The DownloadService and DownloadServiceListener classes are dedicated to the download
and caching of resources, and are often used together with the ExtensionInstallerService .
The DownloadService can return information about cached parts (refer to Chapter 10), parts of
extensions, or simple JAR files. This information can be returned only for items belonging to
the application currently running. In other words, the information can be returned only for
items that are mentioned in the main JNLP file or in referenced JNLP files.
A JAR file, a part, or an extension part could be loaded using the methods loadResource ,
loadPart , and loadExtensionPart . The DownloadServiceListener is used as an argument in
these methods in order to track the download process.
When removing cached items with these methods, resources are rarely deleted immediately.
Rather, JNLP Clients would regard them as no longer needed, and that they should be released
when required in the future.
As an example of cache control, see Listing 11.4.
L ISTING 11.4 An Example Of Cache Control
package com.marinilli.b2.c11;
import com.marinilli.b2.c11.util.*;
import javax.jnlp.*;
* Chapter 11 - Example of DownloadService
* @author Mauro Marinilli
* @version 1.0
public class DownloadExample {
public DownloadExample() {
public static void removeFromJNLPCache(String resourceName){
Search WWH ::

Custom Search