| java.lang.Object org.netbeans.modules.turbo.Turbo
Turbo | final public class Turbo (Code) | | Turbo is general purpose entries/attributes dictionary with pluggable
layer enabling high scalability disk swaping implementations.
It allows to store several name identified values
for an entity identified by a key.
All methods take a key parameter. It
identifies entity to which attribute values are associated.
It must have properly implemented equals() ,
hashcode() and toString() (returning
unique string) methods. Key lifetime must be well
understood to set cache strategy effeciently:
- MAXIMUM: The implementation monitors key instance lifetime and does
not release data from memory until max. size limit reached or
key instance garbage collected whichever comes sooner. For
unbound caches the key must not be hard referenced from stored
value.
- MINIMUM: For value lookups key's value based equalence is used.
Key's instance lifetime is monitored by instance based equalence.
Reasonable min limit must be set because there can be several
value equalent key instances but only one used key instance
actually stored in cache and lifetime monitored.
Entry name fully indentifies contract between
consumers and providers. Contracts are described elsewhere.
The dictionary does not support storing null
values. Writing null value means that given
entry should be invalidated and removed (it actualy depends
on externally negotiated contract identified by name). Getting
null as requets result means that given value
is not (yet) known or does not exist at all.
author: Petr Kuzel |
Inner Class :static class Environment | |
Method Summary | |
public void | addTurboListener(TurboListener l) | public static synchronized Turbo | createCustom(CustomProviders providers, int min, int max) Creates new instance with customized providers layer. | protected void | finalize() Logs cache statistics data. | protected void | fireEntryChange(Object key, String name, Object value) | public static synchronized Turbo | getDefault() Returns default instance. | public Object | getMonitoredKey(Object key) Gets key instance that it actually used in memory layer. | static synchronized void | initEnvironment(Environment environment) Tests can set different environment. | public boolean | isPrepared(Object key, String name) Checks name instant availability. | public boolean | prepareEntry(Object key, String name) Checks value instant availability and possibly schedules its background
loading. | public Object | readEntry(Object key, String name) Reads given attribute for given entity key. | public void | removeTurboListener(TurboListener l) | int | storeEntry(Object key, String name, Object value) Stores directly to providers. | public String | toString() For debugging purposes only. | public boolean | writeEntry(Object key, String name, Object value) Writes given attribute, value pair and notifies all listeners.
Written value is stored both into memory and providers layer.
The call speed depends on actually used provider. |
createCustom | public static synchronized Turbo createCustom(CustomProviders providers, int min, int max)(Code) | | Creates new instance with customized providers layer.
Parameters: providers - never null Parameters: min - minimum number of entries held by the cache Parameters: max - maximum size or -1 for unbound size(defined just by key instance lifetime) |
finalize | protected void finalize() throws Throwable(Code) | | Logs cache statistics data.
|
getDefault | public static synchronized Turbo getDefault()(Code) | | Returns default instance. It's size is driven by
keys lifetime. It shrinks on keys become unreferenced
and grows without bounds on inserting keys.
|
getMonitoredKey | public Object getMonitoredKey(Object key)(Code) | | Gets key instance that it actually used in memory layer.
Client should keep reference to it if it wants to use
key lifetime monitoring cache size strategy.
Parameters: key - key never null key instance that is value-equalent or null if monitored instance does not exist. |
initEnvironment | static synchronized void initEnvironment(Environment environment)(Code) | | Tests can set different environment. Must be called before
Turbo.getDefault .
|
isPrepared | public boolean isPrepared(Object key, String name)(Code) | | Checks name instant availability. Note that actual
value may be still null , in case
that it's known that value does not exist.
|
prepareEntry | public boolean prepareEntry(Object key, String name)(Code) | | Checks value instant availability and possibly schedules its background
loading. It's designed to be called from UI tread.
|
readEntry | public Object readEntry(Object key, String name)(Code) | | Reads given attribute for given entity key.
Parameters: key - a entity key, never null Parameters: name - identifies requested entry, never null entry value or null if it does not exist or unknown. |
storeEntry | int storeEntry(Object key, String name, Object value)(Code) | | Stores directly to providers.
0 success, -1 contract failure, 1 other failure |
toString | public String toString()(Code) | | For debugging purposes only.
|
writeEntry | public boolean writeEntry(Object key, String name, Object value)(Code) | | Writes given attribute, value pair and notifies all listeners.
Written value is stored both into memory and providers layer.
The call speed depends on actually used provider. However do not
rely on synchronous provider call. In future it may return and
fire immediately on writing into memory layer, populating providers
asychronously on background.
A client calling this method is reponsible for passing
valid value that is accepted by attribute serving providers.
Parameters: key - identifies target, never null Parameters: name - identifies attribute, never null Parameters: value - actual attribute value to be stored, null behaviouris defined specificaly for each name. It always invalidates memory entryand it either invalidates or removes value from providers layer(mening: value unknown versus value is known to not exist). Client should consider a size of stored value. It must be corelatedwith Turbo memory layer limits to avoid running ouf of memory. |
|
|