Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceManager


              mergedTypesAddingFeatures);
    else {
      if (null == typeSystemDescription) {
        mergedTypeSystemDescription = null;
      } else {
        ResourceManager resourceManager = createResourceManager();
        Collection tsdc = new ArrayList(1);
        tsdc.add(typeSystemDescription.clone());
        // System.out.println("mergingTypeSystem 2"); //$NON-NLS-1$
        // long time = System.currentTimeMillis();
        mergedTypeSystemDescription = CasCreationUtils.mergeTypeSystems(tsdc, resourceManager,
View Full Code Here


   *
   * @return
   */
  public ResourceManager createResourceManager() {
    // long time = System.currentTimeMillis();
    ResourceManager rm = createResourceManager(null);
    // System.out.println("CreateResourceManager: " + (System.currentTimeMillis() - time));
    return rm;
  }
View Full Code Here

  private String cachedRMclassPath = null;
  private SoftReference<UIMAClassLoader> cachedRMcl = new SoftReference<UIMAClassLoader>(null);

  public ResourceManager createResourceManager(String classPath) {
    ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();

    try {
      if (null == classPath) {
        classPath = getProjectClassPath();
      }     
      String dataPath = CDEpropertyPage.getDataPath(getProject());
     
      // first try to get the value of the class loader from the last (cached)
      // value - should succeed frequently because the class loader is only dependent
      // on the value of the classpath
     
      UIMAClassLoader uimaCL = null;
      if (cachedRMclassPath != null &&
          cachedRMclassPath.equals(classPath)) {
        uimaCL = cachedRMcl.get();
      }
     
      if (uimaCL != null) {
        ((ResourceManager_impl)resourceManager).setExtensionClassPath(uimaCL, true);
      } else {
        // first arg in next is the parent of the class loader.  Make it be the
        //   uima framework's class loader (not this class's class loader)
        //   so the validation tests work properly (that test isAssignableFrom)
        resourceManager.setExtensionClassPath(UIMAFramework.class.getClassLoader(), classPath, true);
        cachedRMclassPath = classPath;
        cachedRMcl = new SoftReference<UIMAClassLoader>((UIMAClassLoader) resourceManager.getExtensionClassLoader());
      }
     
      // in any case, set the data path
      resourceManager.setDataPath(dataPath);
    } catch (MalformedURLException e1) {
      throw new InternalErrorCDE(Messages.getString("MultiPageEditor.14"), e1); //$NON-NLS-1$
    } catch (CoreException e1) {
      throw new InternalErrorCDE(Messages.getString("MultiPageEditor.15"), e1); //$NON-NLS-1$
    }
View Full Code Here

              mergedTypesAddingFeatures);
    else {
      if (null == typeSystemDescription) {
        mergedTypeSystemDescription = null;
      } else {
        ResourceManager resourceManager = createResourceManager();
        Collection tsdc = new ArrayList(1);
        tsdc.add(typeSystemDescription.clone());
        // System.out.println("mergingTypeSystem 2"); //$NON-NLS-1$
        // long time = System.currentTimeMillis();
        mergedTypeSystemDescription = CasCreationUtils.mergeTypeSystems(tsdc, resourceManager,
View Full Code Here

   
    //test aggregate with import by name and configuration parameter overrides
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AeWithConfigParamOverridesAndImportByName.xml"));
    desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    File dataPathDir = JUnitExtension.getFile("TextAnalysisEngineImplTest/dataPathDir");
    resMgr.setDataPath(dataPathDir.getCanonicalPath());
    desc.doFullValidation(resMgr);
   
    //test UIMA C++ descriptor (should succeed even though annotator library doesn't exist)
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/TestUimaCppAe.xml"));
View Full Code Here

  public void testValidate() throws Exception {
    //test aggregate with import by name and configuration parameter overrides
    XMLInputSource in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/AeWithConfigParamOverridesAndImportByName.xml"));
    AnalysisEngineDescription desc = UIMAFramework.getXMLParser().parseAnalysisEngineDescription(in);
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    File dataPathDir = JUnitExtension.getFile("TextAnalysisEngineImplTest/dataPathDir");
    resMgr.setDataPath(dataPathDir.getCanonicalPath());
    desc.validate(resMgr);
   
    //test invalid aggregate with undefined key in flow
    in = new XMLInputSource(JUnitExtension
            .getFile("TextAnalysisEngineImplTest/InvalidAggregate_UndefinedKeyInFlow.xml"));
View Full Code Here

    // load the type system and resolve the imports using the classpath
    // TypeSystemDescription typeSystemDescription;
    try {
      // XMLInputSource in = new XMLInputSource(typeSystemFile.toURI().toURL());
      // typeSystemDescription = UIMAFramework.getXMLParser().parseTypeSystemDescription(in);
      ResourceManager resourceManager = UIMAFramework.newDefaultResourceManager();
      resourceManager.setExtensionClassPath(classpath, true);
      typeSystemDescription.resolveImports(resourceManager);
      // on any exception, the type system was invalid, so assume no files have changed
    } catch (InvalidXMLException e) {
      return false;
    } catch (MalformedURLException e) {
View Full Code Here

      // name import
      importObj = new Import_impl();
      importObj.setName("TypeSystemDescriptionImplTest.TestTypeSystem");
      String workingDir = JUnitExtension.getFile("TypeSystemDescriptionImplTest").getParentFile()
          .getAbsolutePath();
      ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
      resMgr.setDataPath(workingDir);
      absUrl = importObj.findAbsoluteUrl(resMgr);
      expectedUrl = new File(workingDir, "TypeSystemDescriptionImplTest/TestTypeSystem.xml")
      .toURL();
      assertEquals(expectedUrl, absUrl);
View Full Code Here

    // get or create ResourceManager
    // This ResourceManager is shared among all the AEs in the pool, and also used by
    // this MultiprocessingAE instance
    // https://issues.apache.org/jira/browse/UIMA-2078
    ResourceManager resMgr = (ResourceManager) aAdditionalParams.get(Resource.PARAM_RESOURCE_MANAGER);
    if (resMgr == null) {
      resMgr = UIMAFramework.newDefaultResourceManager();
      aAdditionalParams.put(Resource.PARAM_RESOURCE_MANAGER, resMgr);
    }
   
View Full Code Here

 

  public void testAggregateWithImports() throws Exception {
    try {
      String pathSep = System.getProperty("path.separator");
      ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
      resMgr.setDataPath(JUnitExtension.getFile("TypeSystemDescriptionImplTest/dataPathDir")
              .getAbsolutePath()
              + pathSep
              + JUnitExtension.getFile("TypePrioritiesImplTest/dataPathDir").getAbsolutePath()
              + pathSep
              + JUnitExtension.getFile("FsIndexCollectionImplTest/dataPathDir").getAbsolutePath());
View Full Code Here

TOP

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

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.