Package org.apache.uima.resource

Examples of org.apache.uima.resource.ResourceManager


    }
  }

  protected boolean setupAE(File aeFile) {
    try {
      ResourceManager rsrcMgr = null;
      if (this.dataPathName != null) {
        try {
          rsrcMgr = UIMAFramework.newDefaultResourceManager();
          rsrcMgr.setDataPath(this.dataPathName);
        } catch (MalformedURLException e) {
          StringBuffer msg = new StringBuffer();
          msg.append("Error setting data path in AE,\n");
          msg.append("data path contains invalid URL or file descriptor.\n");
          msg.append("You can still run the AE if it doesn't rely on the data path.\n");
View Full Code Here


        validDefinition = true;
      } else {
        // String className = ((CasConsumerDescription) resourceSpecifier).getImplementationName();
        // load class using UIMA Extension ClassLoader if there is one
        ClassLoader cl = null;
        ResourceManager rm = getResourceManager();
        if (rm != null) {
          cl = rm.getExtensionClassLoader();
        }
        if (cl == null) {
          cl = this.getClass().getClassLoader();
        }
        // Class currentClass = Class.forName(className, true, cl);
View Full Code Here

    String className = null;
    try {
      className = ((CasConsumerDescription) aSpecifier).getImplementationName();
      // load class using UIMA Extension ClassLoader if there is one
      ClassLoader cl = null;
      ResourceManager rm = getResourceManager();
      if (rm != null) {
        cl = rm.getExtensionClassLoader();
      }
      if (cl == null) {
        cl = this.getClass().getClassLoader();
      }
      Class currentClass = Class.forName(className, true, cl);
View Full Code Here

    String className = null;
    try {
      className = ((CasInitializerDescription) aSpecifier).getImplementationName();
      // load class using UIMA Extension ClassLoader if there is one
      ClassLoader cl = null;
      ResourceManager rm = getResourceManager();
      if (rm != null) {
        cl = rm.getExtensionClassLoader();
      }
      if (cl == null) {
        cl = this.getClass().getClassLoader();
      }
      Class currentClass = Class.forName(className, true, cl);
View Full Code Here

    InstallationDescriptor insDesc = insController.installComponent();
    Assert.assertTrue(insDesc != null);
    Assert.assertTrue(OUT_PEAR_ID.equals(insDesc.getMainComponentId()));
    // verify the installed component
    // customize ResourceManager by adding component CLASSPATH
    ResourceManager resMngr = UIMAFramework.newDefaultResourceManager();
    String compClassPath = InstallationController.buildComponentClassPath(insDesc
            .getMainComponentRoot(), insDesc, false);
    // instantiate the aggregate AE
    resMngr.setExtensionClassPath(compClassPath, true);
    String compDescFilePath = insDesc.getMainComponentDesc();
    XMLParser xmlPaser = UIMAFramework.getXMLParser();
    XMLInputSource xmlInput = new XMLInputSource(compDescFilePath);
    AnalysisEngineDescription aeSpec = xmlPaser.parseAnalysisEngineDescription(xmlInput);
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aeSpec, resMngr, null);
View Full Code Here

   * @return a resource manager that has a class loader that will search the compiled output of the
   * current project, in addition to the plug-in's classpath
   */
  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 a CPE descriptor using import by name and requiring data patht o be set
   */
  public void testImportsWithDataPath() throws Exception {
    CpeDescription cpeDesc = UIMAFramework.getXMLParser().parseCpeDescription(
            new XMLInputSource(JUnitExtension.getFile("CollectionProcessingEngineImplTest/CpeImportDataPathTest.xml")));
    ResourceManager resMgr = UIMAFramework.newDefaultResourceManager();
    File dataPathDir = JUnitExtension.getFile("CollectionProcessingEngineImplTest/imports");
    resMgr.setDataPath(dataPathDir.getAbsolutePath());
    CollectionProcessingEngine cpe = UIMAFramework.produceCollectionProcessingEngine(cpeDesc, resMgr, null);

    TestStatusCallbackListener listener = new TestStatusCallbackListener();
    cpe.addStatusCallbackListener(listener);

View Full Code Here

      return "";
    return s;
  }

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

    try {
      resourceManager.setExtensionClassPath(this.getClass().getClassLoader(), classPath, true);
    } catch (MalformedURLException e1) {
      error.newError(IError.ERROR, getString("Internal Error", null), e1);
    }
    return resourceManager;
  }
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.