iSeries Remote Systems
v6.0.0

com.ibm.etools.iseries.core.cache
Class CacheManager

java.lang.Object
  extended bycom.ibm.etools.systems.subsystems.impl.AbstractCacheManager
      extended bycom.ibm.etools.iseries.core.cache.CacheManager
All Implemented Interfaces:
ICacheConstants, com.ibm.etools.systems.subsystems.ICacheManager

public class CacheManager
extends com.ibm.etools.systems.subsystems.impl.AbstractCacheManager
implements ICacheConstants


Field Summary
static String CACHE_FILE_CL_COMMAND_PROPERTIES
           
static String CACHE_FILE_CL_HELP_EXTENSION
           
static String CACHE_FILE_CL_HELP_TABLE_EXTENSION
           
protected static String CACHE_FILE_EXTENSION
           
protected static String CACHE_INDEX_FILE
           
static char CACHE_KEY_DELIMINATOR
           
static String copyright
           
static int USE_CACHE_ALWAYS
           
static int USE_CACHE_LEVELCHECK
           
static int USE_CACHE_NEVER
           
 
Fields inherited from class com.ibm.etools.systems.subsystems.impl.AbstractCacheManager
Copyright
 
Fields inherited from interface com.ibm.etools.iseries.core.cache.ICacheConstants
MAX_SIZE_DEFAULT, PREF_ALWAYS, PREF_CACHE_LISTS, PREF_CL, PREF_CL_HOST, PREF_CL_IGNORE, PREF_CL_RELEASE, PREF_DISABLE_CACHE, PREF_LEVELCHECK, PREF_LOCATION, PREF_MAXSIZE, PREF_MAXSIZE_OPTION, PREF_NEVER, PREF_OFFLINE_UNIVERSAL, PREF_ONLINE_OPTIONS
 
Constructor Summary
protected CacheManager(String hostname)
          The CacheManager is a singleton per host (keyed by hostname).
 
Method Summary
 boolean clearCacheFile(String key)
          Clear the specified cache file
protected  void clearMemoryCache()
          Clear the in-memory cache for this cache manager
protected static String getDataElementName(String name, boolean object)
          Return the name of the DataElement for the specified cache key segment.
protected static String getDataElementType(String name, boolean object)
          Return the type of the DataElement for the specified cache key segment.
protected static String getDirectoryName(com.ibm.etools.systems.dstore.core.model.DataElement element)
          The following three methods are used to map DataElements to directory names.
protected static String getEscapedDirectoryName(String name)
          Get the escaped directory name for the specified String.
protected  String getHostName()
           
 int getOnlineOption()
          Checks the caching preferences to see if the which online caching mode the user has selected.
 boolean isCached(com.ibm.etools.systems.dstore.core.model.DataElement minerRoot, String cacheKey, int dirDepth)
          Checks if the DataElement represented by cacheKey is stored in the cache
 boolean isCachingDisabled()
          Check if caching has been disabled.
 boolean isCheckCacheFirst()
          Check if the communciations layer should check the local cache first for the requested information before retreiving it from the remote host.
 com.ibm.etools.systems.dstore.core.model.DataElement load(com.ibm.etools.systems.dstore.core.model.DataElement minerRoot, String cacheKey, int dirDepth, int treeDepth)
          Loads the DataElement specified by cacheKey into the DataStore tree along with all of it's children up to treeDepth deep.
 void removeNode(com.ibm.etools.systems.dstore.core.model.DataElement minerRoot, String cacheKey, int dirDepth)
          Clear the node in the cache with the specified cache key.
 void save(com.ibm.etools.systems.dstore.core.model.DataElement node, int dirDepth, int treeDepth, boolean saveRefs)
          Save the specified DataElement and it's children to the cache.
 void save(com.ibm.etools.systems.dstore.core.model.DataElement node, int dirDepth, int treeDepth, boolean saveRefs, boolean refresh)
          Save the specified DataElement and it's children to the cache.
 void setCachingDisabled(boolean state)
          Disable caching for this cache manager.
 void setCheckCacheFirst(boolean checkCacheFirst)
          Set whether or not the communications layer should check the local cache first for the requested informatoin before retreiving it from the remote host.
protected  void updateCacheLocation(String newCacheLocation)
           
 boolean useCacheForLists()
          Checks the caching preferences to see if the cache should be used for retrieving lists of information.
 
Methods inherited from class com.ibm.etools.systems.subsystems.impl.AbstractCacheManager
isRestoreFromMemento, setRestoreFromMemento
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values

USE_CACHE_NEVER

public static final int USE_CACHE_NEVER
See Also:
Constant Field Values

USE_CACHE_LEVELCHECK

public static final int USE_CACHE_LEVELCHECK
See Also:
Constant Field Values

USE_CACHE_ALWAYS

public static final int USE_CACHE_ALWAYS
See Also:
Constant Field Values

CACHE_KEY_DELIMINATOR

public static final char CACHE_KEY_DELIMINATOR
See Also:
Constant Field Values

CACHE_INDEX_FILE

protected static final String CACHE_INDEX_FILE
See Also:
Constant Field Values

CACHE_FILE_EXTENSION

protected static final String CACHE_FILE_EXTENSION
See Also:
Constant Field Values

CACHE_FILE_CL_HELP_EXTENSION

public static final String CACHE_FILE_CL_HELP_EXTENSION
See Also:
Constant Field Values

CACHE_FILE_CL_HELP_TABLE_EXTENSION

public static final String CACHE_FILE_CL_HELP_TABLE_EXTENSION
See Also:
Constant Field Values

CACHE_FILE_CL_COMMAND_PROPERTIES

public static final String CACHE_FILE_CL_COMMAND_PROPERTIES
See Also:
Constant Field Values
Constructor Detail

CacheManager

protected CacheManager(String hostname)
The CacheManager is a singleton per host (keyed by hostname). Users should obtain instances from the getInstance() method

Method Detail

updateCacheLocation

protected void updateCacheLocation(String newCacheLocation)

getHostName

protected String getHostName()

isCheckCacheFirst

public boolean isCheckCacheFirst()
Check if the communciations layer should check the local cache first for the requested information before retreiving it from the remote host.

Since:
v5.0 sp1

setCheckCacheFirst

public void setCheckCacheFirst(boolean checkCacheFirst)
Set whether or not the communications layer should check the local cache first for the requested informatoin before retreiving it from the remote host.

Since:
v5.0 sp1

isCachingDisabled

public boolean isCachingDisabled()
Check if caching has been disabled. If caching is disabled then the cache is not updated when new information is retrieved from the iSeries, but may be used when working in offline mode.


setCachingDisabled

public void setCachingDisabled(boolean state)
Disable caching for this cache manager. This was initially added to allow WebFacing to disable caching during WebFacing conversion. The user can configure enabling / disabling the cache via the caching preferences page so you should only override the user's preference in special circumstances. The caller should restore the caching state after the override is no longer required.. For example WebFacing overrides this only during conversion because of the large amounts of data retrieved from the remote system that will never be used from the cache.

Since:
WDSc 5.1

useCacheForLists

public boolean useCacheForLists()
Checks the caching preferences to see if the cache should be used for retrieving lists of information.

Returns:
true if the cache should be used for retrieving lists, false otherwise

getOnlineOption

public int getOnlineOption()
Checks the caching preferences to see if the which online caching mode the user has selected.

Returns:
USE_CACHE_NEVER if the cache should never be used for retrieving information. USE_CACHE_LEVELCHECK if the level check of the AS/400 object should be verfied before using the cache. USE_CACHE_ALWAYS if the cache should always be used.

getEscapedDirectoryName

protected static String getEscapedDirectoryName(String name)
Get the escaped directory name for the specified String. This method converts all illegal Windows filename chars to a _xx escaped sequences (where xx is the hex value for the character

Since:
WDScv5.1

getDirectoryName

protected static String getDirectoryName(com.ibm.etools.systems.dstore.core.model.DataElement element)
The following three methods are used to map DataElements to directory names. getDirectoryName, getDataElementName, getDataElementType


getDataElementName

protected static String getDataElementName(String name,
                                           boolean object)
Return the name of the DataElement for the specified cache key segment.

Parameters:
name - The name of the object from the cache key
object - Wether this is an OS/400 object or not
Returns:

getDataElementType

protected static String getDataElementType(String name,
                                           boolean object)
Return the type of the DataElement for the specified cache key segment.

Parameters:
name - The name of the object from the cache key
object - Wether this is an OS/400 object or not
Returns:

save

public void save(com.ibm.etools.systems.dstore.core.model.DataElement node,
                 int dirDepth,
                 int treeDepth,
                 boolean saveRefs)
Save the specified DataElement and it's children to the cache.

Parameters:
node -
dirDepth - The number of subdirectories to use before writing remaining information to a single xml file.
treeDepth - Number of layers in the tree to save to disk. Valid values are 0 and higher. A value of 0 writes just the information for the specified node. A value of 1 writes the information for the specified node and its immediate children, ...
saveRefs - Whether or not to save DataElements which are references to other DataElements

save

public void save(com.ibm.etools.systems.dstore.core.model.DataElement node,
                 int dirDepth,
                 int treeDepth,
                 boolean saveRefs,
                 boolean refresh)
Save the specified DataElement and it's children to the cache.

Parameters:
node -
dirDepth - The number of subdirectories to use before writing remaining information to a single xml file.
treeDepth - Number of layers in the tree to save to disk. Valid values are 0 and higher. A value of 0 writes just the information for the specified node. A value of 1 writes the information for the specified node and its immediate children, ...
saveRefs - Whether or not to save DataElements which are references to other DataElements
refresh - Refresh the cache with what is under element. Any children in the cache that do not exists as children of element will be removed.

load

public com.ibm.etools.systems.dstore.core.model.DataElement load(com.ibm.etools.systems.dstore.core.model.DataElement minerRoot,
                                                                 String cacheKey,
                                                                 int dirDepth,
                                                                 int treeDepth)
Loads the DataElement specified by cacheKey into the DataStore tree along with all of it's children up to treeDepth deep.

Parameters:
minerRoot - The minerRoot for the miner whose data is cached

isCached

public boolean isCached(com.ibm.etools.systems.dstore.core.model.DataElement minerRoot,
                        String cacheKey,
                        int dirDepth)
Checks if the DataElement represented by cacheKey is stored in the cache

Parameters:
minerRoot - The minerRoot for the miner whose data is cached

clearCacheFile

public boolean clearCacheFile(String key)
Clear the specified cache file


clearMemoryCache

protected void clearMemoryCache()
Clear the in-memory cache for this cache manager


removeNode

public void removeNode(com.ibm.etools.systems.dstore.core.model.DataElement minerRoot,
                       String cacheKey,
                       int dirDepth)
Clear the node in the cache with the specified cache key.

Parameters:
cacheKey - The cache key of the node to clear.

iSeries Remote Systems
v6.0.0

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.