org.apache.uima.collection.impl.cpm.container
Class CPEFactory

java.lang.Object
  extended by org.apache.uima.collection.impl.cpm.container.CPEFactory

public class CPEFactory
extends java.lang.Object

Component responsible for generating objects representing cpe descriptor configuration. Provides various ways to instantiate object model representing cpe configuration. In the simplest form it ingests an xml file (cpe descriptor), parses it and creates an object for every element in the xml file.

Using objects representing configuration, this component creates CollectionReader CasInitializer, Analysis Engines, and Cas Consumers.

In addition to creating object, this component provides read/write access to the object model allowing for dynamic or programmatic modifications. It facilitates plugging in existing CollectionReaders and CasProcessors.


Field Summary
 java.util.HashMap casProcessorConfigMap
           
static java.lang.String CPM_HOME
           
 
Constructor Summary
CPEFactory(CpeDescription aDescriptor, ResourceManager aResourceManager)
          Create a new CPEFactory for a CpeDescription that's already been parsed.
CPEFactory(ResourceManager aResourceManager)
          Create a new CPEFactory on which we will later call parse(String) to parse a CPE descriptor.
 
Method Summary
 void addCasProcessor(CasProcessor aCasProcessor)
          Appends given Cas Processor to the list of CasProcessors
 void addCollectionReader(BaseCollectionReader collectionReader)
           
 CasProcessor[] getCasProcessors()
          Returns an array of Cas Processors instantiated from the cpe descriptor
 BaseCollectionReader getCollectionReader()
          Returns Collection Reader instantiated from configuration in the cpe descriptor.
 CpeConfiguration getCPEConfig()
          Returns an object containing global CPE configuration including: Number of documents to process Checkpoint configuration id of the document begin processing
 CpeDescription getCpeDescriptor()
          Returns Cpe Descriptor
 java.lang.String getDescriptor(java.util.List aList)
           
 java.net.URL getDescriptorURL(CpeCasProcessor aCasProcessorCfg)
          Returns a descriptor path associated with Cas Processor
 int getProcessingUnitThreadCount()
          Returns number of processing threads (Processing Units)
 ResourceManager getResourceManager()
          Gets the ResourceManager that all components of this CPE should share.
 ResourceSpecifier getSpecifier(java.net.URL aDescriptorUrl)
          Instantiates a ResourceSpecifier from a given URL.
 boolean isDefault()
           
 boolean isDefinitionInstanceOf(java.lang.Class aResourceClass, ResourceSpecifier resourceSpecifier, java.lang.String aDescriptor)
          Check if a class has appropriate type
 void parse()
          Creates an object representation from default cpe descriptor.
 void parse(java.io.InputStream aDescriptorStream)
          Creates an object representation for configuration in a given stream
 void parse(java.lang.String aDescriptor)
          Creates an object representation for configuration in a given cpe descriptor file.
 CasProcessor produceCasDataConsumer(java.lang.Class aResourceClass, ResourceSpecifier aSpecifier, java.util.Map aAdditionalParams)
          Instantiates CasData Consumer from a given class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CPM_HOME

public static final java.lang.String CPM_HOME
See Also:
Constant Field Values

casProcessorConfigMap

public java.util.HashMap casProcessorConfigMap
Constructor Detail

CPEFactory

public CPEFactory(ResourceManager aResourceManager)
Create a new CPEFactory on which we will later call parse(String) to parse a CPE descriptor.


CPEFactory

public CPEFactory(CpeDescription aDescriptor,
                  ResourceManager aResourceManager)
           throws ResourceInitializationException
Create a new CPEFactory for a CpeDescription that's already been parsed.

Parameters:
aDescriptor -
aResourceManager - the resource manager that all components of this CPE will share If null, a new ResourceManager will be created.
Throws:
ResourceInitializationException
Method Detail

parse

public void parse(java.lang.String aDescriptor)
           throws java.lang.InstantiationException
Creates an object representation for configuration in a given cpe descriptor file.

Parameters:
aDescriptor - - path to the descriptor
Throws:
java.lang.InstantiationException

parse

public void parse(java.io.InputStream aDescriptorStream)
           throws java.lang.InstantiationException
Creates an object representation for configuration in a given stream

Parameters:
aDescriptorStream - - stream containing cpe description
Throws:
java.lang.InstantiationException

parse

public void parse()
Creates an object representation from default cpe descriptor.

Parameters:
aDescriptorStream - - stream containing cpe description
Throws:
java.lang.InstantiationException

getCollectionReader

public BaseCollectionReader getCollectionReader()
                                         throws ResourceConfigurationException
Returns Collection Reader instantiated from configuration in the cpe descriptor. It also creates and intializes the Cas Initializer if one is defined and associates it with the CollectionReader.

Returns:
- CollectionReader instance
Throws:
javax.naming.ConfigurationException
ResourceConfigurationException

getCasProcessors

public CasProcessor[] getCasProcessors()
                                throws ResourceConfigurationException
Returns an array of Cas Processors instantiated from the cpe descriptor

Returns:
- array of CasProcessor instances
Throws:
ResourceConfigurationException

isDefinitionInstanceOf

public boolean isDefinitionInstanceOf(java.lang.Class aResourceClass,
                                      ResourceSpecifier resourceSpecifier,
                                      java.lang.String aDescriptor)
                               throws ResourceConfigurationException
Check if a class has appropriate type

Parameters:
aResourceClass - - class to check
resourceSpecifier - - specifier containing expected type
aDescriptor - - descriptor name
Returns:
true - if class matches type
Throws:
ResourceConfigurationException

produceCasDataConsumer

public CasProcessor produceCasDataConsumer(java.lang.Class aResourceClass,
                                           ResourceSpecifier aSpecifier,
                                           java.util.Map aAdditionalParams)
                                    throws ResourceInitializationException
Instantiates CasData Consumer from a given class.

Parameters:
aResourceClass - - CasDataConsumer class
aSpecifier - - specifier
aAdditionalParams - - parameters used to initialize CasDataConsumer
Returns:
- instance of CasProcessor
Throws:
ResourceInitializationException

getDescriptorURL

public java.net.URL getDescriptorURL(CpeCasProcessor aCasProcessorCfg)
                              throws ResourceConfigurationException
Returns a descriptor path associated with Cas Processor

Parameters:
aCasProcessorCfg - - Cas Processor configuration
Returns:
- Descriptor path
Throws:
ResourceConfigurationException

getSpecifier

public ResourceSpecifier getSpecifier(java.net.URL aDescriptorUrl)
                               throws java.lang.Exception
Instantiates a ResourceSpecifier from a given URL.

Parameters:
aDescriptorURL - - URL of descriptor
Returns:
- ResourceSpecifier
Throws:
java.lang.Exception

getCPEConfig

public CpeConfiguration getCPEConfig()
                              throws java.lang.InstantiationException
Returns an object containing global CPE configuration including:
  • Number of documents to process
  • Checkpoint configuration
  • id of the document begin processing
  • Returns:
    - Global CPE Configuration
    Throws:
    java.lang.InstantiationException

    getProcessingUnitThreadCount

    public int getProcessingUnitThreadCount()
                                     throws ResourceConfigurationException
    Returns number of processing threads (Processing Units)

    Returns:
    Number of processing threads
    Throws:
    ResourceConfigurationException

    isDefault

    public boolean isDefault()
    Returns:

    getCpeDescriptor

    public CpeDescription getCpeDescriptor()
    Returns Cpe Descriptor

    Returns:

    addCasProcessor

    public void addCasProcessor(CasProcessor aCasProcessor)
                         throws ResourceConfigurationException
    Appends given Cas Processor to the list of CasProcessors

    Parameters:
    aCasProcessor - - CasProcessor to add
    Throws:
    ResourceConfigurationException

    getDescriptor

    public java.lang.String getDescriptor(java.util.List aList)
                                   throws ResourceConfigurationException
    Parameters:
    aList -
    Returns:
    Throws:
    ResourceConfigurationException

    addCollectionReader

    public void addCollectionReader(BaseCollectionReader collectionReader)
    Parameters:
    collectionReader - - collection reader to use by the CPM

    getResourceManager

    public ResourceManager getResourceManager()
    Gets the ResourceManager that all components of this CPE should share.

    Returns:


    Copyright © 2010 The Apache Software Foundation. All Rights Reserved.