Java Reference
In-Depth Information
Tag Value
Meaning
dirty
Server doesn't have an up-to-date copy of the data
cached
Server has an up-to-date copy
temporary
Data that can always be recreated
These states are read by the JNLP Client when it needs to clear the cache. The deletion order
is: temporary files first; then cached data; and, finally, items tagged as dirty .
A Persistence Utility Class
Another utility class provided with this topic, the PersistenceStorage class, is a wrapper of
the PersistenceService object, so that you don't have to deal with FileContents or all the
details typical of the new jnlp API. Instead, the interface of this utility class is very simple to
use, and there is no additional knowledge of the PersistenceService API required in order to
use it. Of course, if you need particular operations, you can always extract the wrapped
PersistenceService object and manage it as required. However, this class will help in the
majority of real cases.
It is useful for storing Java objects locally with a given key. It works much like a Hash table,
saving objects and retrieving them by means of a key (a string or a full URL). The key string is
used to create a URL based on the codebase value (see the getUrl() method at lines 102-111)
in Listing 11.5.
To save a serializable object, just use the following code:
persistenceStorage1.write(“key”, serializableObject);
to read the following value:
Object serializableObject = persistenceStorage1.read(“key”);
Then, cast the obtained object as needed.
L ISTING 11.5 The PersistenceStorage Utility Class
package com.marinilli.b2.c11.util;
import com.marinilli.b2.c11.util.Utilities;
import javax.jnlp.*;
import java.net.URL;
import java.io.*;
import java.util.*;
/**
* Chapter 11 - utility wrapper for PersistenceService
* @author Mauro Marinilli
* @version 1.0
Search WWH ::




Custom Search