Package org.apache.uima.pear.tools

Examples of org.apache.uima.pear.tools.InstallationDescriptor$ActionInfo


  static InstallationDescriptor generateMergedInstallationDescriptor(File rootDir,
          String aggCompName, File aggDescFile, InstallationDescriptor[] dlgInstDescs,
          File[] dlgRootDirs) throws IOException {
    // create aggregate installation descriptor
    File aggInsdFile = new File(rootDir, PackageBrowser.INSTALLATION_DESCRIPTOR_FILE);
    InstallationDescriptor aggInsdObject = new InstallationDescriptor(aggInsdFile);
    aggInsdObject.setMainComponent(aggCompName);
    // 1st step: set aggregate component descriptor
    String aggDescPath = MAIN_ROOT + "/"
            + FileUtil.getRelativePath(rootDir, aggDescFile.getAbsolutePath());
    aggInsdObject.setMainComponentDesc(aggDescPath);
    // 2nd step: collect installation actions from delegates
    for (int i = 0; i < dlgInstDescs.length; i++) {
      InstallationDescriptor dlgInsdObject = dlgInstDescs[i];
      // add implicit installation actions
      File dlgRootDir = dlgRootDirs[i];
      String adjMainRoot = MAIN_ROOT + "/" + dlgRootDir.getName();
      StringBuffer cpBuffer = new StringBuffer();
      // add JAR files in delegate lib dir to CLASSPATH
      File dlgLibDir = new File(dlgRootDir, PackageBrowser.LIBRARY_DIR);
      if (dlgLibDir.isDirectory()) {
        // get list of JAR files
        File[] jarFiles = dlgLibDir.listFiles(new FileUtil.ExtFilenameFilter(".jar"));
        // build delegate CLASSPATH buffer
        cpBuffer.setLength(0);
        for (int n = 0; n < jarFiles.length; n++) {
          if (cpBuffer.length() > 0)
            cpBuffer.append(STANDARD_PATH_SEPARATOR_CHAR);
          cpBuffer.append(adjMainRoot + "/"
                  + FileUtil.getRelativePath(dlgRootDir, jarFiles[n].getAbsolutePath()));
        }
        // add 'set_env_variable' action
        if (cpBuffer.length() > 0)
          aggInsdObject.addInstallationAction(createEnvAction("CLASSPATH", cpBuffer.toString()));
      }
      // add delegate bin dir to CLASSPATH and PATH
      File dlgBinDir = new File(dlgRootDir, PackageBrowser.BINARY_DIR);
      if (dlgBinDir.isDirectory()) {
        String adjBinDirPath = adjMainRoot + "/"
                + FileUtil.getRelativePath(dlgRootDir, dlgBinDir.getAbsolutePath());
        aggInsdObject.addInstallationAction(createEnvAction("CLASSPATH", adjBinDirPath));
        aggInsdObject.addInstallationAction(createEnvAction("PATH", adjBinDirPath));
      }
      // add explicit installation actions
      Collection dlgInstActs = dlgInsdObject.getInstallationActions();
      Iterator list = dlgInstActs.iterator();
      while (list.hasNext())
        aggInsdObject.addInstallationAction((InstallationDescriptor.ActionInfo) list.next());
    }
    // save aggregate installation descriptor file
View Full Code Here


    try {
      insdHandler.parse(insdFile);
    } catch (Exception e) {
      throw new IOException(e.toString());
    }
    InstallationDescriptor insdObject = insdHandler.getInstallationDescriptor();
    // add installation descriptor file to 'find_and_replace_path' actions
    insdObject.addInstallationAction(createFileAction(adjMainRoot + "/"
            + InstallationProcessor.INSD_FILE_PATH, MAIN_ROOT));
    // 2nd: process files under 'desc' folder, if exists
    processFiles(rootDir, PackageBrowser.DESCRIPTORS_DIR, insdObject);
    // 3rd: process files under 'conf' folder, if exists
    processFiles(rootDir, PackageBrowser.CONFIGURATION_DIR, insdObject);
View Full Code Here

    Assert.assertTrue(done);
    Assert.assertTrue(outPearFile.isFile());
    // install the output PEAR file and check the results
    InstallationController insController = new InstallationController(OUT_PEAR_ID, outPearFile,
            _tempWorkingDir);
    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);
    Assert.assertTrue(ae != null);
View Full Code Here

      // get Map of delegate specifiers with imports
      Map delegatesMap = aggDescription.getDelegateAnalysisEngineSpecifiersWithImports();
      // add delegate imports to the Map
      for (int i = 0; i < dlgInstDescs.length; i++) {
        // get delegate component attributes
        InstallationDescriptor dlgInsD = dlgInstDescs[i];
        String dlgName = dlgInsD.getMainComponentId();
        String dlgDescPath = dlgInsD.getMainComponentDesc();
        // create Import for delegate component
        Import dlgImport = rsFactory.createImport();
        // set relative delegate descriptor location
        String dlgDescRelPath = dlgDescPath.replaceAll(PMControllerHelper.MAIN_ROOT_REGEX,
                StringUtil.toRegExpReplacement(".."));
View Full Code Here

          addNature = MessageDialog.openQuestion(shell, "Adding UIMA custom Nature",
                  "Would you like to add a UIMA Nature to the project '" + currentProject.getName()
                          + "' ?");
        }
        if (addNature) {
          InstallationDescriptor insd = null;
          try {
            insd = PearInstallationDescriptor.getInstallationDescriptor(currentProject);
          } catch (Throwable e) {
            e.printStackTrace();
            insd = new InstallationDescriptor();
          }
          try {
            ProjectCustomizer.customizeProject(currentProject, insd);
            if (currentProject.hasNature(ProjectCustomizer.UIMA_NATURE_ID)) {
              MessageDialog.openInformation(shell, "UIMA Nature",
View Full Code Here

    }
    try {
      insd = PearInstallationDescriptor.getInstallationDescriptor(currentContainer);
    } catch (Throwable e) {
      e.printStackTrace();
      insd = new InstallationDescriptor();
    }
    try {
      ProjectCustomizer.customizeProject(currentContainer, insd);
    } catch (Throwable e) {
      PearException subEx = new PearException(
View Full Code Here

   *          An IProject
   * @throws PearException
   *           If a problem occurs
   */
  public static void customizeProject(IProject project) throws PearException {
    InstallationDescriptor insd = new InstallationDescriptor();
    customizeProject(project, insd);
  }
View Full Code Here

    }
    try {
      insd = PearInstallationDescriptor.getInstallationDescriptor(currentProject);
    } catch (Throwable e) {
      e.printStackTrace();
      insd = new InstallationDescriptor();
    }
    try {
      ProjectCustomizer.customizeProject(currentProject, insd);
    } catch (Throwable e) {
      PearException subEx = new PearException(
View Full Code Here

    Assert.assertTrue(done);
    Assert.assertTrue(outPearFile.isFile());
    // install the output PEAR file and check the results
    InstallationController insController = new InstallationController(OUT_PEAR_ID, outPearFile,
            _tempWorkingDir);
    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);
    Assert.assertTrue(ae != null);
View Full Code Here

      // get Map of delegate specifiers with imports
      Map delegatesMap = aggDescription.getDelegateAnalysisEngineSpecifiersWithImports();
      // add delegate imports to the Map
      for (int i = 0; i < dlgInstDescs.length; i++) {
        // get delegate component attributes
        InstallationDescriptor dlgInsD = dlgInstDescs[i];
        String dlgName = dlgInsD.getMainComponentId();
        String dlgDescPath = dlgInsD.getMainComponentDesc();
        // create Import for delegate component
        Import dlgImport = rsFactory.createImport();
        // set relative delegate descriptor location
        String dlgDescRelPath = dlgDescPath.replaceAll(PMControllerHelper.MAIN_ROOT_REGEX,
                StringUtil.toRegExpReplacement(".."));
View Full Code Here

TOP

Related Classes of org.apache.uima.pear.tools.InstallationDescriptor$ActionInfo

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.