public abstract class

SnmpTableCache

extends Object
implements Serializable
java.lang.Object
   ↳ sun.management.snmp.util.SnmpTableCache
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

This abstract class implements a weak cache that holds table data.

The table data is stored in an instance of SnmpCachedData, which is kept in a WeakReference. If the WeakReference is null or empty, the cached data is recomputed.

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

Summary

Fields
protected WeakReference<SnmpCachedData> datas A weak refernce holding cached table data.
protected long validity Interval of time in ms during which the cached table data is considered valid.
Public Constructors
SnmpTableCache()
Public Methods
abstract SnmpTableHandler getTableHandler()
Return a table handler that holds the table data.
Protected Methods
SnmpCachedData getCachedDatas()
Returns the cached table data.
synchronized SnmpCachedData getTableDatas(Object context)
Returns the cached table data, if it is still valid, or recompute it if it is obsolete.
boolean isObsolete(SnmpCachedData cached)
true if the given cached table data is obsolete.
abstract SnmpCachedData updateCachedDatas(Object context)
Recompute cached data.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected WeakReference<SnmpCachedData> datas

A weak refernce holding cached table data.

protected long validity

Interval of time in ms during which the cached table data is considered valid.

Public Constructors

public SnmpTableCache ()

Public Methods

public abstract SnmpTableHandler getTableHandler ()

Return a table handler that holds the table data. This method should return the cached table data if it is still valid, recompute it and cache the new value if it's not.

Protected Methods

protected SnmpCachedData getCachedDatas ()

Returns the cached table data. Returns null if the cached data is obsolete, or if there is no cached data, or if the cached data was garbage collected.

Returns
  • a still valid cached data or null.

protected synchronized SnmpCachedData getTableDatas (Object context)

Returns the cached table data, if it is still valid, or recompute it if it is obsolete.

When cache data is recomputed, store it in the weak reference, unless validity is 0: then the data will not be stored at all.
This method calls isObsolete(SnmpCachedData) to determine whether the cached data is obsolete, and { updateCachedDatas(Object) to recompute it.

Parameters
context A context object.
Returns
  • the valid cached data, or the recomputed table data.

protected boolean isObsolete (SnmpCachedData cached)

true if the given cached table data is obsolete.

protected abstract SnmpCachedData updateCachedDatas (Object context)

Recompute cached data.

Parameters
context A context object, as passed to getTableDatas(Object)