Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceInitializationException


      logger.logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize", LOG_RESOURCE_BUNDLE,
              "UIMA_analysis_engine_init_successful__CONFIG", md.getName());
      return true;
    } catch (ResourceConfigurationException e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] {
                  getMetaData().getName(), aSpecifier.getSourceUrlString() });
    }
  }
View Full Code Here


    // instantiate Annotator class
    String annotatorClassName;
    annotatorClassName = mDescription.getImplementationName();

    if (annotatorClassName == null || annotatorClassName.length() == 0) {
      throw new ResourceInitializationException(
              ResourceInitializationException.MISSING_ANNOTATOR_CLASS_NAME,
              new Object[] { mDescription.getSourceUrlString() });
    }

    // load annotator class
    Class<?> annotatorClass = null;
    try {
      // get UIMA extension ClassLoader if available
      ClassLoader cl = getUimaContextAdmin().getResourceManager().getExtensionClassLoader();

      if (cl != null) {
        // use UIMA extension ClassLoader to load the class
        annotatorClass = cl.loadClass(annotatorClassName);
      } else {
        // use application ClassLoader to load the class
        annotatorClass = Class.forName(annotatorClassName);
      }
    } catch (ClassNotFoundException e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.ANNOTATOR_CLASS_NOT_FOUND, new Object[] {
                  annotatorClassName, mDescription.getSourceUrlString() }, e);
    }

    // Make sure the specified class can be adapter to an AnalysisComponent.
    if (!(AnalysisComponent.class.isAssignableFrom(annotatorClass))
            && !AnalysisComponentAdapterFactory.isAdaptable(annotatorClass)) {
      throw new ResourceInitializationException(
              ResourceInitializationException.NOT_AN_ANALYSIS_COMPONENT, new Object[] {
                  annotatorClass.getName(), mDescription.getSourceUrlString() });
    }

    // if we're in verification mode, stop here and do not try to instantiate the
    // analysis component
    if (mVerificationMode) {
      return;
    }

    try {
      Object userObject = annotatorClass.newInstance();
      if (userObject instanceof AnalysisComponent) {
        mAnalysisComponent = (AnalysisComponent) userObject;
      } else {
        mAnalysisComponent = AnalysisComponentAdapterFactory.createAdapter(userObject,
                getAnalysisEngineMetaData(), aAdditionalParams);
      }
    } catch (ResourceInitializationException e) {
      throw e;
    } catch (Exception e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.COULD_NOT_INSTANTIATE_ANNOTATOR, new Object[] {
                  annotatorClassName, mDescription.getSourceUrlString() }, e);
    }

    // Set Logger, to enable annotator-specific logging
    UimaContextAdmin uimaContext = getUimaContextAdmin();
    Logger logger = UIMAFramework.getLogger(annotatorClass);
    logger.setResourceManager(this.getResourceManager());
    uimaContext.setLogger(logger);

    // initialize AnalysisComponent
    try {
      mAnalysisComponent.initialize(getUimaContext());
    } catch (Exception e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.ANNOTATOR_INITIALIZATION_FAILED, new Object[] {
                  annotatorClassName, mDescription.getSourceUrlString() }, e);
    }

    // set up the CAS pool for this AE (this won't do anything if
View Full Code Here

    for (int i = 0; i < mNumInstances; i++) {
      JCas c;
      try {
        c = CasCreationUtils.createCas(mdList).getJCas();
      } catch (CASException e) {
        throw new ResourceInitializationException(e);
      }
      mAllInstances.add(c);
      mFreeInstances.add(c);
    }
  }
View Full Code Here

      try {
        mDescription.getDelegateAnalysisEngineSpecifiers(getResourceManager());
        if (mDescription.getFlowControllerDeclaration() != null) {
          if (mDescription.getFlowControllerDeclaration().getImport() == null
                  && mDescription.getFlowControllerDeclaration().getSpecifier() == null) {
            throw new ResourceInitializationException(
                    ResourceInitializationException.EMPTY_FLOW_CONTROLLER_DECLARATION,
                    new Object[] { getMetaData().getName(), mDescription.getSourceUrl() });
          }

          mDescription.getFlowControllerDeclaration().resolveImports(getResourceManager());
        }
      } catch (InvalidXMLException e) {
        throw new ResourceInitializationException(e);
      }

      // validate the AnalysisEngineDescription and throw a
      // ResourceInitializationException if there is a problem
      mDescription.validate(getResourceManager());

      // Read parameters from the aAdditionalParams map.
      // (First copy it so we can modify it and send the parameters on to
      // out delegate analysis engines.)
      if (aAdditionalParams == null) {
        aAdditionalParams = new HashMap<String, Object>();
      } else {
        aAdditionalParams = new HashMap<String, Object>(aAdditionalParams);
      }

      // put configuration parameter settings into the aAdditionalParams map to be
      // passed on to delegate AEs
      aAdditionalParams.put(Resource.PARAM_CONFIG_PARAM_SETTINGS,
              getCurrentConfigParameterSettings());

      // add resource manager (initialized by superclass) to aAdditionalParams map
      // so that delegate AEs will share it
      aAdditionalParams.put(Resource.PARAM_RESOURCE_MANAGER, getResourceManager());

      initializeAggregateAnalysisEngine(mDescription, aAdditionalParams);

      // Initialize ResultSpec based on output capabilities
      // TODO: should only do this for outermost AE
      resetResultSpecificationToDefault();

      logger.logrb(Level.CONFIG, CLASS_NAME.getName(), "initialize", LOG_RESOURCE_BUNDLE,
              "UIMA_analysis_engine_init_successful__CONFIG", md.getName());
      return true;
    } catch (ResourceConfigurationException e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.ERROR_INITIALIZING_FROM_DESCRIPTOR, new Object[] {
                  getMetaData().getName(), aSpecifier.getSourceUrlString() });
    }
  }
View Full Code Here

    if (flowControllerDecl != null) {
      try {
        aAnalysisEngineDescription.getFlowControllerDeclaration().resolveImports(
                getResourceManager());
      } catch (InvalidXMLException e) {
        throw new ResourceInitializationException(e);
      }
    } else {
      flowControllerDecl = getDefaultFlowControllerDeclaration();
    }
View Full Code Here

        ProcessingResourceMetaData md = metadataIterator.next();
        OperationalProperties componentProps = md.getOperationalProperties();
        if (componentProps != null) {
          if (aggProps.isMultipleDeploymentAllowed()
                  && !componentProps.isMultipleDeploymentAllowed()) {
            throw new ResourceInitializationException(
                    ResourceInitializationException.INVALID_MULTIPLE_DEPLOYMENT_ALLOWED,
                    new Object[] { getAnalysisEngineMetaData().getName(), md.getName(),
                        getAnalysisEngineMetaData().getSourceUrlString() });
          }
          if (!aggProps.getModifiesCas() && componentProps.getModifiesCas()) {
            throw new ResourceInitializationException(
                    ResourceInitializationException.INVALID_MODIFIES_CAS, new Object[] {
                        getAnalysisEngineMetaData().getName(), md.getName(),
                        getAnalysisEngineMetaData().getSourceUrlString() });
          }
          if (componentProps.getOutputsNewCASes()) {
            atLeastOneCasMultiplier = true;
          }
        }
      }
      if (aggProps.getOutputsNewCASes() && !atLeastOneCasMultiplier) {
        throw new ResourceInitializationException(
                ResourceInitializationException.INVALID_OUTPUTS_NEW_CASES, new Object[] {
                    getAnalysisEngineMetaData().getName(),
                    getAnalysisEngineMetaData().getSourceUrlString() });
      }
    }
View Full Code Here

      // resolve deep type system imports
      try {
        mDescription.validate(getResourceManager());
      } catch (ResourceConfigurationException e) {
        throw new ResourceInitializationException(e);
      }

      mergeDelegateAnalysisEngineMetaData();     
    }

    ProcessingResourceMetaData md = (ProcessingResourceMetaData) mDescription.getMetaData();
    // resolve imports for primitives
    if (mDescription instanceof AnalysisEngineDescription  &&
            ((AnalysisEngineDescription)mDescription).isPrimitive()) {
        try {
          md.resolveImports();
        } catch (InvalidXMLException e1) {
        throw new ResourceInitializationException(e1);
      }
       }

    super.initialize(aSpecifier, aAdditionalParams);
View Full Code Here

            modelName);

        mLookupDictionary = new StringDictionary(inModel);
      }
    } catch (IOException e) {
      throw new ResourceInitializationException(
          ExceptionMessages.MESSAGE_CATALOG, "io_error_model_reading",
          new Object[] {});
    }
  }
View Full Code Here

      TokenizerModelResource modelResource = (TokenizerModelResource) context
          .getResourceObject(UimaUtil.MODEL_PARAMETER);

      model = modelResource.getModel();
    } catch (ResourceAccessException e) {
      throw new ResourceInitializationException(e);
    }

    tokenizer = new TokenizerME(model);
  }
View Full Code Here

      ParserModelResource modelResource = (ParserModelResource) context
          .getResourceObject(UimaUtil.MODEL_PARAMETER);

      model = modelResource.getModel();
    } catch (ResourceAccessException e) {
      throw new ResourceInitializationException(e);
    }

    mParser = ParserFactory.create(model);
  }
View Full Code Here

TOP

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

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.