Java Code Examples for javax.management.ImmutableDescriptor#union()

The following examples show how to use javax.management.ImmutableDescriptor#union() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private static void check(Object x, Descriptor d, Descriptor expect) {
    String fail = null;
    try {
        Descriptor u = ImmutableDescriptor.union(d, expect);
        if (!u.equals(d))
            fail = "should contain " + expect + "; is " + d;
    } catch (IllegalArgumentException e) {
        fail = e.getMessage();
    }
    if (fail == null) {
        System.out.println("OK: " + x);
    } else {
        failed = "NOT OK: Incorrect descriptor for: " + x;
        System.out.println(failed);
        System.out.println("..." + fail);
    }
}
 
Example 2
Source File: AnnotationTest.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private static void check(Object x, Descriptor d, Descriptor expect) {
    String fail = null;
    try {
        Descriptor u = ImmutableDescriptor.union(d, expect);
        if (!u.equals(d))
            fail = "should contain " + expect + "; is " + d;
    } catch (IllegalArgumentException e) {
        fail = e.getMessage();
    }
    if (fail == null) {
        System.out.println("OK: " + x);
    } else {
        failed = "NOT OK: Incorrect descriptor for: " + x;
        System.out.println(failed);
        System.out.println("..." + fail);
    }
}
 
Example 3
Source File: AnnotationTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void check(Object x, Descriptor d, Descriptor expect) {
    String fail = null;
    try {
        Descriptor u = ImmutableDescriptor.union(d, expect);
        if (!u.equals(d))
            fail = "should contain " + expect + "; is " + d;
    } catch (IllegalArgumentException e) {
        fail = e.getMessage();
    }
    if (fail == null) {
        System.out.println("OK: " + x);
    } else {
        failed = "NOT OK: Incorrect descriptor for: " + x;
        System.out.println(failed);
        System.out.println("..." + fail);
    }
}
 
Example 4
Source File: AnnotationTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private static void check(Object x, Descriptor d, Descriptor expect) {
    String fail = null;
    try {
        Descriptor u = ImmutableDescriptor.union(d, expect);
        if (!u.equals(d))
            fail = "should contain " + expect + "; is " + d;
    } catch (IllegalArgumentException e) {
        fail = e.getMessage();
    }
    if (fail == null) {
        System.out.println("OK: " + x);
    } else {
        failed = "NOT OK: Incorrect descriptor for: " + x;
        System.out.println(failed);
        System.out.println("..." + fail);
    }
}
 
Example 5
Source File: OpenMBeanParameterInfoSupport.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Constructs an {@code OpenMBeanParameterInfoSupport} instance,
 * which describes the parameter used in one or more operations or
 * constructors of a class of open MBeans, with the specified
 * {@code name}, {@code openType}, {@code description},
 * and {@code descriptor}.
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param descriptor The descriptor for the parameter.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package
 * description</a>.
 *
 * @since 1.6
 */
public OpenMBeanParameterInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     Descriptor descriptor) {


    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          ImmutableDescriptor.union(descriptor,(openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 6
Source File: OpenMBeanParameterInfoSupport.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs an {@code OpenMBeanParameterInfoSupport} instance,
 * which describes the parameter used in one or more operations or
 * constructors of a class of open MBeans, with the specified
 * {@code name}, {@code openType}, {@code description},
 * and {@code descriptor}.
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param descriptor The descriptor for the parameter.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package
 * description</a>.
 *
 * @since 1.6
 */
public OpenMBeanParameterInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     Descriptor descriptor) {


    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          ImmutableDescriptor.union(descriptor,(openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 7
Source File: OpenMBeanParameterInfoSupport.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an {@code OpenMBeanParameterInfoSupport} instance,
 * which describes the parameter used in one or more operations or
 * constructors of a class of open MBeans, with the specified
 * {@code name}, {@code openType}, {@code description},
 * and {@code descriptor}.
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param descriptor The descriptor for the parameter.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package
 * description</a>.
 *
 * @since 1.6
 */
public OpenMBeanParameterInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     Descriptor descriptor) {


    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          ImmutableDescriptor.union(descriptor,(openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 8
Source File: OpenMBeanParameterInfoSupport.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs an {@code OpenMBeanParameterInfoSupport} instance,
 * which describes the parameter used in one or more operations or
 * constructors of a class of open MBeans, with the specified
 * {@code name}, {@code openType}, {@code description},
 * and {@code descriptor}.
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param descriptor The descriptor for the parameter.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package
 * description</a>.
 *
 * @since 1.6
 */
public OpenMBeanParameterInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     Descriptor descriptor) {


    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          ImmutableDescriptor.union(descriptor,(openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 9
Source File: OpenMBeanOperationInfoSupport.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 10
Source File: OpenMBeanOperationInfoSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 11
Source File: OpenMBeanOperationInfoSupport.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 12
Source File: OpenMBeanOperationInfoSupport.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 13
Source File: OpenMBeanOperationInfoSupport.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 14
Source File: OpenMBeanOperationInfoSupport.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 15
Source File: OpenMBeanOperationInfoSupport.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanOperationInfoSupport}
 * instance, which describes the operation of a class of open
 * MBeans, with the specified {@code name}, {@code description},
 * {@code signature}, {@code returnOpenType}, {@code
 * impact}, and {@code descriptor}.</p>
 *
 * <p>The {@code signature} array parameter is internally copied,
 * so that subsequent changes to the array referenced by {@code
 * signature} have no effect on this instance.</p>
 *
 * @param name cannot be a null or empty string.
 *
 * @param description cannot be a null or empty string.
 *
 * @param signature can be null or empty if there are no
 * parameters to describe.
 *
 * @param returnOpenType cannot be null: use {@code
 * SimpleType.VOID} for operations that return nothing.
 *
 * @param impact must be one of {@code ACTION}, {@code
 * ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @param descriptor The descriptor for the operation.  This may
 * be null, which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code
 * returnOpenType} is null, or {@code impact} is not one of {@code
 * ACTION}, {@code ACTION_INFO}, {@code INFO}, or {@code UNKNOWN}.
 *
 * @throws ArrayStoreException If {@code signature} is not an
 * array of instances of a subclass of {@code MBeanParameterInfo}.
 *
 * @since 1.6
 */
public OpenMBeanOperationInfoSupport(String name,
                                     String description,
                                     OpenMBeanParameterInfo[] signature,
                                     OpenType<?> returnOpenType,
                                     int impact,
                                     Descriptor descriptor) {
    super(name,
          description,
          arrayCopyCast(signature),
          // must prevent NPE here - we will throw IAE later on if
          // returnOpenType is null
          (returnOpenType == null) ? null : returnOpenType.getClassName(),
          impact,
          ImmutableDescriptor.union(descriptor,
            // must prevent NPE here - we will throw IAE later on if
            // returnOpenType is null
            (returnOpenType==null) ? null :returnOpenType.getDescriptor()));

    // check parameters that should not be null or empty
    // (unfortunately it is not done in superclass :-( ! )
    //
    if (name == null || name.trim().equals("")) {
        throw new IllegalArgumentException("Argument name cannot " +
                                           "be null or empty");
    }
    if (description == null || description.trim().equals("")) {
        throw new IllegalArgumentException("Argument description cannot " +
                                           "be null or empty");
    }
    if (returnOpenType == null) {
        throw new IllegalArgumentException("Argument returnOpenType " +
                                           "cannot be null");
    }

    if (impact != ACTION && impact != ACTION_INFO && impact != INFO &&
            impact != UNKNOWN) {
        throw new IllegalArgumentException("Argument impact can only be " +
                                           "one of ACTION, ACTION_INFO, " +
                                           "INFO, or UNKNOWN: " + impact);
    }

    this.returnOpenType = returnOpenType;
}
 
Example 16
Source File: OpenMBeanAttributeInfoSupport.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanAttributeInfoSupport} instance,
 * which describes the attribute of an open MBean with the
 * specified {@code name}, {@code openType}, {@code
 * description}, read/write access properties, and {@code Descriptor}.</p>
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param isReadable {@code true} if the attribute has a getter
 * exposed for management.
 *
 * @param isWritable {@code true} if the attribute has a setter
 * exposed for management.
 *
 * @param isIs {@code true} if the attribute's getter is of the
 * form <tt>is<i>XXX</i></tt>.
 *
 * @param descriptor The descriptor for the attribute.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package description</a>.
 *
 * @since 1.6
 */
public OpenMBeanAttributeInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     boolean isReadable,
                                     boolean isWritable,
                                     boolean isIs,
                                     Descriptor descriptor) {
    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          isReadable,
          isWritable,
          isIs,
          ImmutableDescriptor.union(descriptor, (openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 17
Source File: OpenMBeanAttributeInfoSupport.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanAttributeInfoSupport} instance,
 * which describes the attribute of an open MBean with the
 * specified {@code name}, {@code openType}, {@code
 * description}, read/write access properties, and {@code Descriptor}.</p>
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param isReadable {@code true} if the attribute has a getter
 * exposed for management.
 *
 * @param isWritable {@code true} if the attribute has a setter
 * exposed for management.
 *
 * @param isIs {@code true} if the attribute's getter is of the
 * form <tt>is<i>XXX</i></tt>.
 *
 * @param descriptor The descriptor for the attribute.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package description</a>.
 *
 * @since 1.6
 */
public OpenMBeanAttributeInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     boolean isReadable,
                                     boolean isWritable,
                                     boolean isIs,
                                     Descriptor descriptor) {
    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          isReadable,
          isWritable,
          isIs,
          ImmutableDescriptor.union(descriptor, (openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 18
Source File: OpenMBeanAttributeInfoSupport.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanAttributeInfoSupport} instance,
 * which describes the attribute of an open MBean with the
 * specified {@code name}, {@code openType}, {@code
 * description}, read/write access properties, and {@code Descriptor}.</p>
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param isReadable {@code true} if the attribute has a getter
 * exposed for management.
 *
 * @param isWritable {@code true} if the attribute has a setter
 * exposed for management.
 *
 * @param isIs {@code true} if the attribute's getter is of the
 * form <tt>is<i>XXX</i></tt>.
 *
 * @param descriptor The descriptor for the attribute.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package description</a>.
 *
 * @since 1.6
 */
public OpenMBeanAttributeInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     boolean isReadable,
                                     boolean isWritable,
                                     boolean isIs,
                                     Descriptor descriptor) {
    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          isReadable,
          isWritable,
          isIs,
          ImmutableDescriptor.union(descriptor, (openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 19
Source File: OpenMBeanAttributeInfoSupport.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanAttributeInfoSupport} instance,
 * which describes the attribute of an open MBean with the
 * specified {@code name}, {@code openType}, {@code
 * description}, read/write access properties, and {@code Descriptor}.</p>
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param isReadable {@code true} if the attribute has a getter
 * exposed for management.
 *
 * @param isWritable {@code true} if the attribute has a setter
 * exposed for management.
 *
 * @param isIs {@code true} if the attribute's getter is of the
 * form <tt>is<i>XXX</i></tt>.
 *
 * @param descriptor The descriptor for the attribute.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package description</a>.
 *
 * @since 1.6
 */
public OpenMBeanAttributeInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     boolean isReadable,
                                     boolean isWritable,
                                     boolean isIs,
                                     Descriptor descriptor) {
    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          isReadable,
          isWritable,
          isIs,
          ImmutableDescriptor.union(descriptor, (openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}
 
Example 20
Source File: OpenMBeanAttributeInfoSupport.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * <p>Constructs an {@code OpenMBeanAttributeInfoSupport} instance,
 * which describes the attribute of an open MBean with the
 * specified {@code name}, {@code openType}, {@code
 * description}, read/write access properties, and {@code Descriptor}.</p>
 *
 * <p>The {@code descriptor} can contain entries that will define
 * the values returned by certain methods of this class, as
 * explained in the <a href="package-summary.html#constraints">
 * package description</a>.
 *
 * @param name  cannot be a null or empty string.
 *
 * @param description  cannot be a null or empty string.
 *
 * @param openType  cannot be null.
 *
 * @param isReadable {@code true} if the attribute has a getter
 * exposed for management.
 *
 * @param isWritable {@code true} if the attribute has a setter
 * exposed for management.
 *
 * @param isIs {@code true} if the attribute's getter is of the
 * form <tt>is<i>XXX</i></tt>.
 *
 * @param descriptor The descriptor for the attribute.  This may be null
 * which is equivalent to an empty descriptor.
 *
 * @throws IllegalArgumentException if {@code name} or {@code
 * description} are null or empty string, or {@code openType} is
 * null, or the descriptor entries are invalid as described in the
 * <a href="package-summary.html#constraints">package description</a>.
 *
 * @since 1.6
 */
public OpenMBeanAttributeInfoSupport(String name,
                                     String description,
                                     OpenType<?> openType,
                                     boolean isReadable,
                                     boolean isWritable,
                                     boolean isIs,
                                     Descriptor descriptor) {
    // Construct parent's state
    //
    super(name,
          (openType==null) ? null : openType.getClassName(),
          description,
          isReadable,
          isWritable,
          isIs,
          ImmutableDescriptor.union(descriptor, (openType==null)?null:
            openType.getDescriptor()));

    // Initialize this instance's specific state
    //
    this.openType = openType;

    descriptor = getDescriptor();  // replace null by empty
    this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
    this.legalValues = valuesFrom(descriptor, "legalValues", openType);
    this.minValue = comparableValueFrom(descriptor, "minValue", openType);
    this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);

    try {
        check(this);
    } catch (OpenDataException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
    }
}