jautil.avatar
Class AvatarsCacheHandler

java.lang.Object
  extended by jautil.avatar.AvatarsCacheHandler

public class AvatarsCacheHandler
extends java.lang.Object

An avatars cache handler provides access to a local cache for a potentially remote and dispersed collection of avatar definition data files.

Each cache is bound to a specific version of JASigning.

Each avatar is represented by a pair of cache entries: a descriptor, represented here as an AvatarCacheDescriptor, and the cached copy of the original avatar data. The contents of the descriptor include the avatar name and the original source URL for the avatar data. The avatar data itself is a JAR file containing the avatar definition files together with an access class.

The obvious way to support this cache would be through the standard Java caching mechanism, the JNLP Persistence Service. However, that service seems not to be available to HTML applets -- at least not automatically so: a typical applet dies a horrible death as soon as it tries to use that service. So this cache is implemented using the local file system: the descriptor and data files for a given avatar AV are held in the directory .jasigning/avatars/AV under the given user's base directory.


Constructor Summary
AvatarsCacheHandler()
          Constructs a new avatar cache handler.
 
Method Summary
 AvatarCacheDescriptor ensureCached(java.lang.String av, java.lang.String avurl)
          Tries to ensure that the avatar cache contains an up-to-date pair of entries for the avatar with the given name and original data URL, returning the avatar cache descriptor if successful, or null otherwise.
 java.lang.String getDataFileURL(AvatarCacheDescriptor desc)
          Returns the data file URL for the avatar to which the given cache descriptor refers.
 boolean isCached(java.lang.String av, java.lang.String url)
          Determines whether the cache contains an (up-to-date) pair of entries for the avatar with the given name and original data URL.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AvatarsCacheHandler

public AvatarsCacheHandler()
Constructs a new avatar cache handler.

Method Detail

isCached

public boolean isCached(java.lang.String av,
                        java.lang.String url)
Determines whether the cache contains an (up-to-date) pair of entries for the avatar with the given name and original data URL.


ensureCached

public AvatarCacheDescriptor ensureCached(java.lang.String av,
                                          java.lang.String avurl)
Tries to ensure that the avatar cache contains an up-to-date pair of entries for the avatar with the given name and original data URL, returning the avatar cache descriptor if successful, or null otherwise. If necessary, a new pair of cache entries is created or an existing stale data entry is refreshed.


getDataFileURL

public java.lang.String getDataFileURL(AvatarCacheDescriptor desc)
Returns the data file URL for the avatar to which the given cache descriptor refers.