Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.PropertiesConfiguration


    return new BrowseThread(boboReader,_reqIter,throttleWait,runForever,this);
  }
 
  public static void main(String[] args) throws Exception{
    File propFile = new File(args[0]);
    BoboPerf perf = new BoboPerf(new PropertiesConfiguration(propFile));
    perf.start();
  }
View Full Code Here


   * @param args
   */
  public static void main(String[] args) throws Exception {
    File propFile = new File(args[0]);
    DocumentFetchPerf perf = new DocumentFetchPerf(
        new PropertiesConfiguration(propFile));
    perf.start();
  }
View Full Code Here

          });
          FileSystem.setDefaultFileSystem(fs);
          // allow for conditional incldues -> first createn an empty
          // properties conf
          _fileConfiguration = new PropertiesConfiguration();
          // then set the file name and load it
          _fileConfiguration.setFileName(configFile);
          try
          {
            _fileConfiguration.setBasePath(new File(".").getCanonicalPath());
View Full Code Here

      File cn = new File(cf, fileName);

      if (save)
      {
        // interpolate the file so that no includes are required
        PropertiesConfiguration c2 = (PropertiesConfiguration) _fileConfiguration.interpolatedConfiguration();

        // save the file
        c2.save(cn);
      }
      return cn.getCanonicalPath();

    }
    catch (Exception ex)
View Full Code Here

       * vmidentifier = new VmIdentifier("" + p.getPid()); MonitoredVm vm
       * = monitoredhost.getMonitoredVm(vmidentifier, 0);
       */

      // System.out.println("cmd " +MonitoredVmUtil.commandLine(vm));
      PropertiesConfiguration conf;
      if (input == null)
        conf = new PropertiesConfiguration();
      else
        conf = new PropertiesConfiguration(input);

      JCLParser parsedCmd = JCLParser.parse(cmd);
      /*
       * String mainClass = MonitoredVmUtil.mainClass(vm, true); if
       * (!isNotNullEmpty(mainClass)) {System.out.println(
       * "could not retrieve main class of java application -> abort");
       * return; } mainClass = confString(mainClass); if
       * (mainClass.endsWith(".jar"))
       * conf.setProperty("wrapper.java.app.jar",
       * relativeString(mainClass, workingDir)); else
       * conf.setProperty("wrapper.java.app.mainclass", mainClass);
       */
      if (parsedCmd.getMainClass() != null)
        conf.setProperty("wrapper.java.app.mainclass", parsedCmd.getMainClass());
      else
        conf.setProperty("wrapper.java.app.jar", relativeString(parsedCmd.getJar(), workingDir));

      /*
       * // this does not seem to work correctly -> get jvm the hard way
       * // System.out.println("vmVersion " + vmVersion); String jvm =
       * null; if (cmd.startsWith("\"")) jvm = cmd.substring(0,
       * cmd.indexOf("\" ") + 1); else jvm = cmd.substring(0,
       * cmd.indexOf(" ")); if (isNotNullEmpty(jvm)) { jvm =
       * confString(jvm); conf.setProperty("wrapper.java.command", jvm); }
       */
      conf.setProperty("wrapper.java.command", parsedCmd.getJava());
      /*
       * String classpath = ((StringMonitor)
       * vm.findByName("java.property.java.class.path")).stringValue(); if
       * (isNotNullEmpty(classpath)) { classpath =
       * relativeString(classpath, workingDir); classpath =
       * confString(classpath); String[] classpaths =
       * classpath.split(System.getProperty("path.separator")); int i = 1;
       * for (String file : classpaths) {
       * conf.setProperty("wrapper.java.classpath." + i, file); i++; } }
       */
      int i = 1;
      List<String> classpathList = parsedCmd.getClasspath();
      // no longer required - wrapper will automatically add the jar to the classpath
      //if (conf.getString("wrapper.java.app.jar", null) != null)
      //  classpathList.add(conf.getString("wrapper.java.app.jar"));
      if (classpathList == null || classpathList.isEmpty())
        classpathList = getClasspathFromEnvironment(p);
      if (classpathList.isEmpty() && parsedCmd.getJar() == null)
        classpathList.add(".");
      for (String classpath : classpathList)
      {
        classpath = relativeString(classpath, workingDir);
        classpath = confString(classpath);
        conf.setProperty("wrapper.java.classpath." + i++, classpath);
      }

      /*
       * // bug in MonitoredVMUtil 'c:/x.txt "d d"' returns 'c:/x.txt d d'
       * //String mainArgs = MonitoredVmUtil.mainArgs(vm); // TODO really
       * parse the cmd String mainArgs =
       * cmd.substring(cmd.indexOf(" "+mainClass
       * +" ")+mainClass.length()+2); if (isNotNullEmpty(mainArgs)) { List
       * args = splitArgs(mainArgs); int i = 1; for (Iterator
       * it=args.iterator(); it.hasNext(); ) { String arg = (String)
       * it.next(); arg = relativeString(arg, workingDir); arg =
       * confString(arg); conf.setProperty("wrapper.app.parameter."+i++,
       * arg); } }
       */

      i = 1;
      for (String arg : parsedCmd.getArgs())
      {
        arg = relativeString(arg, workingDir);
        arg = confString(arg);
        conf.setProperty("wrapper.app.parameter." + i++, arg);
      }
      /*
       * // bug in MonitoredVMUtil '"-Xd=a a"' returns '-Xd=a a' //String
       * jvmArgs = MonitoredVmUtil.jvmArgs(vm); // TODO really parse the
       * cmd String jvmArgs = cmd.substring(jvm.length(),
       * cmd.indexOf(" "+mainClass+" ")); if (cmd.startsWith("\""))
       * jvmArgs = jvmArgs.substring(1); jvmArgs =
       * jvmArgs.replace(classpath, ""); jvmArgs =
       * jvmArgs.replace(" -classpath ", ""); jvmArgs =
       * jvmArgs.replace(" -cp ", "");
       *
       * if (isNotNullEmpty(jvmArgs)) { List args = splitArgs(jvmArgs);
       * int i = 1; for (Iterator it=args.iterator(); it.hasNext(); ) {
       * String arg = (String) it.next(); arg = relativeString(arg,
       * workingDir); arg = confString(arg);
       * conf.setProperty("wrapper.java.additional."+i++, arg); } }
       *
       * String jvmFlags = MonitoredVmUtil.jvmFlags(vm);
       */
      i = 1;
      for (String opt : parsedCmd.getVmOptions())
      {
        opt = relativeString(opt, workingDir);
        opt = confString(opt);
        conf.setProperty("wrapper.java.additional." + i++, opt);
      }

      if (isNotNullEmpty(workingDir))
      {
        workingDir = confString(workingDir);
        conf.setProperty("wrapper.working.dir", workingDir);
      }
      String title = p.getTitle();
      if (cmd.equals(title))
        title = parsedCmd.getMainClass();

      if (isNotNullEmpty(title))
      {
        title = confString(title);
        conf.setProperty("wrapper.console.title", title);
        conf.setProperty("wrapper.ntservice.name", title);
        conf.setProperty("wrapper.ntservice.displayname", title);
        conf.setProperty("wrapper.ntservice.description", title);
      }
      /*
       * String account = p.getUser(); if (account != null &&
       * !"".equals(account)) conf.setProperty("wrapper.app.account",
       * account);
       */

      /*
       * List l = vm.findByPattern(".*"); for (Iterator it = l.iterator();
       * it.hasNext(); ) { Monitor m = (Monitor) it.next();
       * System.out.println(m.getName()); System.out.println("> "+
       * m.getValue()); }
       */

      conf.save(output);
    }
    catch (Exception ex)
    {
      ex.printStackTrace();
    }
View Full Code Here

  }

  public PropertiesConfiguration toConfiguration(String defaultsFile) throws ConfigurationException, IOException
  {
    int i = 1;
    PropertiesConfiguration jnlpConf = new PropertiesConfiguration();

    List jars = getJars(_doc);
    for (Iterator it = jars.listIterator(); it.hasNext();)
    {
      jnlpConf.setProperty("wrapper.java.classpath." + i++, it.next());
    }

    jnlpConf.setProperty("wrapper.base", getCodebase(_doc));

    jnlpConf.setProperty("wrapper.java.app.mainclass", getMainClass(_doc));

    i = 1;
    for (Iterator it = getArguments(_doc).listIterator(); it.hasNext();)
    {
      jnlpConf.setProperty("wrapper.app.parameter." + i++, it.next());
    }
    i = 1;
    List props = getResourceProperties(_doc);
    for (Iterator it = props.listIterator(); it.hasNext();)
    {
      jnlpConf.setProperty("wrapper.java.additional." + i++, it.next());
    }

    i = 1;
    List resources = getResources(_doc);
    for (Iterator it = resources.listIterator(); it.hasNext();)
    {
      jnlpConf.setProperty("wrapper.resource." + i++, it.next());
    }

    if (defaultsFile == null || "".equals(defaultsFile))
      return jnlpConf;

    // jnlpConf.addProperty("include", defaultsFile);

    if (defaultsFile != null)
    {
      PropertiesConfiguration defaultsConf = new PropertiesConfiguration();
      FileObject fo = VFSUtils.resolveFile(".", defaultsFile);
      InputStream in = fo.getContent().getInputStream();
      defaultsConf.load(in);
      in.close();
      for (Iterator it = defaultsConf.getKeys(); it.hasNext();)
      {
        String key = (String) it.next();
        if (jnlpConf.containsKey(key))
          System.out.println("configuration conflict: " + key);
        else
          jnlpConf.addProperty(key, defaultsConf.getProperty(key));
      }
    }

    return jnlpConf;
View Full Code Here

            confPath = getRealPath(confFile);

            // This should eventually be a Configuration
            // interface so that service and app configuration
            // can be stored anywhere.
            configuration = (Configuration) new PropertiesConfiguration(confPath);
            confStyle = "Properties";
        }


        //
View Full Code Here

            throws TorqueException
    {
        log.debug("init(" + configFile + ")");
        try
        {
            Configuration conf = new PropertiesConfiguration(configFile);

            log.debug("Config Object is " + conf);
            init(conf);
        }
        catch (ConfigurationException e)
View Full Code Here

        super.setUp();
        BrokerTestHelper.setUp();

        _storePath = System.getProperty("QPID_WORK") + File.separator + getName();

        _config = new PropertiesConfiguration();
        _config.addProperty("store.class", getTestProfileMessageStoreClassName());
        _config.addProperty("store.environment-path", _storePath);
        _virtualHostModel = mock(org.apache.qpid.server.model.VirtualHost.class);
        when(_virtualHostModel.getAttribute(eq(org.apache.qpid.server.model.VirtualHost.STORE_PATH))).thenReturn(_storePath);
View Full Code Here

    private ClusterSpec whirrConfigurationToClusterSpec(HostDescription hostDescription,
                                                        File workingDirectory) throws IOException, GFacHandlerException, ConfigurationException {
        File whirrConfig = getWhirrConfigurationFile(hostDescription, workingDirectory);
        CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
        Configuration configuration = new PropertiesConfiguration(whirrConfig);
        compositeConfiguration.addConfiguration(configuration);

        ClusterSpec hadoopClusterSpec = new ClusterSpec(compositeConfiguration);

        for (ClusterSpec.Property required : EnumSet.of(CLUSTER_NAME, PROVIDER, IDENTITY, CREDENTIAL,
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.PropertiesConfiguration

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.