|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.quattor.pan.cache.AbstractCache<T>
public abstract class AbstractCache<T extends TaskResult>
A cache that maps a key, typically an object or template name, to an associated task. The task is one that compiles, builds, or validates the named entity. Any attempt to retrieve something from the cache will return with the associated task, creating a new task if one doesn't already exist. The client can wait on the task for the entity to become available.
| Field Summary | |
|---|---|
protected Compiler |
compiler
Reference to the compiler associated with this cache. |
| Constructor Summary | |
|---|---|
protected |
AbstractCache(Compiler compiler,
int size)
Initializes the internal reference to the associated Compiler and creates a cache with the given initial size. |
| Method Summary | |
|---|---|
protected abstract Task<T> |
createTask(java.lang.String key)
Creates a new task to be put into the cache, if necessary. |
protected abstract TaskResult.ResultType |
getExecutorQueueType()
Subclasses must return the executor queue type for the particular class. |
java.util.concurrent.Future<T> |
retrieve(java.lang.String key)
Returns directly the Future associated with the key or null
if an entry does not exist. |
java.util.concurrent.Future<T> |
retrieve(java.lang.String key,
boolean executeInline)
Returns a Future corresponding to the named object template;
this will add a new entry if one does not yet exist for the given key. |
T |
waitForResult(java.lang.String key)
A convenience method that will retrieve (or create) the task associated with the key, wait for a result to be ready, and process any thrown exceptions. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final Compiler compiler
| Constructor Detail |
|---|
protected AbstractCache(Compiler compiler,
int size)
Compiler and creates a cache with the given initial size.
compiler - Compiler related to this cachesize - number of initial entries| Method Detail |
|---|
public java.util.concurrent.Future<T> retrieve(java.lang.String key,
boolean executeInline)
Future corresponding to the named object template;
this will add a new entry if one does not yet exist for the given key.
key - key to use for the lookup, typically an object or template
nameexecuteInline - If the client is going to wait for the task to complete, then
it can indicate that the task can be run inline.
Future that references the compiled template
public T waitForResult(java.lang.String key)
throws java.lang.RuntimeException,
ValidationException
key - Key for the associated task, usually an object or template
name
java.lang.RuntimeException
ValidationExceptionpublic java.util.concurrent.Future<T> retrieve(java.lang.String key)
Future associated with the key or null
if an entry does not exist. This method will not create a task for a
non-existent entry. This method is primarily used for testing.
key - Key to use for the entity lookup.
Future for the named template or null if it is not
in the cacheprotected abstract Task<T> createTask(java.lang.String key)
key - Key used to generate the associated task.
protected abstract TaskResult.ResultType getExecutorQueueType()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||