Example usage for java.util Properties propertyNames

List of usage examples for java.util Properties propertyNames

Introduction

In this page you can find the example usage for java.util Properties propertyNames.

Prototype

public Enumeration<?> propertyNames() 

Source Link

Document

Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Properties props = System.getProperties();

    Enumeration e = props.propertyNames();
    for (; e.hasMoreElements();) {
        String propName = (String) e.nextElement();
        System.out.println(propName);
        String propValue = (String) props.get(propName);
        System.out.println(propValue);
    }//from  ww  w  .  java2  s  .  c  om
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    Properties p = new Properties();
    p.load(new FileInputStream("test.txt"));
    Enumeration e = p.propertyNames();

    for (; e.hasMoreElements();) {
        System.out.println(e.nextElement());

    }/*  w  ww . j a v  a 2 s . co m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Properties prop = new Properties();

    prop.put("Chapter Count", "200");
    prop.put("Tutorial Count", "15");
    prop.put("tutorial", "java2s.com");

    // assign the property names in a enumaration
    Enumeration<?> enumeration = prop.propertyNames();

    // print the enumaration elements
    System.out.println(enumeration.nextElement());
    System.out.println(enumeration.nextElement());

}

From source file:DumpProps.java

public static void main(String args[]) {
    Properties props = System.getProperties();
    Iterator iter = props.entrySet().iterator();
    while (iter.hasNext()) {
        Map.Entry entry = (Map.Entry) iter.next();
        System.out.println(entry.getKey() + " --- " + entry.getValue());
    }//  www.  j ava2s . co  m

    System.out.println("-------");

    Enumeration e = props.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " --- " + props.getProperty(key));
    }
}

From source file:net.padlocksoftware.padlock.licensevalidator.Main.java

/**
 * @param args the command line arguments
 *//* w  w  w.  j ava  2 s.c  o m*/
public static void main(String[] args) {
    parse(args);
    Date currentDate = new Date();

    Validator v = new Validator(license, new String(Hex.encodeHex(pair.getPublic().getEncoded())));
    v.setIgnoreFloatTime(true);

    boolean ex = false;
    LicenseState state;
    try {
        state = v.validate();
    } catch (ValidatorException e) {
        state = e.getLicenseState();
    }

    // Show test status
    System.out.println("\nValidation Test Results:");
    System.out.println("========================\n");
    for (TestResult result : state.getTests()) {
        System.out.println(
                "\t" + result.getTest().getName() + "\t\t\t" + (result.passed() ? "Passed" : "Failed"));
    }

    System.out.println("\nLicense state: " + (state.isValid() ? "Valid" : "Invalid"));

    //
    // Cycle through any dates
    //
    Date d = license.getCreationDate();
    System.out.println("\nCreation date: \t\t" + d);

    d = license.getStartDate();
    System.out.println("Start date: \t\t" + d);

    d = license.getExpirationDate();
    System.out.println("Expiration date: \t" + d);

    Long floatPeroid = license.getFloatingExpirationPeriod();
    if (floatPeroid != null) {
        long seconds = floatPeroid / 1000L;
        System.out.println("\nExpire after first run: " + seconds + " seconds");

    }

    if (floatPeroid != null || license.getExpirationDate() != null) {
        long remaining = v.getTimeRemaining(currentDate) / 1000L;
        System.out.println("\nTime remaining: " + remaining + " seconds");

    }

    //
    // License properties
    //
    System.out.println("\nLicense Properties");
    Properties p = license.getProperties();
    if (p.size() == 0) {
        System.out.println("None");
    }

    for (final Enumeration propNames = p.propertyNames(); propNames.hasMoreElements();) {
        final String key = (String) propNames.nextElement();
        System.out.println("Property: " + key + " = " + p.getProperty(key));
    }

    //
    // Hardware locking
    //
    for (String address : license.getHardwareAddresses()) {
        System.out.println("\nHardware lock: " + address);
    }
    System.out.println("\n");
}

From source file:org.soaplab.admin.ExploreConfig.java

/*************************************************************************
 *
 *  An entry point/*from w ww.jav  a 2  s  .c  o m*/
 *
 *************************************************************************/
@SuppressWarnings("unchecked")
public static void main(String[] args) {

    try {
        BaseCmdLine cmd = getCmdLine(args, ExploreConfig.class);
        String param = null;

        // remember System properties before we initialize
        // Soaplab's Config
        Properties sysProps = System.getProperties();

        // for testing: adding property files
        if ((param = cmd.getParam("-f")) != null) {
            title("Adding config property files:");
            String[] files = param.split(",");
            for (String filename : files) {
                if (Config.addConfigPropertyFile(filename))
                    msgln("Added:  " + filename);
                else
                    msgln("Failed: " + filename);
            }
            msgln("");
        }
        if ((param = cmd.getParam("-xml")) != null) {
            title("Adding config XML files:");
            String[] files = param.split(",");
            for (String filename : files) {
                if (Config.addConfigXMLFile(filename))
                    msgln("Added:  " + filename);
                else
                    msgln("Failed: " + filename);
            }
            msgln("");
        }

        // list of configurations
        if (cmd.hasOption("-lf")) {
            title("Using property resources (in this order):");
            int i = 0;
            while (true) {
                Configuration cfg = null;
                int count = 0;
                try {
                    cfg = Config.get().getConfiguration(i++);
                    for (Iterator<String> it = cfg.getKeys(); it.hasNext(); count++)
                        it.next();
                } catch (IndexOutOfBoundsException e) {
                    break;
                }
                if (count == 0)
                    msg(i + ": (empty) ");
                else
                    msg(i + ": (" + String.format("%1$5d", count) + ") ");
                if (cfg instanceof FileConfiguration) {
                    msgln(((FileConfiguration) cfg).getFile().getAbsolutePath());
                } else if (cfg instanceof SystemConfiguration) {
                    msgln("Java System Properties");
                } else if (cfg instanceof BaseConfiguration) {
                    msgln("Directly added properties (no config file)");
                } else {
                    msgln(cfg.getClass().getName());
                }
            }
            msgln("");
        }

        // list of properties
        boolean listProps = cmd.hasOption("-l");
        boolean listAllProps = cmd.hasOption("-la");
        if (listProps || listAllProps) {
            title("Available properties" + (listProps ? " (except System properties):" : ":"));
            SortedMap<String, String> allProps = new TreeMap<String, String>();
            int maxLen = 0;
            for (Iterator<String> it = Config.get().getKeys(); it.hasNext();) {
                String key = it.next();
                if (listAllProps || !sysProps.containsKey(key)) {
                    if (key.length() > maxLen)
                        maxLen = key.length();
                    String[] values = Config.get().getStringArray(key);
                    if (values.length != 0)
                        allProps.put(key, StringUtils.join(values, ","));
                }
            }
            for (Iterator<Map.Entry<String, String>> it = allProps.entrySet().iterator(); it.hasNext();) {
                Map.Entry<String, String> entry = it.next();
                msgln(String.format("%1$-" + maxLen + "s", entry.getKey()) + " => " + entry.getValue());
            }
            msgln("");
        }

        // get properties by prefix
        if ((param = cmd.getParam("-prefix")) != null) {
            String serviceName = cmd.getParam("-service");
            if (serviceName == null)
                title("Properties matching prefix:");
            else
                title("Properties matching service name and prefix:");
            SortedSet<String> selectedKeys = new TreeSet<String>();
            int maxLen = 0;
            Properties props = Config.getMatchingProperties(param, serviceName, null);
            for (Enumeration en = props.propertyNames(); en.hasMoreElements();) {
                String key = (String) en.nextElement();
                if (key.length() > maxLen)
                    maxLen = key.length();
                selectedKeys.add(key);
            }
            for (Iterator<String> it = selectedKeys.iterator(); it.hasNext();) {
                String key = it.next();
                msgln(String.format("%1$-" + maxLen + "s", key) + " => " + props.getProperty(key));
            }
            msgln("");
        }

        // show individual properties value
        if (cmd.params.length > 0) {
            int maxLen = 0;
            for (int i = 0; i < cmd.params.length; i++) {
                int len = cmd.params[i].length();
                if (len > maxLen)
                    maxLen = len;
            }
            title("Selected properties:");
            for (int i = 0; i < cmd.params.length; i++) {
                String value = Config.get().getString(cmd.params[i]);
                msgln(String.format("%1$-" + maxLen + "s", cmd.params[i]) + " => "
                        + (value == null ? "<null>" : value));
            }
        }

    } catch (Throwable e) {
        processErrorAndExit(e);
    }
}

From source file:org.apache.commons.net.examples.Main.java

/**
 * Helper application for example classes.
 * Lists available classes, and provides shorthand invocation.
 * For example:<br>/*from  w  w w. java 2  s.c o  m*/
 * <code>java -jar commons-net-examples-m.n.jar FTPClientExample -l host user password</code>
 *
 * @param args the first argument is used to name the class; remaining arguments
 * are passed to the target class.
 * @throws Throwable if an error occurs
 */
public static void main(String[] args) throws Throwable {
    final Properties fp = new Properties();
    final InputStream ras = Main.class.getResourceAsStream("examples.properties");
    if (ras != null) {
        fp.load(ras);
    } else {
        System.err.println("[Cannot find examples.properties file, so aliases cannot be used]");
    }
    if (args.length == 0) {
        if (Thread.currentThread().getStackTrace().length > 2) { // called by Maven
            System.out.println("Usage: mvn -q exec:java  -Dexec.arguments=<alias or"
                    + " exampleClass>,<exampleClass parameters> (comma-separated, no spaces)");
            System.out.println("Or   : mvn -q exec:java  -Dexec.args=\"<alias"
                    + " or exampleClass> <exampleClass parameters>\" (space separated)");
        } else {
            if (fromJar()) {
                System.out.println(
                        "Usage: java -jar commons-net-examples-m.n.jar <alias or exampleClass> <exampleClass parameters>");
            } else {
                System.out.println(
                        "Usage: java -cp target/classes examples/Main <alias or exampleClass> <exampleClass parameters>");
            }
        }
        @SuppressWarnings("unchecked") // property names are Strings
        List<String> l = (List<String>) Collections.list(fp.propertyNames());
        if (l.isEmpty()) {
            return;
        }
        Collections.sort(l);
        System.out.println("\nAliases and their classes:");
        for (String s : l) {
            System.out.printf("%-25s %s%n", s, fp.getProperty(s));
        }
        return;
    }

    String shortName = args[0];
    String fullName = fp.getProperty(shortName);
    if (fullName == null) {
        fullName = shortName;
    }
    fullName = fullName.replace('/', '.');
    try {
        Class<?> clazz = Class.forName(fullName);
        Method m = clazz.getDeclaredMethod("main", new Class[] { args.getClass() });
        String[] args2 = new String[args.length - 1];
        System.arraycopy(args, 1, args2, 0, args2.length);
        try {
            m.invoke(null, (Object) args2);
        } catch (InvocationTargetException ite) {
            Throwable cause = ite.getCause();
            if (cause != null) {
                throw cause;
            } else {
                throw ite;
            }
        }
    } catch (ClassNotFoundException e) {
        System.out.println(e);
    }
}

From source file:com.bluexml.tools.miscellaneous.PrepareSIDEModulesMigration.java

/**
 * @param args//  www . j  a  v a  2  s. c  o m
 */
public static void main(String[] args) {
    boolean inplace = false;

    String workspace = "/Users/davidabad/workspaces/SIDE-Modules/";
    String frameworkmodulesPath = "/Volumes/Data/SVN/side/HEAD/S-IDE/FrameworksModules/trunk/";
    String classifier_base = "enterprise";
    String version_base = "3.4.6";
    String classifier_target = "enterprise";
    String version_target = "3.4.11";
    String frameworkmodulesInplace = "/Volumes/Data/SVN/projects/Ifremer/IfremerV5/src/modules/mavenProjects";

    Properties props = new Properties();
    try {
        InputStream resourceAsStream = PrepareSIDEModulesMigration.class
                .getResourceAsStream("config.properties");
        if (resourceAsStream != null) {
            props.load(resourceAsStream);

            inplace = Boolean.parseBoolean(props.getProperty("inplace", Boolean.toString(inplace)));
            workspace = props.getProperty("workspace", workspace);
            frameworkmodulesPath = props.getProperty("frameworkmodulesPath", frameworkmodulesPath);
            classifier_base = props.getProperty("classifier_base", classifier_base);
            version_base = props.getProperty("version_base", version_base);
            classifier_target = props.getProperty("classifier_target", classifier_target);
            version_target = props.getProperty("version_target", version_target);
            frameworkmodulesInplace = props.getProperty("frameworkmodulesInplace", frameworkmodulesInplace);
        } else {
            System.out.println("no configuration founded in classpath config.properties");
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return;
    }

    System.out.println("properties :");
    Enumeration<?> propertyNames = props.propertyNames();
    while (propertyNames.hasMoreElements()) {
        String nextElement = propertyNames.nextElement().toString();
        System.out.println("\t " + nextElement + " : " + props.getProperty(nextElement));
    }

    File workspaceFile = new File(workspace);

    File targetHome = new File(workspaceFile, MIGRATION_FOLDER);
    if (targetHome.exists()) {
        try {
            FileUtils.deleteDirectory(targetHome);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    final String versionInProjectName = getVersionInProjectName(classifier_base, version_base);
    String versionInProjectName2 = getVersionInProjectName(classifier_target, version_target);

    if (frameworkmodulesPath.contains(",")) {
        // this is a list of paths
        String[] split = frameworkmodulesPath.split(",");
        for (String string : split) {
            if (StringUtils.trimToNull(string) != null) {
                executeInpath(inplace, string, classifier_base, version_base, classifier_target, version_target,
                        frameworkmodulesInplace, workspaceFile, versionInProjectName, versionInProjectName2);
            }
        }
    } else {
        executeInpath(inplace, frameworkmodulesPath, classifier_base, version_base, classifier_target,
                version_target, frameworkmodulesInplace, workspaceFile, versionInProjectName,
                versionInProjectName2);
    }

    System.out.println("Job's done !");
    System.out.println("Please check " + MIGRATION_FOLDER);
    System.out.println(
            "If all is ok you can use commit.sh in a terminal do : cd " + MIGRATION_FOLDER + "; sh commit.sh");
    System.out.println(
            "This script will create new svn projet and commit resources, add 'target' to svn:ignore ...");

}

From source file:org.timconrad.vmstats.Main.java

public static void main(String[] args) {

    Logger logger = LoggerFactory.getLogger(Main.class);
    Properties config = new Properties();
    Boolean showPerfMgr = false;/*from ww w.  ja v  a2s . c  om*/
    Boolean showEstimate = false;
    Boolean noThreads = false;
    Boolean noGraphite = false;

    File configFile = new File("vmstats.properties");

    Hashtable<String, String> appConfig = new Hashtable<String, String>();

    CommandLineParser parser = new PosixParser();
    Options options = new Options();

    options.addOption("P", "perfMgr", false, "Display Performance Manager Counters and exit");
    options.addOption("E", "estimate", false, "Estimate the # of counters written to graphite and exit");
    options.addOption("N", "noThreads", false,
            "Don't start any threads, just run the main part (helpful for troubleshooting initial issues");
    options.addOption("g", "noGraphite", false, "Don't send anything to graphite");
    options.addOption("c", "configFile", true,
            "Configuration file for vmstats - defaults to 'vmstats.properties' in the .jar directory");
    options.addOption("O", "runOnce", false, "Run the stats gatherer one time - useful for debugging");
    options.addOption("D", "debugOutput", false, "Dump the output to a thread-named file.");
    options.addOption("h", "help", false, "show help");

    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption("help")) {
            System.out.println("vmstats.jar -Dlog4j.configuration=file:/path/to/log4j.properties [options]");
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("vmstats.jar", options);
            System.exit(0);
        }
        if (line.hasOption("perfMgr")) {
            showPerfMgr = true;
        }
        if (line.hasOption("estimate")) {
            showEstimate = true;
        }
        if (line.hasOption("noThreads")) {
            noThreads = true;
        }
        if (line.hasOption("noGraphite")) {
            noGraphite = true;
        }
        if (line.hasOption("runOnce")) {
            appConfig.put("runOnce", "true");

        } else {
            appConfig.put("runOnce", "false");
        }
        if (line.hasOption("debugOutput")) {
            appConfig.put("debugOutput", "true");
        } else {
            appConfig.put("debugOutput", "false");
        }

        if (line.hasOption("configFile")) {
            // if the user adds a custom config flag, use it. Otherwise they'll get the default.
            String file = line.getOptionValue("configFile");
            File optFile = new File(file);
            boolean exists = optFile.exists();
            // check to make sure the file exists.
            if (!exists) {
                System.out.println("The configuration file doesn't seem to exist in path: " + file);
                System.exit(0);
            } else {
                configFile = optFile;
            }

        }
    } catch (org.apache.commons.cli.ParseException e) {
        System.out.println("CLI options exception: " + e.getMessage());
        e.printStackTrace();
    }

    try {
        config.load(new FileInputStream(configFile));
    } catch (FileNotFoundException e) {
        logger.info("Configuration file not found!\n\tException: " + e);
        System.exit(-1);
    } catch (IOException e) {
        logger.info("Configuration file not found!\n\tException: " + e);
        System.exit(-1);
    }

    Enumeration configOpts = config.propertyNames();
    // this will have to be manually updated.
    String[] expectedOptions = { "VCS_TAG", "VCS_USER", "GRAPHITE_PORT", "GRAPHITE_TAG", "VCS_HOST", "VCS_PASS",
            "MAX_VMSTAT_THREADS", "GRAPHITE_HOST", "ESX_STATS", "USE_FQDN", "SLEEP_TIME", "SEND_ALL_ABSOLUTE",
            "SEND_ALL_DELTA", "SEND_ALL_PERIODS" };
    ArrayList<String> matchedOptions = new ArrayList<String>();
    while (configOpts.hasMoreElements()) {
        String optTmp = (String) configOpts.nextElement();
        for (int i = 0; i < expectedOptions.length; i++) {
            if (optTmp.equals(expectedOptions[i])) {
                matchedOptions.add(optTmp);
            }
        }
    }

    if (expectedOptions.length != matchedOptions.size()) {
        // this kinda blows, but better than throwing a null pointer exception
        // or doing try/catch for each possible option below.
        System.out.println("Configuration file options are missing");
        System.exit(-1);
    }

    // Get settings from config file
    String vcsHostRaw = config.getProperty("VCS_HOST");
    String vcsUser = config.getProperty("VCS_USER");
    String vcsPass = config.getProperty("VCS_PASS");
    String vcsTag = config.getProperty("VCS_TAG");
    String vcsFilter = config.getProperty("FILTERFILE");

    if (vcsFilter != null) {
        String filterfile = vcsFilter;
        File FilterFile = new File(filterfile);
        List<String> FilterList = null;
        try {
            FilterList = FileUtils.readLines(FilterFile);
        } catch (IOException e) {
            e.printStackTrace();
        }

        FilterArrays = FilterList.toArray(new String[] {});
    }

    appConfig.put("vcsTag", vcsTag);
    // vcs information
    // this needs to be https://host/sdk
    String vcsHost = "https://" + vcsHostRaw + "/sdk";
    String graphEsx = config.getProperty("ESX_STATS");
    appConfig.put("USE_FQDN", config.getProperty("USE_FQDN"));
    appConfig.put("graphEsx", graphEsx);

    // graphite information
    String graphiteHost = config.getProperty("GRAPHITE_HOST");
    int graphitePort = Integer.parseInt(config.getProperty("GRAPHITE_PORT"));
    String graphiteTag = config.getProperty("GRAPHITE_TAG");

    try {
        appConfig.put("graphiteTag", graphiteTag);
    } catch (NullPointerException e) {
        System.out.println("Issue with configuration file - Missing GRAPHITE_TAG");
        System.exit(-1);
    }

    // TODO: make this dynamic. maybe.
    int MAX_VMSTAT_THREADS = Integer.parseInt(config.getProperty("MAX_VMSTAT_THREADS"));
    int MAX_ESXSTAT_THREADS = Integer.parseInt(config.getProperty("MAX_ESXSTAT_THREADS"));
    int MAX_GRAPHITE_THREADS = Integer.parseInt(config.getProperty("MAX_GRAPHITE_THREADS"));

    appConfig.put("MAX_VMSTAT_THREADS", String.valueOf(MAX_VMSTAT_THREADS));
    appConfig.put("MAX_ESXSTAT_THREADS", String.valueOf(MAX_ESXSTAT_THREADS));
    String SLEEP_TIME = config.getProperty("SLEEP_TIME");
    appConfig.put("SLEEP_TIME", SLEEP_TIME);
    String SEND_ALL_PERIODS = config.getProperty("SEND_ALL_PERIODS");
    appConfig.put("SEND_ALL_PERIODS", SEND_ALL_PERIODS);
    int sleep_time = Integer.parseInt(SLEEP_TIME);
    if ((sleep_time % 20) == 0) {
        int periods = sleep_time / 20;
        appConfig.put("PERIODS", String.valueOf(periods));
    } else {
        System.out.println("SLEEP_TIME needs to be divisible by 20, please fix");
        System.exit(-1);
    }
    appConfig.put("SEND_ALL_ABSOLUTE", config.getProperty("SEND_ALL_ABSOLUTE"));
    appConfig.put("SEND_ALL_DELTA", config.getProperty("SEND_ALL_DELTA"));

    // Build internal data structures. 

    // use a hashtable to store performance id information
    Hashtable<String, Hashtable<String, String>> perfKeys = new Hashtable<String, Hashtable<String, String>>();
    // BlockingQueue to store managed objects - basically anything that vmware knows about
    BlockingQueue<Object> vm_mob_queue = new ArrayBlockingQueue<Object>(10000);
    BlockingQueue<Object> esx_mob_queue = new ArrayBlockingQueue<Object>(10000);
    // BlockingQueue to store arrays of stats - each managed object generates a bunch of strings that are stored in
    BlockingQueue<Object> sender = new ArrayBlockingQueue<Object>(60000);

    // Initialize these vmware types as nulls so we can see if things work properly
    ServiceInstance si = null;
    PerformanceManager perfMgr = null;

    try {
        // TODO: this doesn't handle some ASCII characters well, not sure why.
        si = new ServiceInstance(new URL(vcsHost), vcsUser, vcsPass, true);
    } catch (InvalidLogin e) {
        logger.info("Invalid login vCenter: " + vcsHost + " User: " + vcsUser);
        System.exit(-1);
    } catch (RemoteException e) {
        logger.info("Remote exception: " + e);
        e.printStackTrace();
    } catch (MalformedURLException e) {
        logger.info("MalformedURLexception: " + e);
        e.printStackTrace();
    }

    if (si != null) {

        perfMgr = si.getPerformanceManager();
        PerfCounterInfo[] counters = perfMgr.getPerfCounter();
        // build a hash lookup to turn the counter 23 into 'disk.this.that.the.other'
        // These are not sequential.
        for (int i = 0; i < counters.length; i++) {
            // create a temp hash to push onto the big hash
            Hashtable<String, String> temp_hash = new Hashtable<String, String>();
            String path = counters[i].getGroupInfo().getKey() + "." + counters[i].getNameInfo().getKey();
            // this is a key like cpu.run.0.summation
            temp_hash.put("key", path);
            // one of average, latest, maximum, minimum, none,  summation
            temp_hash.put("rollup", counters[i].getRollupType().toString());
            // one of absolute, delta, rate
            temp_hash.put("statstype", counters[i].getStatsType().toString());
            // it's important to understand that the counters aren't sequential, so they have their own id.
            perfKeys.put("" + counters[i].getKey(), temp_hash);
        }
    } else {
        logger.info("Issues with the service instance that wasn't properly handled");
        System.exit(-1);
    }

    if (showPerfMgr) {
        // show the performance keys that are available to the user
        System.out.println("Showing Performance Counter Entities available:");
        System.out.println("Read the following link for more information:");
        System.out.println(
                "http://vijava.sourceforge.net/vSphereAPIDoc/ver5/ReferenceGuide/vim.PerformanceManager.html");
        Enumeration<String> keys = perfKeys.keys();
        System.out.println("ID|Tag|Rollup");
        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            System.out
                    .println(key + "|" + perfKeys.get(key).get("key") + "|" + perfKeys.get(key).get("rollup"));
        }
        System.exit(0);
    }

    if (showEstimate) {
        // estimate the number of keys that will be updated/written to Graphite per minute
        System.out.println("Currently Disabled");
    }

    // this gets the lists of vm's from vCenter
    if (!noThreads) {
        if (si != null && perfMgr != null) {
            logger.info("ServiceInstance: " + si);
            logger.info("PerformanceManager: " + perfMgr);

            meGrabber me_grabber = new meGrabber(si, vm_mob_queue, esx_mob_queue, appConfig, sender);
            ExecutorService grab_exe = Executors.newCachedThreadPool();
            grab_exe.execute(me_grabber);

            // it's easier sometimes to debug things without stats being sent to graphite. make noGraphite = true; to 
            // change this.
            if (!noGraphite) {
                for (int i = 1; i <= MAX_GRAPHITE_THREADS; i++) {
                    GraphiteWriter graphite = new GraphiteWriter(graphiteHost, graphitePort, sender, appConfig);
                    ExecutorService graph_exe = Executors.newCachedThreadPool();
                    graph_exe.execute(graphite);
                }
            } else {
                System.out.println("Graphite output has been disabled via the -g flag.");
            }

            for (int i = 1; i <= MAX_VMSTAT_THREADS; i++) {
                statsGrabber vm_stats_grabber = new statsGrabber(perfMgr, perfKeys, vm_mob_queue, sender,
                        appConfig, "vm", FilterArrays);
                ExecutorService vm_stat_exe = Executors.newCachedThreadPool();
                vm_stat_exe.execute(vm_stats_grabber);
            }

            if (graphEsx.contains("true")) {
                for (int i = 1; i <= MAX_ESXSTAT_THREADS; i++) {
                    statsGrabber esx_stats_grabber = new statsGrabber(perfMgr, perfKeys, esx_mob_queue, sender,
                            appConfig, "ESX", FilterArrays);
                    ExecutorService esx_stat_exe = Executors.newCachedThreadPool();
                    esx_stat_exe.execute(esx_stats_grabber);
                }
            }

        } else {
            logger.info("Either ServiceInstance or PerformanceManager is null, bailing.");
        }
    } else {
        System.out.println("Not running any of the main threads");
        System.exit(0);
    }
}

From source file:Main.java

public static String replaceSystemProps(String xml) {
    Properties properties = System.getProperties();
    Enumeration e = properties.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String s = "${" + key + "}";
        if (xml.contains(s)) {
            xml = xml.replace(s, properties.getProperty(key));
        }/*from  w ww.j a  va  2  s .  c o  m*/

    }
    return xml;
}