Example usage for org.apache.commons.lang SystemUtils JAVA_VENDOR_URL

List of usage examples for org.apache.commons.lang SystemUtils JAVA_VENDOR_URL

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils JAVA_VENDOR_URL.

Prototype

String JAVA_VENDOR_URL

To view the source code for org.apache.commons.lang SystemUtils JAVA_VENDOR_URL.

Click Source Link

Document

The java.vendor.url System Property.

Usage

From source file:org.apache.cocoon.generation.StatusGenerator.java

private void genVMStatus() throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    startGroup("VM");

    // BEGIN ClassPath
    String classpath = SystemUtils.JAVA_CLASS_PATH;
    if (classpath != null) {
        List paths = new ArrayList();
        StringTokenizer tokenizer = new StringTokenizer(classpath, SystemUtils.PATH_SEPARATOR);
        while (tokenizer.hasMoreTokens()) {
            paths.add(tokenizer.nextToken());
        }/* w w  w.j  av a 2  s.co  m*/
        addMultilineValue("classpath", paths);
    }
    // END ClassPath

    // BEGIN CONTEXT CLASSPATH
    String contextClassPath = null;
    try {
        contextClassPath = (String) this.context.get(Constants.CONTEXT_CLASSPATH);
    } catch (ContextException e) {
        // we ignore this
    }
    if (contextClassPath != null) {
        List paths = new ArrayList();
        StringTokenizer tokenizer = new StringTokenizer(contextClassPath, File.pathSeparator);
        while (tokenizer.hasMoreTokens()) {
            paths.add(tokenizer.nextToken());
        }
        addMultilineValue("context-classpath", paths);
    }
    // END CONTEXT CLASSPATH

    // BEGIN Memory status
    startGroup("Memory");
    final long totalMemory = Runtime.getRuntime().totalMemory();
    final long freeMemory = Runtime.getRuntime().freeMemory();
    addValue("total", String.valueOf(totalMemory));
    addValue("used", String.valueOf(totalMemory - freeMemory));
    addValue("free", String.valueOf(freeMemory));
    endGroup();
    // END Memory status

    // BEGIN JRE
    startGroup("JRE");
    addValue("version", SystemUtils.JAVA_VERSION);
    atts.clear();
    // qName = prefix + ':' + localName
    atts.addAttribute(XLINK_NS, "type", XLINK_PREFIX + ":type", "CDATA", "simple");
    atts.addAttribute(XLINK_NS, "href", XLINK_PREFIX + ":href", "CDATA", SystemUtils.JAVA_VENDOR_URL);
    addValue("java-vendor", SystemUtils.JAVA_VENDOR, atts);
    endGroup();
    // END JRE

    // BEGIN Operating system
    startGroup("Operating System");
    addValue("name", SystemUtils.OS_NAME);
    addValue("architecture", SystemUtils.OS_ARCH);
    addValue("version", SystemUtils.OS_VERSION);
    endGroup();
    // END operating system

    // BEGIN Cache
    if (this.storeJanitor != null) {
        startGroup("Store Janitor");

        // For each element in StoreJanitor
        Iterator i = this.storeJanitor.iterator();
        while (i.hasNext()) {
            Store store = (Store) i.next();
            startGroup(
                    store.getClass().getName() + " (hash = 0x" + Integer.toHexString(store.hashCode()) + ")");
            int size = 0;
            int empty = 0;
            atts.clear();
            atts.addAttribute(NAMESPACE, "name", "name", "CDATA", "cached");
            super.contentHandler.startElement(NAMESPACE, "value", "value", atts);

            atts.clear();
            Enumeration e = store.keys();
            while (e.hasMoreElements()) {
                size++;
                Object key = e.nextElement();
                Object val = store.get(key);
                String line;
                if (val == null) {
                    empty++;
                } else {
                    line = key + " (class: " + val.getClass().getName() + ")";
                    super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
                    super.contentHandler.characters(line.toCharArray(), 0, line.length());
                    super.contentHandler.endElement(NAMESPACE, "line", "line");
                }
            }
            if (size == 0) {
                super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
                String value = "[empty]";
                super.contentHandler.characters(value.toCharArray(), 0, value.length());
                super.contentHandler.endElement(NAMESPACE, "line", "line");
            }
            super.contentHandler.endElement(NAMESPACE, "value", "value");

            addValue("size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
            endGroup();
        }
        endGroup();
    }

    if (this.storePersistent != null) {
        startGroup(storePersistent.getClass().getName() + " (hash = 0x"
                + Integer.toHexString(storePersistent.hashCode()) + ")");
        int size = 0;
        int empty = 0;
        atts.clear();
        atts.addAttribute(NAMESPACE, "name", "name", "CDATA", "cached");
        super.contentHandler.startElement(NAMESPACE, "value", "value", atts);

        atts.clear();
        Enumeration e = this.storePersistent.keys();
        while (e.hasMoreElements()) {
            size++;
            Object key = e.nextElement();
            Object val = storePersistent.get(key);
            String line;
            if (val == null) {
                empty++;
            } else {
                line = key + " (class: " + val.getClass().getName() + ")";
                super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
                super.contentHandler.characters(line.toCharArray(), 0, line.length());
                super.contentHandler.endElement(NAMESPACE, "line", "line");
            }
        }
        if (size == 0) {
            super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
            String value = "[empty]";
            super.contentHandler.characters(value.toCharArray(), 0, value.length());
            super.contentHandler.endElement(NAMESPACE, "line", "line");
        }
        super.contentHandler.endElement(NAMESPACE, "value", "value");

        addValue("size", size + " items in cache (" + empty + " are empty)");
        endGroup();
    }
    // END Cache

    endGroup();
}