Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceInitializationException


      // we do this to keep resolvedDelegates update-able
      // The value from getDeletageAESpecs is an unmodifiable hash map
      resolvedDelegates.putAll(aeDescription
              .getDelegateAnalysisEngineSpecifiers(createResourceManager()));
    } catch (InvalidXMLException e) {
      throw new ResourceInitializationException(e);
    }
    // These come before setTypeSystemDescription call because that call
    // invokeds tcas validate, which uses the merged values for speedup
    // Here we set them to values that won't cause errors. They're set to actual values below.
    mergedFsIndexCollection = aeDescription.getAnalysisEngineMetaData().getFsIndexCollection();
    mergedTypePriorities = aeDescription.getAnalysisEngineMetaData().getTypePriorities();
    resolvedExternalResourcesAndBindings = aeDescription.getResourceManagerConfiguration();
    resolvedFlowControllerDeclaration = aeDescription.getFlowControllerDeclaration();

    setTypeSystemDescription(aeDescription.isPrimitive() ? aeDescription
            .getAnalysisEngineMetaData().getTypeSystem() : null); // aggregates have null
    // tsd. If passed in one
    // isn't null, make it
    // null.

    // These come after setTypeSystemDescription call, even though
    // that call invokeds tcas validate, which uses the merged values for speedup
    // Therefore, merged values have to be set to proper ideas first.
    setMergedFsIndexCollection();
    setImportedFsIndexCollection();
    setMergedTypePriorities();
    setImportedTypePriorities();
    try {
      setResolvedExternalResourcesAndBindings();
      // setImportedExternalResourcesAndBindings();
    } catch (InvalidXMLException e1) {
      throw new ResourceInitializationException(e1);
    }
    try {
      setResolvedFlowControllerDeclaration();
    } catch (InvalidXMLException e1) {
      throw new ResourceInitializationException(e1);
    }
  }
View Full Code Here


    aeDescription.setResourceManagerConfiguration(rb);
    try {
      setResolvedExternalResourcesAndBindings();
      // setImportedExternalResourcesAndBindings();
    } catch (InvalidXMLException e) {
      throw new ResourceInitializationException(e);
    }
    descriptorCAS.validate();
  }
View Full Code Here

    }
  }

  private void validateDescriptorType(int newDescriptorType) throws ResourceInitializationException {
    if (0 != descriptorType && !openingContext && ((descriptorType & newDescriptorType) == 0))
      throw new ResourceInitializationException(Messages.getString("MultiPageEditor.12"), //$NON-NLS-1$
              Messages.getString("MultiPageEditor.13"), //$NON-NLS-1$
              new String[] { descriptorTypeString(), descriptorTypeString(newDescriptorType) });
    if (!openingContext)
      descriptorType = newDescriptorType;
  }
View Full Code Here

      // we do this to keep resolvedDelegates update-able
      // The value from getDeletageAESpecs is an unmodifiable hash map
      resolvedDelegates.putAll(aeDescription
              .getDelegateAnalysisEngineSpecifiers(createResourceManager()));
    } catch (InvalidXMLException e) {
      throw new ResourceInitializationException(e);
    }
    // get the metadata once, because it can be expensive to do    
    AnalysisEngineMetaData md = aeDescription.getAnalysisEngineMetaData();

    // These come before setTypeSystemDescription call because that call
    // invokes tcas validate, which uses the merged values for speedup
    // Here we set them to values that won't cause errors. They're set to actual values below.
    mergedFsIndexCollection = md.getFsIndexCollection();
    mergedTypePriorities = md.getTypePriorities();
    resolvedExternalResourcesAndBindings = aeDescription.getResourceManagerConfiguration();
    resolvedFlowControllerDeclaration = aeDescription.getFlowControllerDeclaration();

    setTypeSystemDescription(aeDescription.isPrimitive() ? md.getTypeSystem() : null);
    // aggregates have null type system descriptors.
    // If passed in one that isn't null, make it null.

    // These come after setTypeSystemDescription call, even though
    // that call invokeds tcas validate, which uses the merged values for speedup
    // Therefore, merged values have to be set to proper ideas first.
    setMergedFsIndexCollection();
    setImportedFsIndexCollection();
    setMergedTypePriorities();
    setImportedTypePriorities();
    try {
      setResolvedExternalResourcesAndBindings();
      // setImportedExternalResourcesAndBindings();
    } catch (InvalidXMLException e1) {
      throw new ResourceInitializationException(e1);
    }
    try {
      setResolvedFlowControllerDeclaration();
    } catch (InvalidXMLException e1) {
      throw new ResourceInitializationException(e1);
    }
  }
View Full Code Here

    aeDescription.setResourceManagerConfiguration(rb);
    try {
      setResolvedExternalResourcesAndBindings();
      // setImportedExternalResourcesAndBindings();
    } catch (InvalidXMLException e) {
      throw new ResourceInitializationException(e);
    }
    descriptorCAS.validate();
  }
View Full Code Here

  public static Resource produceResource(Class<? extends Resource> aResourceClass, ResourceSpecifier aSpecifier,
          Map<String, Object> aAdditionalParams) throws ResourceInitializationException {
    Resource resource = getResourceFactory().produceResource(aResourceClass, aSpecifier,
            aAdditionalParams);
    if (resource == null) {
      throw new ResourceInitializationException(ResourceInitializationException.DO_NOT_KNOW_HOW,
              new Object[] { aResourceClass.getName(), aSpecifier.getSourceUrlString() });
    }
    return resource;
  }
View Full Code Here

          throws ResourceInitializationException {
    try {
      // specifier must be a FlowControllerDescription. (Eventually, we
      // might support remote specifiers, but not yet)
      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());

      // determine if this component is Sofa-aware (based on whether it
      // declares any input or output sofas in its capabilities)
      mSofaAware = getProcessingResourceMetaData().isSofaAware();
     
      // Set Logger, to enable component-specific logging configuration
      UimaContextAdmin uimaContext = getUimaContextAdmin();
      Logger logger = UIMAFramework.getLogger(mFlowController.getClass());
      logger.setResourceManager(this.getResourceManager());
      uimaContext.setLogger(logger);     
     
      // initialize FlowController
      mFlowController.initialize(getFlowControllerContext());

      mMBeanServer = null;
      String mbeanNamePrefix = null;
      if (aAdditionalParams != null) {
        mMBeanServer = aAdditionalParams.get(AnalysisEngine.PARAM_MBEAN_SERVER);
        mbeanNamePrefix = (String)aAdditionalParams.get(AnalysisEngine.PARAM_MBEAN_NAME_PREFIX);
      }
      // update MBean with the name taken from metadata
      getMBean().setName(getMetaData().getName(), getUimaContextAdmin(), mbeanNamePrefix);
      // register MBean with MBeanServer. If no MBeanServer specified in the
      // additionalParams map, this will use the platform MBean Server
      // (Java 1.5 only)
      JmxMBeanAgent.registerMBean(getMBean(), mMBeanServer);

      initialized = true;
      return true;
    } catch (ResourceConfigurationException e) {
      throw new ResourceInitializationException(e);
    }
  }
View Full Code Here

          throws ResourceInitializationException {
    String flowControllerClassName;
    flowControllerClassName = aDescriptor.getImplementationName();

    if (flowControllerClassName == null || flowControllerClassName.length() == 0) {
      throw new ResourceInitializationException(
              ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
              new Object[] { aDescriptor.getSourceUrlString() });
    }
    // load FlowController class
    Class<?> flowControllerClass = null;
    try {
      // get UIMA extension ClassLoader if available
      ClassLoader cl = getUimaContextAdmin().getResourceManager().getExtensionClassLoader();

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

    Object userObject;
    try {
      userObject = flowControllerClass.newInstance();
    } catch (Exception e) {
      throw new ResourceInitializationException(
              ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] {
                  flowControllerClassName, aDescriptor.getSourceUrlString() }, e);
    }
    if (!(userObject instanceof FlowController)) {
      throw new ResourceInitializationException(
              ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                  flowControllerClassName, FlowController.class, aDescriptor.getSourceUrlString() });
    }
    return (FlowController) userObject;
  }
View Full Code Here

 
  public void initialize(UimaContext aContext) throws ResourceInitializationException {
    super.initialize(aContext);
   
    if (getContext().getConfigParameterValue("FailDuringInitialization") != null) {
      throw new ResourceInitializationException(new FileNotFoundException("Simulated Exception"));
    }

    if (getContext().getConfigParameterValue("ErrorFrequency") != null) {
      errorFrequency = ((Integer) getContext().getConfigParameterValue("ErrorFrequency"))
              .intValue();
View Full Code Here

      fis = new FileInputStream(file);
      byte[] contents = new byte[(int) file.length()];
      fis.read(contents);
      text = new String(contents);
    } catch (Exception e) {
      throw new ResourceInitializationException(e);
    } finally {
      if (fis != null) {
        try {
          fis.close();
        } catch (Exception e) {
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.