Search in sources :

Example 1 with DescriptorSupport

use of javax.management.modelmbean.DescriptorSupport in project jdk8u_jdk by JetBrains.

the class DescriptorSupportTest method main.

public static void main(String[] args) throws Exception {
    boolean ok = true;
    System.out.println("Checking that name and descriptorType are " + "mandatory");
    // Try omitting name and/or descriptorType
    for (int i = 0; i < 3; i++) {
        final boolean addName = ((i & 1) != 0);
        final boolean addDescriptorType = ((i & 2) != 0);
        final List fields = new ArrayList();
        if (addName)
            fields.add("name=something");
        if (addDescriptorType)
            fields.add("descriptorType=something-else");
        final String[] fs = (String[]) fields.toArray(new String[0]);
        final String what = "DescriptorSupport with " + (addName ? "" : "no ") + "name and " + (addDescriptorType ? "" : "no ") + "descriptorType";
        DescriptorSupport ds = new DescriptorSupport(fs);
        if (ds.isValid()) {
            System.out.println("INCORRECTLY ACCEPTED: " + what);
            ok = false;
        } else
            System.out.println("OK: rejected " + what);
    }
    for (int pass = 0; pass < 2; pass++) {
        boolean shouldAccept = (pass == 0);
        System.out.println("Trying out " + (shouldAccept ? "correct" : "bogus") + " DescriptorSupport fields");
        Object[] fields = shouldAccept ? goodFields : badFields;
        for (int i = 0; i < fields.length; i += 2) {
            String[] names = { "name", "descriptorType" };
            String[] values = { "some-name", "some-type" };
            DescriptorSupport d = new DescriptorSupport(names, values);
            final String name = (String) fields[i];
            final Object value = fields[i + 1];
            final String valueS = (value instanceof String) ? ("\"" + value + "\"") : (value == null) ? "null" : value.toString();
            final String what = "DescriptorSupport with " + name + " = " + valueS;
            try {
                d.setField(name, value);
                if (shouldAccept)
                    System.out.println("OK: accepted " + what);
                else {
                    System.out.println("INCORRECTLY ACCEPTED: " + what);
                    ok = false;
                }
            } catch (RuntimeOperationsException e) {
                if (shouldAccept) {
                    System.out.println("INCORRECTLY REJECTED: " + what + ": " + e);
                    ok = false;
                } else {
                    System.out.println("OK: rejected " + what);
                // OK: this is what should happen
                }
            } catch (Exception e) {
                System.out.println("WRONG EXCEPTION: " + what + ": " + e);
                ok = false;
            }
        }
    }
    // 4894856: ModelMBeanInfoSupport.setDescriptor(d, "mbean") fails
    System.out.println("Checking that setDescriptor(d, \"mbean\") works");
    ModelMBeanInfo mmbi = new ModelMBeanInfoSupport("x", "descr", null, null, null, null);
    Descriptor d = mmbi.getDescriptor("x", "mbean");
    try {
        mmbi.setDescriptor(d, "mbean");
    } catch (Exception e) {
        System.out.println("Unexpected exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    // 5016685: DescriptorSupport forces field names to lower case
    System.out.println("Checking that field name case is ignored " + "but preserved");
    ok &= caseTest(new DescriptorSupport(new String[] { "NAME=blah" }), "DescriptorSupport(String[])");
    ok &= caseTest(new DescriptorSupport(new String[] { "NAME" }, new String[] { "blah" }), "DescriptorSupport(String[], Object[])");
    DescriptorSupport d1 = new DescriptorSupport();
    d1.setField("NAME", "blah");
    ok &= caseTest(d1, "DescriptorSupport.setField");
    d1 = new DescriptorSupport(new String[] { "NAME=blah" });
    ok &= caseTest(new DescriptorSupport(d1), "DescriptorSupport(Descriptor)");
    d1 = new DescriptorSupport(new String[] { "NAME=blah" });
    ok &= caseTest(new DescriptorSupport(d1.toXMLString()), "DescriptorSupport(String)");
    d1 = new DescriptorSupport(new String[] { "NAME=blah" });
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bos);
    oos.writeObject(d1);
    oos.close();
    bos.close();
    ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
    ObjectInputStream ois = new ObjectInputStream(bis);
    d1 = (DescriptorSupport) ois.readObject();
    ok &= caseTest(d1, "serialized DescriptorSupport");
    if (ok)
        System.out.println("Test passed");
    else {
        System.out.println("TEST FAILED");
        System.exit(1);
    }
}
Also used : ArrayList(java.util.ArrayList) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) RuntimeOperationsException(javax.management.RuntimeOperationsException) ByteArrayInputStream(java.io.ByteArrayInputStream) Descriptor(javax.management.Descriptor) List(java.util.List) ArrayList(java.util.ArrayList) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport) RuntimeOperationsException(javax.management.RuntimeOperationsException) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with DescriptorSupport

use of javax.management.modelmbean.DescriptorSupport in project jdk8u_jdk by JetBrains.

the class DescriptorSupportXMLTest method main.

public static void main(String[] args) throws Exception {
    System.out.println("Testing that DescriptorSupport.toXMLString() " + "can be used to reconstruct an equivalent " + "DescriptorSupport");
    int failed = 0;
    final Object[] testValues = { // Values that should be encodable.
    "", "ok", "null", "(open", "close)", "(parens)", "quote\"quote", "a description with several words", "magic&\"\\<> \r\t\n\f;&;magic", "&lt;descriptor&gt;&&&&lt;/descriptor&gt;", "&lt;descriptor&gt;&&&&lt;/blahblahblah&gt;", null, new Integer(10), Boolean.TRUE, new Float(1.0f), // because they don't have a (String) constructor.
    new Character('!'), new java.util.HashMap() };
    for (int i = 0; i < testValues.length; i++) {
        final Object v = testValues[i];
        final String what = (v == null) ? "null" : (v.getClass().getName() + "{" + v + "}");
        final DescriptorSupport in = new DescriptorSupport(new String[] { "bloo" }, new Object[] { v });
        final String xml;
        try {
            xml = in.toXMLString();
        } catch (RuntimeOperationsException e) {
            final Throwable cause = e.getCause();
            if (cause instanceof IllegalArgumentException) {
                System.out.println("OK: " + what + ": got a " + "RuntimeOperationsException wrapping " + "an IllegalArgumentException: " + cause.getMessage());
            } else {
                final String causeString = (cause == null) ? "null" : cause.getClass().getName();
                System.out.println("FAILED: " + what + ": got a " + "RuntimeOperationException wrapping " + causeString);
                failed++;
            }
            continue;
        }
        System.out.println("Encoded " + what + " as " + xml);
        final DescriptorSupport out;
        try {
            out = new DescriptorSupport(xml);
        } catch (Exception e) {
            System.out.println("FAILED: " + what + ": got an exception:");
            e.printStackTrace(System.out);
            failed++;
            continue;
        }
        final String[] names = out.getFieldNames();
        if (names.length != 1 || !"bloo".equals(names[0])) {
            System.out.println("FAILED: decoded names wrong: " + Arrays.asList(names));
            failed++;
            continue;
        }
        final Object[] values = out.getFieldValues(names);
        if (values.length != 1) {
            System.out.println("FAILED: wrong number of values: " + Arrays.asList(values));
            failed++;
            continue;
        }
        final Object outValue = values[0];
        if (v == null) {
            if (outValue == null)
                System.out.println("OK: decoded null value");
            else {
                System.out.println("FAILED: decoded null value as " + outValue.getClass().getName() + "{" + outValue + "}");
                failed++;
            }
            continue;
        }
        if (outValue == null) {
            System.out.println("FAILED: decoded non-null value as null");
            failed++;
            continue;
        }
        if (v.getClass() != outValue.getClass()) {
            System.out.println("FAILED: decoded value has class " + outValue.getClass().getName() + "{" + outValue + "}");
            failed++;
            continue;
        }
        if (v.equals(outValue))
            System.out.println("OK: decoded value is equal to original");
        else {
            System.out.println("FAILED: decoded value is different: {" + outValue + "}");
            failed++;
        }
    }
    if (failed == 0)
        System.out.println("OK: all tests passed");
    else {
        System.out.println("TEST FAILED: fail count: " + failed);
        System.exit(1);
    }
}
Also used : DescriptorSupport(javax.management.modelmbean.DescriptorSupport) RuntimeOperationsException(javax.management.RuntimeOperationsException) RuntimeOperationsException(javax.management.RuntimeOperationsException)

Example 3 with DescriptorSupport

use of javax.management.modelmbean.DescriptorSupport in project jdk8u_jdk by JetBrains.

the class LoggingExceptionTest method main.

public static void main(String[] args) {
    Handler handler = new ConsoleHandler();
    Logger logger = Logger.getLogger("javax.management.modelmbean");
    logger.addHandler(handler);
    logger.setLevel(Level.FINEST);
    try {
        for (int i = 0; i < tests.length; i++) {
            System.out.println(">>> DescriptorSupportLoggingTest: Test Case " + i);
            DescriptorSupport ds;
            String msg = "Instantiate " + tests[i];
            System.out.println(msg);
            switch(i) {
                case 0:
                    ds = new DescriptorSupport();
                    break;
                case 1:
                    ds = new DescriptorSupport(10);
                    break;
                case 2:
                    ds = new DescriptorSupport(new DescriptorSupport().toXMLString());
                    break;
                case 3:
                    ds = new DescriptorSupport("name1=value1", "name2=value2");
                    break;
                case 4:
                    ds = new DescriptorSupport(new String[] { "name" }, new Object[] { "value" });
                    break;
                case 5:
                    ds = new DescriptorSupport(new DescriptorSupport());
                    break;
                case 6:
                    RequiredModelMBean mbean = new RequiredModelMBean();
                    NotificationListener nl = new NotificationListener() {

                        public void handleNotification(Notification notification, Object handback) {
                        }
                    };
                    mbean.addAttributeChangeNotificationListener(nl, null, null);
                    break;
                default:
                    throw new AssertionError();
            }
            System.out.println(msg + " OK");
        }
    } catch (Exception e) {
        System.out.println("Got unexpected exception = " + e);
        String msg = "Test FAILED!";
        System.out.println(msg);
        throw new IllegalArgumentException(msg);
    }
    System.out.println("Test PASSED!");
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) Logger(java.util.logging.Logger) ConsoleHandler(java.util.logging.ConsoleHandler) Notification(javax.management.Notification) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) NotificationListener(javax.management.NotificationListener)

Example 4 with DescriptorSupport

use of javax.management.modelmbean.DescriptorSupport in project jdk8u_jdk by JetBrains.

the class UnserializableTargetObjectTest method main.

public static void main(String[] args) throws Exception {
    MBeanServer mbs = MBeanServerFactory.newMBeanServer();
    ObjectName name = new ObjectName("a:b=c");
    Resource resource1 = new Resource();
    Resource resource2 = new Resource();
    Resource resource3 = new Resource();
    Method operationMethod = Resource.class.getMethod("operation");
    Method getCountMethod = Resource.class.getMethod("getCount");
    Method setCountMethod = Resource.class.getMethod("setCount", int.class);
    Descriptor operationDescriptor = new DescriptorSupport(new String[] { "descriptorType", "name", "targetObject" }, new Object[] { "operation", "operation", resource1 });
    Descriptor getCountDescriptor = new DescriptorSupport(new String[] { "descriptorType", "name", "targetObject" }, new Object[] { "operation", "getCount", resource2 });
    Descriptor setCountDescriptor = new DescriptorSupport(new String[] { "descriptorType", "name", "targetObject" }, new Object[] { "operation", "setCount", resource2 });
    Descriptor countDescriptor = new DescriptorSupport(new String[] { "descriptorType", "name", "getMethod", "setMethod" }, new Object[] { "attribute", "Count", "getCount", "setCount" });
    ModelMBeanOperationInfo operationInfo = new ModelMBeanOperationInfo("operation description", operationMethod, operationDescriptor);
    ModelMBeanOperationInfo getCountInfo = new ModelMBeanOperationInfo("getCount description", getCountMethod, getCountDescriptor);
    ModelMBeanOperationInfo setCountInfo = new ModelMBeanOperationInfo("setCount description", setCountMethod, setCountDescriptor);
    ModelMBeanAttributeInfo countInfo = new ModelMBeanAttributeInfo("Count", "Count description", getCountMethod, setCountMethod, countDescriptor);
    ModelMBeanInfo mmbi = new ModelMBeanInfoSupport(Resource.class.getName(), "ModelMBean to test targetObject", new ModelMBeanAttributeInfo[] { countInfo }, // no constructors
    null, new ModelMBeanOperationInfo[] { operationInfo, getCountInfo, setCountInfo }, // no notifications
    null);
    ModelMBean mmb = new RequiredModelMBean(mmbi);
    mmb.setManagedResource(resource3, "ObjectReference");
    mbs.registerMBean(mmb, name);
    mbs.invoke(name, "operation", null, null);
    mbs.setAttribute(name, new Attribute("Count", 53));
    if (resource1.operationCount != 1)
        throw new Exception("operationCount: " + resource1.operationCount);
    if (resource2.count != 53)
        throw new Exception("count: " + resource2.count);
    int got = (Integer) mbs.getAttribute(name, "Count");
    if (got != 53)
        throw new Exception("got count: " + got);
    JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
    JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    cs.start();
    JMXServiceURL addr = cs.getAddress();
    JMXConnector cc = JMXConnectorFactory.connect(addr);
    MBeanServerConnection mbsc = cc.getMBeanServerConnection();
    ModelMBeanInfo rmmbi = (ModelMBeanInfo) mbsc.getMBeanInfo(name);
    // Above gets NotSerializableException if resource included in
    // serialized form
    cc.close();
    cs.stop();
    System.out.println("TEST PASSED");
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) ModelMBean(javax.management.modelmbean.ModelMBean) Attribute(javax.management.Attribute) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) Method(java.lang.reflect.Method) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) ObjectName(javax.management.ObjectName) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) JMXConnectorServer(javax.management.remote.JMXConnectorServer) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) JMXConnector(javax.management.remote.JMXConnector) Descriptor(javax.management.Descriptor) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport) MBeanServerConnection(javax.management.MBeanServerConnection) MBeanServer(javax.management.MBeanServer)

Example 5 with DescriptorSupport

use of javax.management.modelmbean.DescriptorSupport in project jdk8u_jdk by JetBrains.

the class RequiredModelMBeanGetAttributeTest method main.

public static void main(String[] args) throws Exception {
    boolean ok = true;
    MBeanServer mbs = MBeanServerFactory.createMBeanServer();
    // Resource methods
    Method nullGetter = Resource.class.getMethod("getNull", (Class[]) null);
    Method integerGetter = Resource.class.getMethod("getInteger", (Class[]) null);
    Method hashtableGetter = Resource.class.getMethod("getHashtable", (Class[]) null);
    Method mapGetter = Resource.class.getMethod("getMap", (Class[]) null);
    // ModelMBeanOperationInfo
    Descriptor nullOperationDescriptor = new DescriptorSupport(new String[] { "name=getNull", "descriptorType=operation", "role=getter" });
    ModelMBeanOperationInfo nullOperationInfo = new ModelMBeanOperationInfo("Null attribute", nullGetter, nullOperationDescriptor);
    Descriptor integerOperationDescriptor = new DescriptorSupport(new String[] { "name=getInteger", "descriptorType=operation", "role=getter" });
    ModelMBeanOperationInfo integerOperationInfo = new ModelMBeanOperationInfo("Integer attribute", integerGetter, integerOperationDescriptor);
    Descriptor hashtableOperationDescriptor = new DescriptorSupport(new String[] { "name=getHashtable", "descriptorType=operation", "role=getter" });
    ModelMBeanOperationInfo hashtableOperationInfo = new ModelMBeanOperationInfo("Hashtable attribute", hashtableGetter, hashtableOperationDescriptor);
    Descriptor mapOperationDescriptor = new DescriptorSupport(new String[] { "name=getMap", "descriptorType=operation", "role=getter" });
    ModelMBeanOperationInfo mapOperationInfo = new ModelMBeanOperationInfo("Map attribute", mapGetter, mapOperationDescriptor);
    // ModelMBeanAttributeInfo
    Descriptor nullAttributeDescriptor = new DescriptorSupport(new String[] { "name=Null", "descriptorType=attribute", "getMethod=getNull" });
    ModelMBeanAttributeInfo nullAttributeInfo = new ModelMBeanAttributeInfo("Null", "java.lang.Object", "Null attribute", true, false, false, nullAttributeDescriptor);
    Descriptor integerAttributeDescriptor = new DescriptorSupport(new String[] { "name=Integer", "descriptorType=attribute", "getMethod=getInteger" });
    ModelMBeanAttributeInfo integerAttributeInfo = new ModelMBeanAttributeInfo("Integer", "int", "Integer attribute", true, false, false, integerAttributeDescriptor);
    Descriptor hashtableAttributeDescriptor = new DescriptorSupport(new String[] { "name=Hashtable", "descriptorType=attribute", "getMethod=getHashtable" });
    ModelMBeanAttributeInfo hashtableAttributeInfo = new ModelMBeanAttributeInfo("Hashtable", "java.util.Hashtable", "Hashtable attribute", true, false, false, hashtableAttributeDescriptor);
    Descriptor mapAttributeDescriptor = new DescriptorSupport(new String[] { "name=Map", "descriptorType=attribute", "getMethod=getMap" });
    ModelMBeanAttributeInfo mapAttributeInfo = new ModelMBeanAttributeInfo("Map", "java.util.Map", "Map attribute", true, false, false, mapAttributeDescriptor);
    Descriptor null2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Null2", "descriptorType=attribute" });
    null2AttributeDescriptor.setField("default", null);
    ModelMBeanAttributeInfo null2AttributeInfo = new ModelMBeanAttributeInfo("Null2", "java.lang.Object", "Null2 attribute", true, false, false, null2AttributeDescriptor);
    Descriptor integer2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Integer2", "descriptorType=attribute" });
    integer2AttributeDescriptor.setField("default", 10);
    ModelMBeanAttributeInfo integer2AttributeInfo = new ModelMBeanAttributeInfo("Integer2", "int", "Integer2 attribute", true, false, false, integer2AttributeDescriptor);
    Descriptor hashtable2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Hashtable2", "descriptorType=attribute" });
    hashtable2AttributeDescriptor.setField("default", new Hashtable());
    ModelMBeanAttributeInfo hashtable2AttributeInfo = new ModelMBeanAttributeInfo("Hashtable2", "java.util.Hashtable", "Hashtable2 attribute", true, false, false, hashtable2AttributeDescriptor);
    Descriptor map2AttributeDescriptor = new DescriptorSupport(new String[] { "name=Map2", "descriptorType=attribute" });
    map2AttributeDescriptor.setField("default", new Hashtable());
    ModelMBeanAttributeInfo map2AttributeInfo = new ModelMBeanAttributeInfo("Map2", "java.util.Map", "Map2 attribute", true, false, false, map2AttributeDescriptor);
    // ModelMBeanInfo
    ModelMBeanInfo mmbi = new ModelMBeanInfoSupport(Resource.class.getName(), "Resource MBean", new ModelMBeanAttributeInfo[] { nullAttributeInfo, integerAttributeInfo, hashtableAttributeInfo, mapAttributeInfo, null2AttributeInfo, integer2AttributeInfo, hashtable2AttributeInfo, map2AttributeInfo }, null, new ModelMBeanOperationInfo[] { nullOperationInfo, integerOperationInfo, hashtableOperationInfo, mapOperationInfo }, null);
    // RequiredModelMBean
    ModelMBean mmb = new RequiredModelMBean(mmbi);
    mmb.setManagedResource(resource, "ObjectReference");
    ObjectName mmbName = new ObjectName(":type=ResourceMBean");
    mbs.registerMBean(mmb, mmbName);
    // Run tests
    System.out.println("\nTesting that we can call getNull()... ");
    try {
        Object o = mbs.getAttribute(mmbName, "Null");
        System.out.println("getNull() = " + o);
        System.out.println("Attribute's declared type = java.lang.Object");
        System.out.println("Returned value's type = null");
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getInteger()... ");
    try {
        Integer i = (Integer) mbs.getAttribute(mmbName, "Integer");
        System.out.println("getInteger() = " + i);
        System.out.println("Attribute's declared type = int");
        System.out.println("Returned value's type = " + i.getClass().getName());
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getHashtable()... ");
    try {
        Hashtable h = (Hashtable) mbs.getAttribute(mmbName, "Hashtable");
        System.out.println("getHashtable() = " + h);
        System.out.println("Attribute's declared type = " + "java.util.Hashtable");
        System.out.println("Returned value's type = " + h.getClass().getName());
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getMap()... ");
    try {
        Map m = (Map) mbs.getAttribute(mmbName, "Map");
        System.out.println("getMap() = " + m);
        System.out.println("Attribute's declared type = " + "java.util.Map");
        System.out.println("Returned value's type = " + m.getClass().getName());
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getNull2()... ");
    try {
        Object o = mbs.getAttribute(mmbName, "Null2");
        System.out.println("getNull2() = " + o);
        System.out.println("Attribute's declared type = java.lang.Object");
        System.out.println("Returned value's type = null");
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getInteger2()... ");
    try {
        Integer i = (Integer) mbs.getAttribute(mmbName, "Integer2");
        System.out.println("getInteger2() = " + i);
        System.out.println("Attribute's declared type = int");
        System.out.println("Returned value's type = " + i.getClass().getName());
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getHashtable2()... ");
    try {
        Hashtable h = (Hashtable) mbs.getAttribute(mmbName, "Hashtable2");
        System.out.println("getHashtable2() = " + h);
        System.out.println("Attribute's declared type = " + "java.util.Hashtable");
        System.out.println("Returned value's type = " + h.getClass().getName());
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    System.out.println("\nTesting that we can call getMap2()... ");
    try {
        Map m = (Map) mbs.getAttribute(mmbName, "Map2");
        System.out.println("getMap2() = " + m);
        System.out.println("Attribute's declared type = " + "java.util.Map");
        System.out.println("Returned value's type = " + m.getClass().getName());
    } catch (Exception e) {
        System.out.println("TEST FAILED: Caught exception:");
        e.printStackTrace(System.out);
        ok = false;
    }
    if (ok)
        System.out.println("\nTest passed.\n");
    else {
        System.out.println("\nTest failed.\n");
        System.exit(1);
    }
}
Also used : ModelMBeanOperationInfo(javax.management.modelmbean.ModelMBeanOperationInfo) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) ModelMBean(javax.management.modelmbean.ModelMBean) Hashtable(java.util.Hashtable) DescriptorSupport(javax.management.modelmbean.DescriptorSupport) Method(java.lang.reflect.Method) ModelMBeanInfo(javax.management.modelmbean.ModelMBeanInfo) RequiredModelMBean(javax.management.modelmbean.RequiredModelMBean) ObjectName(javax.management.ObjectName) ModelMBeanAttributeInfo(javax.management.modelmbean.ModelMBeanAttributeInfo) Descriptor(javax.management.Descriptor) ModelMBeanInfoSupport(javax.management.modelmbean.ModelMBeanInfoSupport) Map(java.util.Map) MBeanServer(javax.management.MBeanServer)

Aggregations

DescriptorSupport (javax.management.modelmbean.DescriptorSupport)14 Descriptor (javax.management.Descriptor)7 ModelMBeanAttributeInfo (javax.management.modelmbean.ModelMBeanAttributeInfo)6 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)5 ModelMBeanInfoSupport (javax.management.modelmbean.ModelMBeanInfoSupport)5 ModelMBeanInfo (javax.management.modelmbean.ModelMBeanInfo)4 RequiredModelMBean (javax.management.modelmbean.RequiredModelMBean)4 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)3 MBeanConstructorInfo (javax.management.MBeanConstructorInfo)3 MBeanInfo (javax.management.MBeanInfo)3 MBeanOperationInfo (javax.management.MBeanOperationInfo)3 MBeanParameterInfo (javax.management.MBeanParameterInfo)3 MBeanServer (javax.management.MBeanServer)3 ObjectName (javax.management.ObjectName)3 ModelMBean (javax.management.modelmbean.ModelMBean)3 ModelMBeanOperationInfo (javax.management.modelmbean.ModelMBeanOperationInfo)3 OpenMBeanAttributeInfo (javax.management.openmbean.OpenMBeanAttributeInfo)3 OpenMBeanAttributeInfoSupport (javax.management.openmbean.OpenMBeanAttributeInfoSupport)3 OpenMBeanConstructorInfo (javax.management.openmbean.OpenMBeanConstructorInfo)3 OpenMBeanConstructorInfoSupport (javax.management.openmbean.OpenMBeanConstructorInfoSupport)3