Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceCreationSpecifier


      if (!(aSpecifier instanceof FlowControllerDescription)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.NOT_A_FLOW_CONTROLLER_DESCRIPTOR, new Object[] {
                    aSpecifier.getSourceUrlString(), aSpecifier.getClass().getName() });
      }
      ResourceCreationSpecifier desc = (ResourceCreationSpecifier) aSpecifier;

      // also framework implementation must start with org.apache.uima.java
      final String fwImpl = desc.getFrameworkImplementation();
      if (fwImpl == null
              || !fwImpl.equalsIgnoreCase(Constants.JAVA_FRAMEWORK_NAME)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION, new Object[] {
                    fwImpl, aSpecifier.getSourceUrlString() });
      }

      super.initialize(aSpecifier, aAdditionalParams);

      // validate the descriptor
      desc.validate(getResourceManager());

      // instantiate FlowController
      mFlowController = instantiateFlowController(desc);

      // record metadata
      setMetaData(desc.getMetaData());

      // add our metadata to the CasManager, so that it will pick up our
      // type system, priorities, and indexes
      getCasManager().addMetaData(getProcessingResourceMetaData());
View Full Code Here


*/
public class ResourceCreationSpecifier_implTest extends TestCase {
  public void testDoFullValidation() throws Exception {
    try {
      File descFile = JUnitExtension.getFile("UimaContextTest/CasConsumerForUimaContextTest.xml");
      ResourceCreationSpecifier resCreaSpec = (ResourceCreationSpecifier) UIMAFramework
              .getXMLParser().parseResourceSpecifier(new XMLInputSource(descFile));
      resCreaSpec.doFullValidation();
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

            && aResourceClass.isAssignableFrom(TextAnalysisEngine.class))
    // NOTE: for backwards-compatibility, we have to check TextAnalysisEngine,
    // not AnalysisEngine. Otherwise produceTAE would fail becasue
    // TextAnalysisEngien.class.isAssignableFrom(AnalysisEngine.class) is false.
    {
      ResourceCreationSpecifier spec = (ResourceCreationSpecifier) aSpecifier;
      if (multiprocessing) {
        resource = new MultiprocessingAnalysisEngine_impl();
      } else {

        String frameworkImpl = spec.getFrameworkImplementation();
        if (frameworkImpl == null || frameworkImpl.length() == 0) {
          throw new ResourceInitializationException(
                  ResourceInitializationException.MISSING_FRAMEWORK_IMPLEMENTATION,
                  new Object[] { aSpecifier.getSourceUrlString() });
        }

        if (frameworkImpl.startsWith(Constants.CPP_FRAMEWORK_NAME)) {
          resource = new UimacppAnalysisEngineImpl();
        } else if (frameworkImpl.startsWith(Constants.JAVA_FRAMEWORK_NAME)) {
          if (spec instanceof AnalysisEngineDescription
                  && !((AnalysisEngineDescription) spec).isPrimitive()) {
            resource = new AggregateAnalysisEngine_impl();
          } else {
            resource = new PrimitiveAnalysisEngine_impl();
          }
        } else {
          throw new ResourceInitializationException(
                  ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION,
                  new Object[] { spec.getFrameworkImplementation(), aSpecifier.getSourceUrlString() });
        }
      }
    }

    if (resource != null && resource.initialize(aSpecifier, aAdditionalParams)) {
View Full Code Here

      if (!(aSpecifier instanceof FlowControllerDescription)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.NOT_A_FLOW_CONTROLLER_DESCRIPTOR, new Object[] {
                    aSpecifier.getSourceUrlString(), aSpecifier.getClass().getName() });
      }
      ResourceCreationSpecifier desc = (ResourceCreationSpecifier) aSpecifier;

      // also framework implementation must start with org.apache.uima.java
      final String fwImpl = desc.getFrameworkImplementation();
      if (fwImpl == null
              || !fwImpl.equalsIgnoreCase(Constants.JAVA_FRAMEWORK_NAME)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION, new Object[] {
                    fwImpl, aSpecifier.getSourceUrlString() });
      }

      super.initialize(aSpecifier, aAdditionalParams);

      // validate the descriptor
      desc.validate(getResourceManager());

      // instantiate FlowController
      mFlowController = instantiateFlowController(desc);

      // record metadata
      setMetaData(desc.getMetaData());

      // add our metadata to the CasManager, so that it will pick up our
      // type system, priorities, and indexes
      getCasManager().addMetaData(getProcessingResourceMetaData());
View Full Code Here

   */
  public static ResourceCreationSpecifier createResourceCreationSpecifier(XMLInputSource xmlInput,
          Object[] parameters) throws InvalidXMLException {
    ConfigurationParameterFactory.ensureParametersComeInPairs(parameters);

    ResourceCreationSpecifier specifier;
    XMLParser parser = UIMAFramework.getXMLParser();
    specifier = (ResourceCreationSpecifier) parser.parseResourceSpecifier(xmlInput);
    setConfigurationParameters(specifier, parameters);

    return specifier;
View Full Code Here

        // Do not generate descriptors for abstract classes, they cannot be instantiated.
        if (Modifier.isAbstract(clazz.getModifiers())) {
          continue;
        }
       
        ResourceCreationSpecifier desc = null;
        switch (Util.getType(componentLoader, clazz)) {
          case ANALYSIS_ENGINE:
            desc = AnalysisEngineFactory.createEngineDescription(clazz);
            break;
          case COLLECTION_READER:
View Full Code Here

   *          value) pairs, so there should always be an even number of parameters.
   * @return The CollectionReader created from the XML descriptor and the configuration parameters.
   */
  public static CollectionReaderDescription createReaderDescriptionFromPath(String descriptorPath,
          Object... configurationData) throws UIMAException, IOException {
    ResourceCreationSpecifier specifier = createResourceCreationSpecifier(descriptorPath,
            configurationData);
    return (CollectionReaderDescription) specifier;
  }
View Full Code Here

public class ResourceCreationSpecifier_implTest extends TestCase {
  public void testDoFullValidation() throws Exception {
    try {
      File descFile = JUnitExtension.getFile("UimaContextTest/CasConsumerForUimaContextTest.xml");
      ResourceCreationSpecifier resCreaSpec = (ResourceCreationSpecifier) UIMAFramework
              .getXMLParser().parseResourceSpecifier(new XMLInputSource(descFile));
      resCreaSpec.doFullValidation();
    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
View Full Code Here

      if (!(aSpecifier instanceof FlowControllerDescription)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.NOT_A_FLOW_CONTROLLER_DESCRIPTOR, new Object[] {
                    aSpecifier.getSourceUrlString(), aSpecifier.getClass().getName() });
      }
      ResourceCreationSpecifier desc = (ResourceCreationSpecifier) aSpecifier;

      // also framework implementation must start with org.apache.uima.java
      final String fwImpl = desc.getFrameworkImplementation();
      if (fwImpl == null
              || !fwImpl.equalsIgnoreCase(Constants.JAVA_FRAMEWORK_NAME)) {
        throw new ResourceInitializationException(
                ResourceInitializationException.UNSUPPORTED_FRAMEWORK_IMPLEMENTATION, new Object[] {
                    fwImpl, aSpecifier.getSourceUrlString() });
      }

      super.initialize(aSpecifier, aAdditionalParams);

      // validate the descriptor
      desc.validate(getResourceManager());

      // instantiate FlowController
      mFlowController = instantiateFlowController(desc);

      // record metadata
      setMetaData(desc.getMetaData());

      // add our metadata to the CasManager, so that it will pick up our
      // type system, priorities, and indexes
      getCasManager().addMetaData(getProcessingResourceMetaData());
View Full Code Here

      mh.error(e);
      throw e;
    }
    ResourceSpecifier crrs = xmlParser.parseCollectionReaderDescription(in);
    // CR overrides - throw up if trying to override an undefined parameter
        ResourceCreationSpecifier specifier = (ResourceCreationSpecifier) crrs;
        ConfigurationParameterDeclarations configurationParameterDeclarations = specifier.getMetaData().getConfigurationParameterDeclarations();
        ConfigurationParameterSettings cps = specifier.getMetaData().getConfigurationParameterSettings();
        if(crOverrides != null) {
            // Tokenize override assignments on whitespace, honoring but stripping quotes
            // Then create a map from all of them
            ArrayList<String> toks = QuotedOptions.tokenizeList(crOverrides, true);
            Map<String,String> map = QuotedOptions.parseAssignments(toks, false);
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.ResourceCreationSpecifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.