KEY
- VAL
- STATE
- public abstract class CanonicalFactory<KEY,VAL,STATE> extends Object
Constructor and Description |
---|
CanonicalFactory(int queueCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all entries from the cache.
|
Iterator<Map.Entry<KEY,WeakReference<VAL>>> |
entryIterator()
An iterator that visits the entries in the map.
|
VAL |
getInstance(KEY key,
STATE state)
Canonical factory pattern.
|
protected abstract VAL |
newInstance(KEY key,
STATE state)
Create an instance which will be associated with the key in the
CanonicalFactory . |
void |
remove(KEY key)
Remove an entry from the cache.
|
public CanonicalFactory(int queueCapacity)
queueCapacity
- The capacity of the backing hard reference queue. This places
a lower bound on the #of instances which will be retained by
the factory.public VAL getInstance(KEY key, STATE state)
key
- The key.state
- Additional state from the caller which will be passed through
to newInstance(Object, Object)
when creating a new
instance (optional).IllegalArgumentException
- if the key is null
.public void remove(KEY key)
Note: It is sometimes necessary to clear a cache entry. For example, if a persistent resource is destroyed it may be necessary to discard the cache entry to avoid inappropriate carry over via the cache if the resource is then recreated.
key
- The key for the entry.IllegalArgumentException
- if the key is null
.protected abstract VAL newInstance(KEY key, STATE state)
CanonicalFactory
.key
- The key.state
- Additional state used to initialize the new instance
(optional).public void clear()
public Iterator<Map.Entry<KEY,WeakReference<VAL>>> entryIterator()
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.