Top
Interstage Studio J Business Kit User's Guide
FUJITSU Software

2.3.13 Applet Caching

This section describes the applet caching of JBK Plugin.

By default, JBK Plugin uses the browser cache. As described in '2.3.6 How JBK Plugin Downloads Class Files', when JBK Plugin uses browser functionality for downloading files, they are stored in the browser cache. The browser cache is, however, sometimes cleared because of the limitation of the cache capacity. This causes extra download, though the downloaded file is not actually updated.

To prevent this, JBK Plugin provides its own applet cache. When the applet cache is enabled, the applet is not stored in the browser cache, but stored in the applet cache. JBK Plugin does not automatically clear the applet cache. Therefore, the extra download does not occur. If the user feels inconvenience for the browser cache, we recommend the JBK Plugin applet cache.

Requirements for the Applet Caching

JBK Plugin applet cache is available under the following requirements:

If the user wants to store the other kinds of files into the applet cache, see 'JBK Plugin Applet Caching API'.

Setting for the Applet Caching

To enable the applet cache, code the following line in the jbkplugin.properties file.

jbk.plugin.www.plugin_cache.enable=<applet-cache-used-or-not>
jbk.plugin.www.plugin_cache.dir=<applet-cache-folder>
jbk.plugin.www.plugin_cache.dir.freespace=<applet-cache-folder-free-space>
jbk.plugin.www.plugin_cache.update=<applet-cache-update>
jbk.plugin.www.plugin_cache.accelerate=<use-accelerate-mode-in-"newer">

Specify the following information in the properties:

How to the Applet Caching Works

The applet cache of JBK Plugin works as follows:

JBK Plugin Applet Caching API

To keep the consistency of the applet cache, it must be guaranteed that several threads do not download the same file at the same time. It is guaranteed that Java VM downloads class files, JAR files and image files only from one thread at a time. Therefore, JBK Plugin makes the applet cache enable for only these kinds of files. For the other kinds of files, the user can use JBK Plugin applet caching API to store them into the applet cache. However, the user has to guarantee that those files are downloaded only from one thread at a time.

JBK Plugin applet caching API is as follows:

The class file of the PluginCacheController class is stored in the JBK runtime class directory (the JBK runtime class directory is the "classes" directory below the JBK install directory).

When compiling an applet class using it, check that the class path includes the JBK runtime class directory.

Example

An example of downloading a file

  • not using JBK Plugin applet caching API

    // create a new URL object
    URL url = new URL(/* the URL of the file to be downloaded */);
    // get a URLConnection
    URLConnection conn = url.openConnection();
    // get an input stream
    InputStream in = conn.getInputStream();
    
    /* downloading the file by the input stream (omitted) */
  • using JBK Plugin applet caching API

    // import
    import com.fujitsu.jbk.plugin.browser.www.PluginCacheController;
    // creates a new URL object
    URL url = new URL(/* the URL of the file to be downloaded */);
    
    // get a new URL object for applet caching
    try {
        url = PluginCacheController.getInstance().getCachedURL(url);
    } catch (Throwable ignore) {
        // The exception thrown by getCachedURL() can be ignored.
    }
    
    // get a URLConnection
    URLConnection conn = url.openConnection();
    // get an input stream
    InputStream in = conn.getInputStream();
    
    /* downloading the file by the input stream (omitted) */

Other Topics for the Applet Caching