alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  
* <td>java.lang.String * </tr> * <tr> * <td>value * <td>java.lang.String * </tr> * <tr> * <td>origin * <td>java.lang.String * </tr> * <tr> * <td>writeable * <td>java.lang.Boolean * </tr> * </table> * </blockquote> * * @param cd <tt>CompositeData representing a VMOption * * @throws IllegalArgumentException if <tt>cd does not * represent a <tt>VMOption with the attributes described * above. * * @return a <tt>VMOption object represented by cd * if <tt>cd is not null; * <tt>null otherwise. */ public static VMOption from(CompositeData cd) { if (cd == null) { return null; } if (cd instanceof VMOptionCompositeData) { return ((VMOptionCompositeData) cd).getVMOption(); } else { return new VMOption(cd); } } }

Other Java examples (source code examples)

Here is a short list of links related to this Java VMOption.java source code file:

Java example source code file (VMOption.java)

This example Java source code file (VMOption.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

config_file, default, environ_var, ergonomic, management, origin, other, string, vm_creation, vmoption, vmoptioncompositedata

The VMOption.java Java example source code

/*
 * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

package com.sun.management;

import sun.management.VMOptionCompositeData;
import javax.management.openmbean.CompositeData;

/**
 * Information about a VM option including its value and
 * where the value came from which is referred as its
 * {@link VMOption.Origin <i>origin}.
 * <p>
 * Each VM option has a default value.  A VM option can
 * be set at VM creation time typically as a command line
 * argument to the launcher or an argument passed to the
 * VM created using the JNI invocation interface.
 * In addition, a VM option may be set via an environment
 * variable or a configuration file. A VM option can also
 * be set dynamically via a management interface after
 * the VM was started.
 *
 * A <tt>VMOption contains the value of a VM option
 * and the origin of that value at the time this <tt>VMOption
 * object was constructed.  The value of the VM option
 * may be changed after the <tt>VMOption object was constructed,
 *
 * @see <a href="{@docRoot}/../../../../technotes/guides/vm/index.html">
 *         Java Virtual Machine</a>
 * @author Mandy Chung
 * @since 1.6
 */
@jdk.Exported
public class VMOption {
    private String name;
    private String value;
    private boolean writeable;
    private Origin origin;

    /**
     * Origin of the value of a VM option.  It tells where the
     * value of a VM option came from.
     *
     * @since 1.6
     */
    @jdk.Exported
    public enum Origin {
        /**
         * The VM option has not been set and its value
         * is the default value.
         */
        DEFAULT,
        /**
         * The VM option was set at VM creation time typically
         * as a command line argument to the launcher or
         * an argument passed to the VM created using the
         * JNI invocation interface.
         */
        VM_CREATION,
        /**
         * The VM option was set via an environment variable.
         */
        ENVIRON_VAR,
        /**
         * The VM option was set via a configuration file.
         */
        CONFIG_FILE,
        /**
         * The VM option was set via the management interface after the VM
         * was started.
         */
        MANAGEMENT,
        /**
         * The VM option was set via the VM ergonomic support.
         */
        ERGONOMIC,
        /**
         * The VM option was set via some other mechanism.
         */
        OTHER
    }

    /**
     * Constructs a <tt>VMOption.
     *
     * @param name Name of a VM option.
     * @param value Value of a VM option.
     * @param writeable <tt>true if a VM option can be set dynamically,
     *                  or <tt>false otherwise.
     * @param origin where the value of a VM option came from.
     *
     * @throws NullPointerException if the name or value is <tt>null
     */
    public VMOption(String name, String value, boolean writeable, Origin origin) {
        this.name = name;
        this.value = value;
        this.writeable = writeable;
        this.origin = origin;
    }

    /**
     * Constructs a <tt>VMOption object from a
     * {@link CompositeData CompositeData}.
     */
    private VMOption(CompositeData cd) {
        // validate the input composite data
        VMOptionCompositeData.validateCompositeData(cd);

        this.name = VMOptionCompositeData.getName(cd);
        this.value = VMOptionCompositeData.getValue(cd);
        this.writeable = VMOptionCompositeData.isWriteable(cd);
        this.origin = VMOptionCompositeData.getOrigin(cd);
    }

    /**
     * Returns the name of this VM option.
     *
     * @return the name of this VM option.
     */
    public String getName() {
        return name;
    }

    /**
     * Returns the value of this VM option at the time when
     * this <tt>VMOption was created. The value could have been changed.
     *
     * @return the value of the VM option at the time when
     *         this <tt>VMOption was created.
     */
    public String getValue() {
        return value;
    }

    /**
     * Returns the origin of the value of this VM option. That is,
     * where the value of this VM option came from.
     *
     * @return where the value of this VM option came from.
     */
    public Origin getOrigin() {
        return origin;
    }

    /**
     * Tests if this VM option is writeable.  If this VM option is writeable,
     * it can be set by the {@link HotSpotDiagnosticMXBean#setVMOption
     * HotSpotDiagnosticMXBean.setVMOption} method.
     *
     * @return <tt>true if this VM option is writeable; false
     * otherwise.
     */
    public boolean isWriteable() {
        return writeable;
    }

    public String toString() {
        return "VM option: " + getName() +
               " value: " + value + " " +
               " origin: " + origin + " " +
               (writeable ? "(read-write)" : "(read-only)");
    }

    /**
     * Returns a <tt>VMOption object represented by the
     * given <tt>CompositeData. The given CompositeData
     * must contain the following attributes:
     * <p>
     * <blockquote>
     * <table border>
     * <tr>
     *   <th align=left>Attribute Name
     *   <th align=left>Type
     * </tr>
     * <tr>
     *   <td>name
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.