Knopflerfish OSGi 3.0.0

org.knopflerfish.util
Class CachedObject

java.lang.Object
  extended by org.knopflerfish.util.CachedObject

public class CachedObject
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(java.lang.Object object)
          Equivalent to CachedObject(object, CachedObject.DEFAULT_TIMEOUT)
CachedObject(java.lang.Object object, long timeout)
          Create a cached object from an object and a specified timeout.
 
Method Summary
 void flush()
          Clear the stored object.
 java.lang.Object get()
          Get the cached object.
 void set(java.lang.Object 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(java.lang.Object object)
Equivalent to CachedObject(object, CachedObject.DEFAULT_TIMEOUT)

See Also:
DEFAULT_TIMEOUT

CachedObject

public CachedObject(java.lang.Object 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(java.lang.Object object)
Set the cache's object and restore its creation time.

Parameters:
object - Object to cache

get

public java.lang.Object 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 3.0.0