public abstract class

SnmpNamedListTableCache

extends SnmpListTableCache
java.lang.Object
   ↳ sun.management.snmp.util.SnmpTableCache
     ↳ sun.management.snmp.util.SnmpListTableCache
       ↳ sun.management.snmp.util.SnmpNamedListTableCache

Class Overview

This abstract class implements a weak cache that holds table data, for a table whose data is obtained from a list where a name can be obtained for each item in the list.

This object maintains a map between an entry name and its associated SnmpOid index, so that a given entry is always associated to the same index.

NOTE: This class is not synchronized, subclasses must implement the appropriate synchronization whwn needed.

Summary

Fields
protected long last The last allocate index.
protected TreeMap names This map associate an entry name with the SnmpOid index that's been allocated for it.
[Expand]
Inherited Fields
From class sun.management.snmp.util.SnmpTableCache
Public Constructors
SnmpNamedListTableCache()
Protected Methods
SnmpOid getIndex(Object context, List rawDatas, int rank, Object item)
Call getKey(Object, List, int, Object) in order to get the item name.
abstract String getKey(Object context, List rawDatas, int rank, Object item)
Returns the key to use as name for the given item.
List getRawDatas(Map<ObjectObject> userData, String key)
Get a list of raw data from which to build the cached data.
abstract String getRawDatasKey()
The name under which the raw data is to be found/put in the request contextual cache.
abstract List loadRawDatas(Map userData)
Load a list of raw data from which to build the cached data.
SnmpOid makeIndex(Object context, List rawDatas, int rank, Object item)
Find a new index for the entry corresponding to the given item.
SnmpCachedData updateCachedDatas(Object context)
Update cahed datas.
SnmpCachedData updateCachedDatas(Object context, List rawDatas)
Allocate a new TreeMap to serve as context, then call updateCachedDatas(Object, List), and finally replace the names TreeMap by the new allocated TreeMap.
[Expand]
Inherited Methods
From class sun.management.snmp.util.SnmpListTableCache
From class sun.management.snmp.util.SnmpTableCache
From class java.lang.Object

Fields

protected long last

The last allocate index.

protected TreeMap names

This map associate an entry name with the SnmpOid index that's been allocated for it.

Public Constructors

public SnmpNamedListTableCache ()

Protected Methods

protected SnmpOid getIndex (Object context, List rawDatas, int rank, Object item)

Call getKey(Object, List, int, Object) in order to get the item name. Then check whether an index was already allocated for the entry by that name. If yes return it. Otherwise, call makeIndex(Object, List, int, Object) to compute a new index for that entry. Finally store the association between the name and index in the context TreeMap.

Parameters
context The context passed to updateCachedDatas(Object, List). It is expected to be an instance of TreeMap.
rawDatas Raw table datas passed to updateCachedDatas(Object, List).
rank Rank of the given item in the rawDatas list iterator.
item The raw data object for which an index must be determined.

protected abstract String getKey (Object context, List rawDatas, int rank, Object item)

Returns the key to use as name for the given item.
This method is called by getIndex(Object, List, int, Object). The given item is expected to be always associated with the same name.

Parameters
context The context passed to updateCachedDatas(Object, List).
rawDatas Raw table datas passed to updateCachedDatas(Object, List).
rank Rank of the given item in the rawDatas list iterator.
item The raw data object for which a key name must be determined.

protected List getRawDatas (Map<ObjectObject> userData, String key)

Get a list of raw data from which to build the cached data. Obtains a list of raw data by first looking it up in the request contextual cache userData under the given key. If nothing is found in the cache, calls loadRawDatas(Map) to obtain a new rawData list, and cache the result in userData under key.

Parameters
userData The request contextual cache allocated by the JvmContextFactory.
key The name under which the raw data is to be found/put in the request contextual cache.

protected abstract String getRawDatasKey ()

The name under which the raw data is to be found/put in the request contextual cache.

protected abstract List loadRawDatas (Map userData)

Load a list of raw data from which to build the cached data. This method is called when nothing is found in the request contextual cache.

Parameters
userData The request contextual cache allocated by the JvmContextFactory.

protected SnmpOid makeIndex (Object context, List rawDatas, int rank, Object item)

Find a new index for the entry corresponding to the given item.
This method is called by getIndex(Object, List, int, Object) when a new index needs to be allocated for an item. The index returned must not be already in used.

Parameters
context The context passed to updateCachedDatas(Object, List).
rawDatas Raw table datas passed to updateCachedDatas(Object, List).
rank Rank of the given item in the rawDatas list iterator.
item The raw data object for which an index must be determined.

protected SnmpCachedData updateCachedDatas (Object context)

Update cahed datas. Obtains a List of raw datas by calling getRawDatas((Map)context,getRawDatasKey()).
Then allocate a new TreeMap to serve as temporary map between names and indexes, and call updateCachedDatas(Object, List) with that temporary map as context.
Finally replaces the names TreeMap by the temporary TreeMap.

Parameters
context The request contextual cache allocated by the JvmContextFactory.

protected SnmpCachedData updateCachedDatas (Object context, List rawDatas)

Allocate a new TreeMap to serve as context, then call updateCachedDatas(Object, List), and finally replace the names TreeMap by the new allocated TreeMap.

Parameters
context A context object, valid during the duration of of the call to this method, and that will be passed to getIndex(Object, List, int, Object) and getData(Object, List, int, Object).
This method is intended to be called by updateCachedDatas(Object). It is assumed that the context is be allocated by before this method is called, and released just after this method has returned.
This class does not use the context object: it is a simple hook for subclassed.
rawDatas The table datas from which the cached data will be computed.
Returns
  • the computed cached data.