com.sun.jaw.impl.agent.services.mlet
Class MLetCacheVersionSrv

java.lang.Object
  |
  +--com.sun.jaw.impl.agent.services.mlet.MLetSrv
        |
        +--com.sun.jaw.impl.agent.services.mlet.MLetCacheVersionSrv

public class MLetCacheVersionSrv
extends MLetSrv
implements java.io.Serializable

This class extends the MLetSrv class to provide caching and version control. This is achieved by overriding the check method of the MLetSrv class.

The check method is invoked to determine whether a .jar file is to be downloaded across the network from the server, or locally from the cache. It does this by comparing the value of the VERSION attribute in the MLET tag with the version number of the .jar file stored locally. If the version in the cache is older than that specified in the MLET tag, the .jar file is loaded from the server. Otherwise, it is loaded from the cache. If the caching directory does not exist on the system or the agent does not have the permission to write to it, then the .jar files will be always loaded from the server and versioning will not be carried out.

Information on the version numbers of cached .jar files is stored in a file named VERSION in the cache directory. The m-let service updates the version number of a .jar file with the value of the VERSION attribute in the MLET tag each time it loads the .jar file from the server. The VERSION file is an ASCII file in which each line contains the name of a .jar file and its version number. The version number is a series of non-negative decimal integers each separated by a period from the one that precedes it.

Example VERSION file:

 firstfile.jar     1.0
 secondfile.jar    3.0
 thirdfile.jar     1.0.1
 fourthfile.jar    2.1
 ...
 

The directory in which cache files are stored by default is specified in the following order:

  1. The value of the jaw.mlet.cache.dir property.
  2. The return value of getVarDir("mletcache") in class DefaultPaths.

See Also:
MLet, MLetSrv, Serialized Form

Field Summary
protected  java.lang.String cacheDir
          The local path for versioning.
 
Fields inherited from class com.sun.jaw.impl.agent.services.mlet.MLetSrv
cmf, mletList
 
Constructor Summary
MLetCacheVersionSrv()
          Instantiates the m-let service that provides caching and version control.
 
Method Summary
 java.net.URL check(java.lang.String version, java.net.URL codebase, java.lang.String jarfile, MLet mlet)
          Determines whether a .jar file is to be downloaded across the network from the server, or locally from the cache.
 java.lang.String getCacheDirectory()
          Gets the cache directory.
static java.lang.String getClassVersion()
          Gets the version of this class.
 void setCacheDirectory(java.lang.String cache_dir)
          Sets the cache directory.
 
Methods inherited from class com.sun.jaw.impl.agent.services.mlet.MLetSrv
deleteCmf, getLibraryDirectory, initCmf, performGetResource, performGetResource, performGetResourceAsStream, performGetResourceAsStream, performLoadURL, performLoadURL, performLocalLoadURL, performLocalLoadURL, performRemoteLoadURL, performRemoteLoadURL, setLibraryDirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cacheDir

protected java.lang.String cacheDir
The local path for versioning.
Constructor Detail

MLetCacheVersionSrv

public MLetCacheVersionSrv()
Instantiates the m-let service that provides caching and version control.
Method Detail

check

public java.net.URL check(java.lang.String version,
                          java.net.URL codebase,
                          java.lang.String jarfile,
                          MLet mlet)
Determines whether a .jar file is to be downloaded across the network from the server, or locally from the cache.

The method does this by comparing the value of the VERSION attribute in the MLET tag with the version number of the .jar file stored locally. If the version in the cache is older than that specified in the MLET tag, the .jar file is loaded from the server. Otherwise, it is loaded from the cache.

Parameters:
version - The version number of the .jar file stored locally.
codebase - The base URL of the remote .jar file.
jarfile - The name of the .jar file to be loaded.
mlet - The MLet instance that represents the MLET tag.
Returns:
The URL where the .jar file is to be loaded from.
Overrides:
check in class MLetSrv

getClassVersion

public static java.lang.String getClassVersion()
Gets the version of this class.
Returns:
The version of this class.

getCacheDirectory

public java.lang.String getCacheDirectory()
Gets the cache directory.
Returns:
The cache directory.

setCacheDirectory

public void setCacheDirectory(java.lang.String cache_dir)
Sets the cache directory.
Parameters:
cache_dir - The absolute path to the cache directory. The directory must exist.