public class AnnotatorPool
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static AnnotatorPool |
SINGLETON
A global singleton annotator pool, so that we can cache globally on a JVM instance.
|
Constructor and Description |
---|
AnnotatorPool()
Create an empty AnnotatorPool.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear this pool, and unmount all the annotators mounted on it.
|
Annotator |
get(java.lang.String name)
Retrieve an Annotator from the pool.
|
boolean |
register(java.lang.String name,
java.util.Properties props,
Lazy<Annotator> annotator)
Register an Annotator that can be created by the pool.
|
public static final AnnotatorPool SINGLETON
public boolean register(java.lang.String name, java.util.Properties props, Lazy<Annotator> annotator)
name
- The name to be associated with the Annotator.props
- The properties we are using to create the annotatorannotator
- A factory that creates an instance of the desired Annotator.
This should be an instance of Lazy.cache(Supplier)
, if we want
the annotator pool to behave as a cache (i.e., evict old annotators
when the GC requires it).public void clear()
public Annotator get(java.lang.String name)
name
- The annotator to retrieve from the pooljava.lang.IllegalArgumentException
- If the annotator cannot be created