Package javax.management

Examples of javax.management.ImmutableDescriptor


     */
    // XXXX TODO: This is not very efficient!
    // Note: this Javadoc is copied from javax.management.Descriptor
    //       due to 6369229.
    public synchronized int hashCode() {
        return new ImmutableDescriptor(descriptorMap).hashCode();
    }
View Full Code Here


    private static MBeanNotificationInfo getNotificationInfo(final NotificationInfo n) {
        final String description = getDescription(n.description(), "-");
        return new MBeanNotificationInfo(n.types(),
            n.notificationClass().getName(), description,
            new ImmutableDescriptor(n.descriptorFields()));
    }
View Full Code Here

    private static MBeanNotificationInfo getNotificationInfo(final NotificationInfo n) {
        final String description = getDescription(n.description(), "-");
        return new MBeanNotificationInfo(n.types(),
            n.notificationClass().getName(), description,
            new ImmutableDescriptor(n.descriptorFields()));
    }
View Full Code Here

        // process all direct annotations
        for (Annotation annotation : computeWalkSequence(annotations)) {
            processAnnotation(annotation, fields);
        }

        return new ImmutableDescriptor(fields);
    }
View Full Code Here

import javax.management.RuntimeOperationsException;

public class ImmutableDescriptorSetFieldsTest {
    public static void main(String[] args) throws Exception {
        boolean ok = true;
        ImmutableDescriptor d = new ImmutableDescriptor("k=v");
        try {
            System.out.println(
                "Call ImmutableDescriptor.setFields(fieldNames,fieldValues) " +
                "with empty name in field names array");
            String fieldNames[] = { "a", "", "c" };
            Object fieldValues[] = { 1, 2, 3 };
            d.setFields(fieldNames, fieldValues);
            System.out.println("Didn't get expected exception");
            ok = false;
        } catch (RuntimeOperationsException e) {
            if (e.getCause() instanceof IllegalArgumentException) {
                System.out.println("Got expected exception:");
                ok = true;
            } else {
                System.out.println("Got unexpected exception:");
                ok = false;
            }
            e.printStackTrace(System.out);
        } catch (Exception e) {
            System.out.println("Got unexpected exception:");
            ok = false;
            e.printStackTrace(System.out);
        }
        try {
            System.out.println(
                "Call ImmutableDescriptor.setFields(fieldNames,fieldValues) " +
                "with null name in field names array");
            String fieldNames[] = { "a", null, "c" };
            Object fieldValues[] = { 1, 2, 3 };
            d.setFields(fieldNames, fieldValues);
            System.out.println("Didn't get expected exception");
            ok = false;
        } catch (RuntimeOperationsException e) {
            if (e.getCause() instanceof IllegalArgumentException) {
                System.out.println("Got expected exception:");
View Full Code Here

        }
        System.out.println("...OK");

        System.out.println("Test that serialization preserves case and " +
                "that deserialized object is case-insensitive");
        Descriptor d = new ImmutableDescriptor("a=aval", "B=Bval", "cC=cCval");
        Descriptor d1 = serialize(d);
        Set<String> keys = new HashSet(Arrays.asList(d1.getFieldNames()));
        if (keys.size() != 3 ||
                !keys.containsAll(Arrays.asList("a", "B", "cC"))) {
            throw new Exception("Keys don't match: " + keys);
        }
        for (String key : keys) {
            String value = (String) d.getFieldValue(key);
            for (String t :
                    Arrays.asList(key, key.toLowerCase(), key.toUpperCase())) {
                String tvalue = (String) d1.getFieldValue(t);
                if (!tvalue.equals(value)) {
                    throw new Exception("Value of " + key + " for " +
View Full Code Here

import javax.management.ImmutableDescriptor;

public class ImmutableArrayFieldTest {
    public static void main(String[] args) throws Exception {
        boolean ok = true;
        ImmutableDescriptor d = new ImmutableDescriptor(
                new String[] {
                    "strings", "ints", "booleans",
                },
                new Object[] {
                    new String[] {"foo"},
                    new int[] {5},
                    new boolean[] {false},
                });

        String[] strings = (String[]) d.getFieldValue("strings");
        strings[0] = "bar";
        strings = (String[]) d.getFieldValue("strings");
        if (!strings[0].equals("foo")) {
            System.out.println("FAILED: modified string array field");
            ok = false;
        }

        int[] ints = (int[]) d.getFieldValue("ints");
        ints[0] = 0;
        ints = (int[]) d.getFieldValue("ints");
        if (ints[0] != 5) {
            System.out.println("FAILED: modified int array field");
            ok = false;
        }

        boolean[] bools = (boolean[]) d.getFieldValue("booleans");
        bools[0] = true;
        bools = (boolean[]) d.getFieldValue("booleans");
        if (bools[0]) {
            System.out.println("FAILED: modified boolean array field");
            ok = false;
        }

        Object[] values = d.getFieldValues("strings", "ints", "booleans");
        ((String[]) values[0])[0] = "bar";
        ((int[]) values[1])[0] = 0;
        ((boolean[]) values[2])[0] = true;
        values = d.getFieldValues("strings", "ints", "booleans");
        if (!((String[]) values[0])[0].equals("foo") ||
                ((int[]) values[1])[0] != 5 ||
                ((boolean[]) values[2])[0]) {
            System.out.println("FAILED: getFieldValues modifiable: " +
                    Arrays.deepToString(values));
View Full Code Here

import static javax.management.ImmutableDescriptor.EMPTY_DESCRIPTOR;
import javax.management.modelmbean.DescriptorSupport;

public class UnionTest {
    public static void main(String[] args) throws Exception {
        ImmutableDescriptor immutableEmpty = new ImmutableDescriptor();
        DescriptorSupport mutableEmpty = new DescriptorSupport();

        checkEmpty(union());
        checkEmpty(union(immutableEmpty));
        checkEmpty(union(mutableEmpty));
        checkEmpty(union(EMPTY_DESCRIPTOR, immutableEmpty, mutableEmpty));
        checkEmpty(union(null, immutableEmpty, null));

        ImmutableDescriptor immutableNumbers =
            new ImmutableDescriptor(new String[] {"one", "two", "three"},
                                    new Object[] {1, 2, 3});
        final String[] noNames = null;
        DescriptorSupport mutableNumbers =
            new DescriptorSupport(immutableNumbers.getFieldNames(),
                                  immutableNumbers.getFieldValues(noNames));
        ImmutableDescriptor immutableOne =
            new ImmutableDescriptor(Collections.singletonMap("one", 1));
        DescriptorSupport mutableOne =
            new DescriptorSupport(new String[] {"one"}, new Object[] {1});
        ImmutableDescriptor immutableTwo =
            new ImmutableDescriptor(Collections.singletonMap("two", 2));
        DescriptorSupport mutableTwo =
            new DescriptorSupport(new String[] {"two"}, new Object[] {2});
        ImmutableDescriptor immutableOneTwo =
            new ImmutableDescriptor(new String[] {"one", "two"},
                                    new Object[] {1, 2});


        checkEqual(union(immutableNumbers), immutableNumbers);
        checkEqual(union(immutableNumbers, mutableNumbers), immutableNumbers);
View Full Code Here

    //       due to 6369229.
    public synchronized boolean equals(Object o) {
        if (o == this)
            return true;

        return new ImmutableDescriptor(descriptorMap).equals(o);
    }
View Full Code Here

     */
    // XXXX TODO: This is not very efficient!
    // Note: this Javadoc is copied from javax.management.Descriptor
    //       due to 6369229.
    public synchronized int hashCode() {
        return new ImmutableDescriptor(descriptorMap).hashCode();
    }
View Full Code Here

TOP

Related Classes of javax.management.ImmutableDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.