Package org.apache.uima.pear.tools

Examples of org.apache.uima.pear.tools.PackageBrowser


    File pearFile2 = JUnitExtension.getFile(pear2);
    Assert.assertNotNull(pearFile2);

    // Install PEAR packages
    PackageBrowser instPear1 = PackageInstaller
            .installPackage(this.tempInstallDir, pearFile1, true);

    // check pear PackageBrowser object
    Assert.assertNotNull(instPear1);

    PackageBrowser instPear2 = PackageInstaller
            .installPackage(this.tempInstallDir, pearFile2, true);

    // check pear PackageBrowser object
    Assert.assertNotNull(instPear2);
View Full Code Here


    try {
      // get installed pear root directory - specified as URI of the descriptor
      File pearRootDir = new File(pearRootDirPath);

      // create pear package browser to get the pear meta data
      PackageBrowser pkgBrowser = new PackageBrowser(pearRootDir);

      // get pear env variables and set them as system properties
      Properties props = pkgBrowser.getComponentEnvVars();
      Iterator keyIterator = props.keySet().iterator();
      Properties systemProps = System.getProperties();
      while (keyIterator.hasNext()) {
        String key = (String) keyIterator.next();
        String value = (String) props.get(key);

        // log warning if system property already exist and does not have the same value
        if (systemProps.containsKey(key)) {
          String systemPropValue = (String) systemProps.get(key);
          if (!systemPropValue.equals(value)) {
            UIMAFramework.getLogger(this.getClass()).logrb(
                    Level.WARNING,
                    this.getClass().getName(),
                    "initialize",
                    LOG_RESOURCE_BUNDLE,
                    "UIMA_pear_runtime_system_var_already_set__WARNING",
                    new Object[] { (key + "=" + systemPropValue), (key + "=" + value),
                        pkgBrowser.getRootDirectory().getName() });
          }
        }
        // set new system property
        System.setProperty(key, value);

        UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
                "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_system_var__CONFIG",
                new Object[] { key + "=" + value, pkgBrowser.getRootDirectory().getName() });

      }

      // create UIMA resource manager and apply pear settings
      ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager();
      String classpath = pkgBrowser.buildComponentClassPath();
      rsrcMgr.setExtensionClassPath(classpath, true);
      UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
              "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_classpath__CONFIG",
              new Object[] { classpath, pkgBrowser.getRootDirectory().getName() });

      // get and set uima.datapath if specified
      String dataPath = pkgBrowser.getComponentDataPath();
      if (dataPath != null) {
        rsrcMgr.setDataPath(dataPath);
        UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
                "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_datapath__CONFIG",
                new Object[] { dataPath, pkgBrowser.getRootDirectory().getName() });
      }

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

  private static void installPear(File installDir, File pearFile, boolean doVerification) {

    try {
      // install PEAR package
      PackageBrowser instPear = PackageInstaller.installPackage(
          installDir, pearFile, doVerification);

      // retrieve installed PEAR data
      // PEAR package classpath
      String classpath = instPear.buildComponentClassPath();
      // PEAR package datapath
      String datapath = instPear.getComponentDataPath();
      // PEAR package main component descriptor
      String mainComponentDescriptor = instPear
      .getInstallationDescriptor().getMainComponentDesc();
      // PEAR package component ID
      String mainComponentID = instPear
      .getInstallationDescriptor().getMainComponentId();
      // PEAR package pear descriptor
      String pearDescPath = instPear.getComponentPearDescPath();

      // print out settings
      System.out.println("PEAR package class path: " + classpath);
      System.out.println("PEAR package datapath: " + datapath);
      System.out.println("PEAR package mainComponentDescriptor: "
View Full Code Here

     //get pear file to install
    File pearFile = JUnitExtension.getFile("pearTests/analysisEngine.pear");
    Assert.assertNotNull("analysisEngine.pear file not found", pearFile);
   
    // Install PEAR package without verification
    PackageBrowser instPear = PackageInstaller.installPackage(
            this.tempInstallDir, pearFile, false);
   
    //check package browser
    Assert.assertNotNull("PackageBrowser is null", instPear);
      
View Full Code Here

    //get pear file to install
   File pearFile = JUnitExtension.getFile("pearTests/casConsumer.pear");
   Assert.assertNotNull("casConsumer.pear file not found", pearFile);
  
   // Install PEAR package without verification
   PackageBrowser instPear = PackageInstaller.installPackage(
           this.tempInstallDir, pearFile, false);
  
   //check package browser
   Assert.assertNotNull("PackageBrowser is null", instPear);
     
View Full Code Here

    //get pear file to install
   File pearFile = JUnitExtension.getFile("pearTests/typeSystem.pear");
   Assert.assertNotNull("typeSystem.pear file not found", pearFile);
  
   // Install PEAR package without verification
   PackageBrowser instPear = PackageInstaller.installPackage(
           this.tempInstallDir, pearFile, false);
  
   //check package browser
   Assert.assertNotNull("PackageBrowser is null", instPear);
     
View Full Code Here

    Runnable runCVD = new Runnable() {

      public void run() {
        try {
          // create PackageBrowser object
          PackageBrowser pkgBrowser = new PackageBrowser(new File(mainComponentRootPath));

          // get pear descriptor
          String pearDesc = pkgBrowser.getComponentPearDescPath();

          // start CVD
          MainFrame frame = CVD.createMainFrame();

          // Prevent CVD from shutting down JVM after exit
View Full Code Here

    // get pear files to install
    File pearFile = JUnitExtension.getFile(pear);
    Assert.assertNotNull(pearFile);

    // Install PEAR packages
    PackageBrowser instPear = PackageInstaller
            .installPackage(this.tempInstallDir, pearFile, true);

    // check pear PackageBrowser object
    Assert.assertNotNull(instPear);
    // import pear specifiers
    Import impPear = UIMAFramework.getResourceSpecifierFactory().createImport();
    File import1 = new File(instPear.getComponentPearDescPath());
    impPear.setLocation(import1.toURI().getPath());

    return impPear;
  }
View Full Code Here

    //get pear file to install
    File pearFile = JUnitExtension.getFile("pearTests/DateTime.pear");
    Assert.assertNotNull(pearFile);
   
    // Install PEAR package
    PackageBrowser instPear = PackageInstaller.installPackage(
            this.tempInstallDir, pearFile, true);

    //check pear PackageBrowser object
    Assert.assertNotNull(instPear);
   
    //check PEAR component ID
    String componentID = instPear.getInstallationDescriptor().getMainComponentId();
    Assert.assertEquals("uima.example.DateTimeAnnotator", componentID);
   
    //check PEAR datapath setting
    //pear file contains (uima.datapath = $main_root/my/test/data/path)
    File datapath = new File(this.tempInstallDir, "uima.example.DateTimeAnnotator/my/test/data/path");
    File pearDatapath = new File(instPear.getComponentDataPath());
    Assert.assertEquals(datapath, pearDatapath);
       
    // Create resouce manager and set PEAR package classpath
    ResourceManager rsrcMgr = UIMAFramework.newDefaultResourceManager();

    // Create analysis engine from the installed PEAR package
    XMLInputSource in = new XMLInputSource(instPear.getComponentPearDescPath());
    ResourceSpecifier specifier = UIMAFramework.getXMLParser()
          .parseResourceSpecifier(in);
    AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(
          specifier, rsrcMgr, null);
    Assert.assertNotNull(ae);
View Full Code Here

      // get installed pear root directory - specified as URI of the
      // descriptor
      File pearRootDir = new File(pearRootDirPath);

      // create pear package browser to get the pear meta data
      PackageBrowser pkgBrowser = new PackageBrowser(pearRootDir);

      Properties systemProps = System.getProperties();
      // get pear env variables and set them as system properties
      Properties props = pkgBrowser.getComponentEnvVars();
      for (Entry<Object, Object> entry : props.entrySet()) {
        String key = (String) entry.getKey();
        String value = (String) entry.getValue();

        // log warning if system property already exist and does not have
        // the same value
        if (systemProps.containsKey(key)) {
          String systemPropValue = (String) systemProps.get(key);
          if (!systemPropValue.equals(value)) {
            UIMAFramework.getLogger(this.getClass()).logrb(
                Level.WARNING,
                this.getClass().getName(),
                "initialize",
                LOG_RESOURCE_BUNDLE,
                "UIMA_pear_runtime_system_var_already_set__WARNING",
                new Object[] { (key + "=" + systemPropValue), (key + "=" + value),
                    pkgBrowser.getRootDirectory().getName() });
          }
        }
        // set new system property
        System.setProperty(key, value);

        UIMAFramework.getLogger(this.getClass()).logrb(Level.CONFIG, this.getClass().getName(),
            "initialize", LOG_RESOURCE_BUNDLE, "UIMA_pear_runtime_set_system_var__CONFIG",
            new Object[] { key + "=" + value, pkgBrowser.getRootDirectory().getName() });

      }

      // Caller's Resource Manager obtained from the additional parameters
      // Note: UimaContext can be null for a top level call to
      // produceAnalysisEngine,
      // 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);
View Full Code Here

TOP

Related Classes of org.apache.uima.pear.tools.PackageBrowser

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.