|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.uima.util.JCasPool
public class JCasPool
This class represents a simple pool of JCas
instances. This is useful for multithreaded
applications, where there is a need for multiple CASes to be processed simultaneously. Because
JCas creation is expensive, it is a good idea to create a pool of reusable JCas instances at
initialization time, rather than creating a new JCas each time one is needed.
Clients check-out JCas instances from the pool using the getJCas()
method and check-in
JCas instances using the releaseJCas(JCas)
method.
Constructor Summary | |
---|---|
JCasPool(int aNumInstances,
AnalysisEngine aAnalysisEngine)
Creates a new JCasPool |
|
JCasPool(int aNumInstances,
ProcessingResourceMetaData aMetaData)
Creates a new JCasPool |
|
JCasPool(int aNumInstances,
TextAnalysisEngine aTextAnalysisEngine)
Deprecated. As of v2.0, TextAnalysisEngine has been deprecated. Use JCasPool(int, AnalysisEngine) instead. |
Method Summary | |
---|---|
protected void |
fillPool(ProcessingResourceMetaData aMetaData)
Utility method used in the constructor to fill the pool with CAS instances. |
protected Vector<JCas> |
getAllInstances()
|
protected Vector<JCas> |
getFreeInstances()
|
JCas |
getJCas()
Checks out a JCas from the pool. |
JCas |
getJCas(long aTimeout)
Checks out a JCas from the pool. |
int |
getSize()
Gets the size of this pool (the total number of JCas instances that it can hold). |
void |
releaseJCas(JCas aJCas)
Checks in a JCas to the pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Deprecated public JCasPool(int aNumInstances, TextAnalysisEngine aTextAnalysisEngine) throws ResourceInitializationException
JCasPool(int, AnalysisEngine)
instead.
aNumInstances
- the number of JCas instances in the poolaTextAnalysisEngine
- the TAE that will create the JCas instances and which will later be used to process
them
ResourceInitializationException
- if the JCas instances could not be createdpublic JCasPool(int aNumInstances, AnalysisEngine aAnalysisEngine) throws ResourceInitializationException
aNumInstances
- the number of JCas instances in the poolaAnalysisEngine
- the AE that will create the JCas instances and which will later be used to process
them
ResourceInitializationException
- if the JCas instances could not be createdpublic JCasPool(int aNumInstances, ProcessingResourceMetaData aMetaData) throws ResourceInitializationException
aNumInstances
- the number of JCas instances in the poolaMetaData
- metadata that includes the type system for the CAS
ResourceInitializationException
- if the CAS instances could not be createdMethod Detail |
---|
public JCas getJCas()
null
if none are available (in which case the
client may Object.wait()
on this object in order to be notified when an
instance becomes available).public void releaseJCas(JCas aJCas)
JCas.reset()
method, to
ensure that when the JCas is later retrieved from the pool it will be ready to use. Also
notifies other Threads that may be waiting for an instance to become available.
aJCas
- the JCas to releasepublic JCas getJCas(long aTimeout)
aTimeout
- the time to wait in milliseconds. A value of <=0 will wait forever.
null
if none are available within the specified
timeout period.public int getSize()
protected void fillPool(ProcessingResourceMetaData aMetaData) throws ResourceInitializationException
aMetaData
- metadata including the type sytsem for the CASes
ResourceInitializationException
- if the Resource instances could not be createdprotected Vector<JCas> getAllInstances()
protected Vector<JCas> getFreeInstances()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |