Package | Class | Tree | Index
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.jnlp
Interface PersistenceService

public interface PersistenceService

`PersistenceService` provides methods for storing data locally on the client system, even for applications that are running in the untrusted execution environment. The service is somewhat similar to that which the cookie mechanism provides to HTML-based applications.

Each entry in the persistence data store is named with a URL. This provides a similar hierarchical structure as a traditional file system.

An application is only allowed to access data stored with a URL that is based on its codebase. For example, given the codebase `http://www.mysite.com/apps/App1/`, the application would be allowed to access the data at the associated URLs:

- `http://www.mysite.com/apps/App1/`
- `http://www.mysite.com/apps/`
- `http://www.mysite.com/`

This scheme allows sharing of data between different applications from the same host. For example, if another application is located at `http://www.mysite.com/apps/App2/`, then they can share data between them in the `http://www.mysite.com/` and `http://www.mysite.com/apps/` directories.

A JNLP client should track the amount of storage that a given application uses. A `PersistenceService` implementation provides methods to get the current storage usage and limits and to request more storage. Storage is allocated on a per file basis, but a JNLP Client will typically grant or deny the request based on the total storage is use by an application.

Data stored using this mechanism is intended to be a local copy of data stored on a remote server. The individual entries can be tagged as either cached, meaning the server has an up-to-date copy, dirty, meaning the server does not have an up-to-date copy, or temporary, meaning that the file can always be recreated.

Version:
  1.0

Field Summary
`static int` | `CACHED`
`static int` | `DIRTY`
`static int` | `TEMPORARY`

Method Summary
`long` | `create(java.net.URL url, long maxsize)` Creates a new persistent storage entry on the client side named with the given URL.
`void` | `delete(java.net.URL url)` Removes the stream associated with the given URL from the client-side date persistence store.
`FileContents` | `get(java.net.URL url)` Returns a `FileContents` object representing the contents of this file.
`java.lang.String[]` | `getNames(java.net.URL url)` Returns an array of Strings containing the names of all the entries for a given URL.
`int` | `getTag(java.net.URL url)` Returns an `int` corresponding to the current value of the tag for the persistent data store entry associated with the given URL.
`void` | `setTag(java.net.URL url, int tag)` Tags the persistent data store entry associated with the given URL with the given tag value.

Field Detail

### CACHED

    public static final int CACHED

### TEMPORARY

    public static final int TEMPORARY

### DIRTY

    public static final int DIRTY

Method Detail

### create

    public long create(java.net.URL url,
                       long maxsize)
                throws java.net.MalformedURLException,
                       java.io.IOException

  Creates a new persistent storage entry on the client side named with the given URL.
  Parameters:
    `url` - the URL representing the name of the entry in the persistent data store.
    `maxsize` - maximum size of storage that can be written to this entry.
  Returns:
    the maximum size of storage that got granted, in bytes.
  Throws:
    java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
    java.io.IOException - if an I/O exception occurs, or the entry already exists.

### get

    public FileContents get(java.net.URL url)
                     throws java.net.MalformedURLException,
                            java.io.IOException,
                            java.io.FileNotFoundException

  Returns a `FileContents` object representing the contents of this file.
  Parameters:
    `url` - the URL representing the persistent data store entry.
  Returns:
    the file contents as a FileContents.
  Throws:
    java.io.IOException - if an I/O error occurs.
    java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
    java.io.FileNotFoundException - if a persistence store for the given URL is not found.

### delete

    public void delete(java.net.URL url)
                throws java.net.MalformedURLException,
                       java.io.IOException

  Removes the stream associated with the given URL from the client-side date persistence store.
  Parameters:
    `url` - the URL representing the entry to delete from the persistent data store.
  Throws:
    java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
    java.io.IOException - if an I/O exception occurs.

### getNames

    public java.lang.String[] getNames(java.net.URL url)
                                throws java.net.MalformedURLException,
                                       java.io.IOException

  Returns an array of Strings containing the names of all the entries for a given URL.
  Parameters:
    `url` - the URL representing the root directory to search for entry names.
  Returns:
    a `String` array containing the entries names.
  Throws:
    java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
    java.io.IOException - if an I/O exception occurs.

### getTag

    public int getTag(java.net.URL url)
               throws java.net.MalformedURLException,
                      java.io.IOException

  Returns an `int` corresponding to the current value of the tag for the persistent data store entry associated with the given URL.
  Parameters:
    `url` - the URL representing the persistent data store entry for which the tag value is requested.
  Returns:
    an `int` containing one of the following tag values:
    - `CACHED`
    - `TEMPORARY`
    - `DIRTY`
  Throws:
    java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
    java.io.IOException - if an I/O exception occurs.

### setTag

    public void setTag(java.net.URL url,
                       int tag)
                throws java.net.MalformedURLException,
                       java.io.IOException

  Tags the persistent data store entry associated with the given URL with the given tag value.
  Parameters:
    `url` - the URL representing the persistent data store entry for which to set the tag value.
    `tag` - the tag value to set.
  Throws:
    java.net.MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
    java.io.IOException - if an I/O exception occurs.

Package | Class | Tree | Index
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2001-2002 Sun Microsystems, Inc. All Rights Reserved