Java Reference
In-Depth Information
L ISTING 11.5 Continued
public PersistenceService getPersistenceService() {
return persistenceService;
public URL getUrl(String keyString) {
URL codebase = Utilities.getBasicService().getCodeBase();
URL url = null;
try {
url = new URL(codebase,keyString);
} catch (IOException ioe) {
System.out.println(getClass()+”.getUrl(“+keyString+”): “+ioe);
return url;
This class provides the following wrapper methods:
public void write(String keyString, Object value) . It persistently saves the
given object at the given key location.
public void write(String keyString, Object value, long maxLength) . The same
as the previous method, but it also specifies the maximum space allocable to the object
serialized on disk.
public void write(URL url, Object value, long maxLength) . The same as the
preceding method, but a URL is supplied to identify the resource. Note that if the URL is
not based on the codebase value (that is, it is not rooted on the Web server that deployed
the application), the service won't work.
public Object read(String keyString) and public Object read(URL url) . Will
return an object given a key, expressed as a string or a complete URL.
public boolean exists(URL url) . Returns true if there are some data cached with
that URL as a key.
public void synchronize(String keyString) and public void synchronize(URL
url) . Synchronize the data, tagging it as explained before.
public void removeEntry(URL url) . Remove the given entry from the local cache.
public List getEntries(String keyString) . Returns a List collection for all the
entries stored at the given URL.
Search WWH ::

Custom Search