Knopflerfish OSGi 5.2.0

org.knopflerfish.util
Class CachedObject<V>

java.lang.Object
  extended by org.knopflerfish.util.CachedObject<V>

public class CachedObject<V>
extends java.lang.Object

An object with a timeout.

A CachedObject has a timeout period - during that period the get method will return the stored object, afterwards get will return null

See Also:
CacheMap

Field Summary
static long DEFAULT_TIMEOUT
          Default timeout period in milliseconds.
 
Constructor Summary
CachedObject()
          Equivalent to CachedObject(null).
CachedObject(V object)
          Equivalent to CachedObject(object, CachedObject.DEFAULT_TIMEOUT)
CachedObject(V object, long timeout)
          Create a cached object from an object and a specified timeout.
 
Method Summary
 void flush()
          Clear the stored object.
 V get()
          Get the cached object.
 void set(V object)
          Set the cache's object and restore its creation time.
 java.lang.String toString()
          Print the cached object as "<object's string value>:<remaining time in milliseconds>"
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TIMEOUT

public static final long DEFAULT_TIMEOUT
Default timeout period in milliseconds. Value is 60 seconds.

See Also:
Constant Field Values
Constructor Detail

CachedObject

public CachedObject()
Equivalent to CachedObject(null).

See Also:
CacheMap

CachedObject

public CachedObject(V object)
Equivalent to CachedObject(object, CachedObject.DEFAULT_TIMEOUT)

See Also:
DEFAULT_TIMEOUT

CachedObject

public CachedObject(V object,
                    long timeout)
Create a cached object from an object and a specified timeout.

Parameters:
object - Object to cache
timeout - period in milliseconds.
See Also:
DEFAULT_TIMEOUT
Method Detail

set

public void set(V object)
Set the cache's object and restore its creation time.

Parameters:
object - Object to cache

get

public V get()
Get the cached object.

Returns:
The cached object before its timeout period, null afterwards.

flush

public void flush()
Clear the stored object. After this call, get will


toString

public java.lang.String toString()
Print the cached object as "<object's string value>:<remaining time in milliseconds>"

Overrides:
toString in class java.lang.Object

Knopflerfish OSGi 5.2.0