Package org.apache.uima

Examples of org.apache.uima.UimaContextAdmin


        overrideParameterSettings(resourceSpecifier, aCasProcessorType
                .getConfigurationParameterSettings(), "CasProcessor:"
                + aCasProcessorType.getName());

        // create child UimaContext and insert into mInitParams map
        UimaContextAdmin childContext = uimaContext.createChild(aCasProcessorType.getName(),
                sofamap);
        Map additionalParams = new HashMap();
        additionalParams.put(Resource.PARAM_UIMA_CONTEXT, childContext);

        // need this check to do specific CasDataConsumer processing
View Full Code Here


        threadState = 1003; // Entering

        // set the current component info of the CAS, so that it knows
        // the sofa
        // mappings for the component that's about to process it
        UimaContextAdmin context = ((CollectionReader) collectionReader).getUimaContextAdmin();
        casList[i].setCurrentComponentInfo(context.getComponentInfo());
        try {
          if (sofaUnaware) {
            // sofa-unaware CR, give it whatever is mapped to the
            // initial view (creating that view first if it's not the default)
            String absSofaName = context.getComponentInfo().mapToSofaID(CAS.NAME_DEFAULT_SOFA);
            if (!CAS.NAME_DEFAULT_SOFA.equals(absSofaName)) {
              casList[i].createView(CAS.NAME_DEFAULT_SOFA);
            }           
            CAS view = casList[i].getView(CAS.NAME_DEFAULT_SOFA);
           
View Full Code Here

    assertEquals(viewE1, iter.next());
    assertEquals(viewE2, iter.next());
    assertFalse(iter.hasNext());
   
    //try with Sofa mappings
    UimaContextAdmin rootCtxt = UIMAFramework.newUimaContext(
            UIMAFramework.getLogger(), UIMAFramework.newDefaultResourceManager(),
            UIMAFramework.newConfigurationManager());
    Map<String, String> sofamap = new HashMap<String, String>();
    sofamap.put("SourceDocument","EnglishDocument");
    UimaContextAdmin childCtxt = rootCtxt.createChild("test", sofamap);
    cas.setCurrentComponentInfo(childCtxt.getComponentInfo());
    iter = this.cas.getViewIterator("SourceDocument");
    assertEquals(viewE1, iter.next());
    assertEquals(viewE2, iter.next());
    assertFalse(iter.hasNext())
    this.cas.setCurrentComponentInfo(null);
   
    //repeat with JCas
    this.cas.reset();
    JCas jcas = this.cas.getJCas();
    JCas jview1 = jcas.createView("View1");
    JCas jview2 = jcas.createView("View2");
    Iterator<JCas> jCasIter = jcas.getViewIterator();
    assertEquals(jcas, jCasIter.next());
    assertEquals(jview1, jCasIter.next());
    assertEquals(jview2, jCasIter.next());
    assertFalse(jCasIter.hasNext());
   
    JCas jviewE1 = jcas.createView("EnglishDocument");
    JCas jviewE2 = jcas.createView("EnglishDocument.2");
    jCasIter = jcas.getViewIterator("EnglishDocument");
    assertEquals(jviewE1, jCasIter.next());
    assertEquals(jviewE2, jCasIter.next());
    assertFalse(jCasIter.hasNext());
   
    //try with Sofa mappings
    cas.setCurrentComponentInfo(childCtxt.getComponentInfo());
    jCasIter = jcas.getViewIterator("SourceDocument");
    assertEquals(jviewE1, jCasIter.next());
    assertEquals(jviewE2, jCasIter.next());
    assertFalse(jCasIter.hasNext())
    this.cas.setCurrentComponentInfo(null);
View Full Code Here

      //  passed to the initialize method of this aggregate, by the
      //  preceeding call to initialize().
     
      if (mInitParams == null)
        mInitParams = new HashMap<String, Object>();
      UimaContextAdmin childContext = aParentContext.createChild(key, sofamap);
      mInitParams.put(Resource.PARAM_UIMA_CONTEXT, childContext);

      AnalysisEngine ae;

      // if running in "validation mode", don't try to connect to any services
View Full Code Here

      // 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;
View Full Code Here

      // where the descriptor is a Pear Resource.

      ResourceManager applicationRM = (aAdditionalParams == null) ? null
          : (ResourceManager) aAdditionalParams.get(Resource.PARAM_RESOURCE_MANAGER);
      if (null == applicationRM) {
        UimaContextAdmin uimaContext = (aAdditionalParams == null) ? null
            : (UimaContextAdmin) aAdditionalParams.get(Resource.PARAM_UIMA_CONTEXT);
        if (null != uimaContext) {
          applicationRM = uimaContext.getResourceManager();
        }
      }

      String classPath = pkgBrowser.buildComponentRuntimeClassPath();
      String dataPath = pkgBrowser.getComponentDataPath();
      StringPair sp = new StringPair(classPath, dataPath);
      ResourceManager innerRM;

      synchronized (cachedResourceManagers) {
        Map<StringPair, ResourceManager> c1 = cachedResourceManagers.get(applicationRM);
        if (null == c1) {
          innerRM = createRM(sp, pkgBrowser, applicationRM);
          cachedResourceManagers.put(applicationRM, createRMmap(sp, innerRM));
        } else {
          innerRM = c1.get(sp);
          if (null == innerRM) {
            innerRM = createRM(sp, pkgBrowser, applicationRM);
            c1.put(sp, innerRM);
            UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
                "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_add_RM_map",
                new Object[] { sp.classPath, sp.dataPath });
          }
        }
      }

      // Create an XML input source from the specifier file
      XMLInputSource in = new XMLInputSource(pkgBrowser.getInstallationDescriptor()
          .getMainComponentDesc());

      // Parse the resource specifier
      ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);

      UimaContextAdmin uimaContext = (aAdditionalParams == null) ? null
          : (UimaContextAdmin) aAdditionalParams.get(Resource.PARAM_UIMA_CONTEXT);
      if (null != uimaContext) {
        ((ChildUimaContext_impl) uimaContext).setPearResourceManager(innerRM);
      }
      // create analysis engine
View Full Code Here

              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) {
View Full Code Here

   *          a UIMA context with configuration parameters.
   * @see #initialize(Object, UimaContext)
   */
  public static void initialize(final Object component, final Map<String, Object> map)
          throws ResourceInitializationException {
    UimaContextAdmin context = UIMAFramework.newUimaContext(UIMAFramework.getLogger(),
            UIMAFramework.newDefaultResourceManager(), UIMAFramework.newConfigurationManager());
    ConfigurationManager cfgMgr = context.getConfigurationManager();
    cfgMgr.setSession(context.getSession());
    for (Entry<String, Object> e : map.entrySet()) {
      cfgMgr.setConfigParameterValue(context.getQualifiedContextName() + e.getKey(), e.getValue());
    }
    initialize(component, context);
  }
View Full Code Here

        threadState = 1003; // Entering

        // set the current component info of the CAS, so that it knows
        // the sofa
        // mappings for the component that's about to process it
        UimaContextAdmin context = ((CollectionReader) collectionReader).getUimaContextAdmin();
        casList[i].setCurrentComponentInfo(context.getComponentInfo());
        try {
          if (sofaUnaware) {
            // sofa-unaware CR, give it whatever is mapped to the
            // initial view (creating that view first if it's not the default)
            String absSofaName = context.getComponentInfo().mapToSofaID(CAS.NAME_DEFAULT_SOFA);
            if (!CAS.NAME_DEFAULT_SOFA.equals(absSofaName)) {
              casList[i].createView(CAS.NAME_DEFAULT_SOFA);
            }           
            CAS view = casList[i].getView(CAS.NAME_DEFAULT_SOFA);
           
View Full Code Here

      if (key == null) {
        throw new AsynchAEException(getName() + "-Unable to look up delegate "
                + aDelegateEndpointName + " in internal map");
      }
      UimaContextAdmin uctx = getUimaContextAdmin();

      // retrieve the sofa mappings for input/output sofas of this analysis engine
      HashMap sofamap = new HashMap();
      if (resourceSpecifier instanceof AnalysisEngineDescription) {
        AnalysisEngineDescription desc = (AnalysisEngineDescription) resourceSpecifier;
        SofaMapping[] sofaMappings = desc.getSofaMappings();
        if (sofaMappings != null && sofaMappings.length > 0) {
          for (int s = 0; s < sofaMappings.length; s++) {
            // the mapping is for this analysis engine
            if (sofaMappings[s].getComponentKey().equals(key)) {
              // if component sofa name is null, replace it with
              // the default for TCAS sofa name
              // This is to support old style TCAS
              if (sofaMappings[s].getComponentSofaName() == null)
                sofaMappings[s].setComponentSofaName(CAS.NAME_DEFAULT_SOFA);
              sofamap.put(sofaMappings[s].getComponentSofaName(), sofaMappings[s]
                      .getAggregateSofaName());
            }
          }
        }
      }
      // create child UimaContext and insert into mInitParams map
      return uctx.createChild(key, sofamap);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.apache.uima.UimaContextAdmin

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.