javax.management.openmbean.OpenMBeanOperationInfo Java Examples

The following examples show how to use javax.management.openmbean.OpenMBeanOperationInfo. 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: MBeanInfoFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private OpenMBeanOperationInfo getOperation(String name, OpenMBeanParameterInfo addWildcardChildName, OperationEntry entry) {
    ModelNode opNode = entry.getDescriptionProvider().getModelDescription(null);
    OpenMBeanParameterInfo[] params = getParameterInfos(opNode);
    if (addWildcardChildName != null) {
        OpenMBeanParameterInfo[] newParams = new OpenMBeanParameterInfo[params.length + 1];
        newParams[0] = addWildcardChildName;
        System.arraycopy(params, 0, newParams, 1, params.length);
        params = newParams;
    }
    return new OpenMBeanOperationInfoSupport(
            name,
            getDescription(opNode),
            params,
            getReturnType(opNode),
            entry.getFlags().contains(Flag.READ_ONLY) ? MBeanOperationInfo.INFO : MBeanOperationInfo.UNKNOWN,
            createOperationDescriptor());
}
 
Example #2
Source File: StandardMBean.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #3
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private OpenMBeanOperationInfo findOperation(MBeanOperationInfo[] ops, String name) {
    for (MBeanOperationInfo op : ops) {
        Assert.assertNotNull(op.getName());
        if (op.getName().equals(name)) {
            return assertCast(OpenMBeanOperationInfo.class, op);
        }
    }
    Assert.fail("No op called " + name);
    return null;
}
 
Example #4
Source File: MBeanInfoFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private OpenMBeanOperationInfo[] getOperations() {
    final boolean root = pathAddress.size() == 0;

    //TODO include inherited/global operations?
    List<OpenMBeanOperationInfo> ops = new ArrayList<OpenMBeanOperationInfo>();
    for (Map.Entry<String, OperationEntry> entry : resourceRegistration.getOperationDescriptions(PathAddress.EMPTY_ADDRESS, false).entrySet()) {
        final String opName = entry.getKey();
        if (opName.equals(ADD) || opName.equals(DESCRIBE)) {
            continue;
        }
        if (root) {
            if (opName.equals(READ_RESOURCE_OPERATION) || opName.equals(READ_ATTRIBUTE_OPERATION) ||
                    opName.equals(READ_RESOURCE_DESCRIPTION_OPERATION) || opName.equals(READ_CHILDREN_NAMES_OPERATION) ||
                    opName.equals(READ_CHILDREN_TYPES_OPERATION) || opName.equals(READ_CHILDREN_RESOURCES_OPERATION) ||
                    opName.equals(READ_OPERATION_NAMES_OPERATION) || opName.equals(READ_OPERATION_DESCRIPTION_OPERATION) ||
                    opName.equals(READ_RESOURCE_OPERATION) || opName.equals(READ_RESOURCE_OPERATION) ||
                    opName.equals(WRITE_ATTRIBUTE_OPERATION) || opName.equals(ValidateAddressOperationHandler.OPERATION_NAME) ||
                    opName.equals(CompositeOperationHandler.NAME) || opName.equals(DeploymentUploadStreamAttachmentHandler.OPERATION_NAME)) {
                //Ignore some of the global operations which probably don't make much sense here
                continue;
            }
        }
        final OperationEntry opEntry = entry.getValue();
        if (mutabilityChecker.mutable(pathAddress) || opEntry.getFlags().contains(Flag.READ_ONLY) || opEntry.getFlags().contains(Flag.RUNTIME_ONLY)) {
            ops.add(getOperation(NameConverter.convertToCamelCase(entry.getKey()), null, opEntry));
        }
    }
    addChildAddOperations(ops, resourceRegistration);
    return ops.toArray(new OpenMBeanOperationInfo[ops.size()]);
}
 
Example #5
Source File: StandardMBean.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #6
Source File: StandardMBean.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #7
Source File: StandardMBean.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #8
Source File: StandardMBean.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #9
Source File: StandardMBean.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #10
Source File: StandardMBean.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #11
Source File: StandardMBean.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #12
Source File: StandardMBean.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #13
Source File: StandardMBean.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #14
Source File: StandardMBean.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #15
Source File: StandardMBean.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #16
Source File: StandardMBean.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #17
Source File: GreetingOpenMBean.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
private OpenMBeanOperationInfo greetOpenOperationInfo() {
    return new OpenMBeanOperationInfoSupport(
            GREET_METHOD_NAME,                // 操作方法名称
            "greet 方法",           // 操作方法描述
            of(nameOpenMBeanParameterInfo()), // 操作方法参数信息
            SimpleType.STRING,                // 操作方法返回类型
            ACTION);
}
 
Example #18
Source File: StandardMBean.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #19
Source File: StandardMBean.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #20
Source File: StandardMBean.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static MBeanOperationInfo
        customize(MBeanOperationInfo oi,
                  String description,
                  MBeanParameterInfo[] signature,
                  int impact) {
    if (equal(description, oi.getDescription()) &&
            identicalArrays(signature, oi.getSignature()) &&
            impact == oi.getImpact())
        return oi;
    if (oi instanceof OpenMBeanOperationInfo) {
        OpenMBeanOperationInfo ooi = (OpenMBeanOperationInfo) oi;
        OpenMBeanParameterInfo[] oparams =
            paramsToOpenParams(signature);
        return new OpenMBeanOperationInfoSupport(oi.getName(),
                                                 description,
                                                 oparams,
                                                 ooi.getReturnOpenType(),
                                                 impact,
                                                 oi.getDescriptor());
    } else {
        return new MBeanOperationInfo(oi.getName(),
                                      description,
                                      signature,
                                      oi.getReturnType(),
                                      impact,
                                      oi.getDescriptor());
    }
}
 
Example #21
Source File: TooManyFooTest.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #22
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testAddMethodSiblingChildren() throws Exception {
    final ObjectName testObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test");
    final ObjectName child1ObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test,siblings=test1");
    final ObjectName child2ObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test,siblings=test2");
    MBeanServerConnection connection = setupAndGetConnection(new MBeanInfoAdditionalInitialization(ProcessType.STANDALONE_SERVER, new SubystemWithSiblingChildrenChildExtension()));

    Set<ObjectName> names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(1, names.size());
    Assert.assertTrue(names.contains(testObjectName));

    MBeanInfo subsystemInfo = connection.getMBeanInfo(testObjectName);
    Assert.assertEquals(0, subsystemInfo.getAttributes().length);
    Assert.assertEquals(1, subsystemInfo.getOperations().length);
    OpenMBeanOperationInfo op = findOperation(subsystemInfo.getOperations(), "addSiblings");
    Assert.assertEquals("add", op.getDescription());
    Assert.assertEquals(2, op.getSignature().length);
    Assert.assertEquals(String.class.getName(), op.getSignature()[0].getType());
    Assert.assertEquals(Integer.class.getName(), op.getSignature()[1].getType());

    connection.invoke(testObjectName, "addSiblings", new Object[]{"test1", 123}, new String[]{String.class.getName(), String.class.getName()});

    names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(2, names.size());
    Assert.assertTrue(names.contains(testObjectName));
    Assert.assertTrue(names.contains(child1ObjectName));

    subsystemInfo = connection.getMBeanInfo(testObjectName);
    Assert.assertEquals(0, subsystemInfo.getAttributes().length);
    Assert.assertEquals(1, subsystemInfo.getOperations().length);
    op = findOperation(subsystemInfo.getOperations(), "addSiblings");
    Assert.assertEquals("add", op.getDescription());
    Assert.assertEquals(2, op.getSignature().length);
    Assert.assertEquals(String.class.getName(), op.getSignature()[0].getType());
    Assert.assertEquals(Integer.class.getName(), op.getSignature()[1].getType());

    MBeanInfo childInfo = connection.getMBeanInfo(child1ObjectName);
    Assert.assertEquals(1, childInfo.getAttributes().length);
    Assert.assertEquals(Integer.class.getName(), childInfo.getAttributes()[0].getType());
    Assert.assertEquals(1, childInfo.getOperations().length);
    op = findOperation(childInfo.getOperations(), REMOVE);
    Assert.assertEquals("remove", op.getDescription());
    Assert.assertEquals(0, op.getSignature().length);

    connection.invoke(testObjectName, "addSiblings", new Object[]{"test2", 456}, new String[]{String.class.getName(), String.class.getName()});

    names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(3, names.size());
    Assert.assertTrue(names.contains(testObjectName));
    Assert.assertTrue(names.contains(child1ObjectName));
    Assert.assertTrue(names.contains(child2ObjectName));

    subsystemInfo = connection.getMBeanInfo(testObjectName);
    Assert.assertEquals(0, subsystemInfo.getAttributes().length);
    Assert.assertEquals(1, subsystemInfo.getOperations().length);
    op = findOperation(subsystemInfo.getOperations(), "addSiblings");
    Assert.assertEquals("add", op.getDescription());
    Assert.assertEquals(2, op.getSignature().length);
    Assert.assertEquals(String.class.getName(), op.getSignature()[0].getType());
    Assert.assertEquals(Integer.class.getName(), op.getSignature()[1].getType());

    childInfo = connection.getMBeanInfo(child1ObjectName);
    Assert.assertEquals(1, childInfo.getAttributes().length);
    Assert.assertEquals(Integer.class.getName(), childInfo.getAttributes()[0].getType());
    Assert.assertEquals(1, childInfo.getOperations().length);
    op = findOperation(childInfo.getOperations(), REMOVE);
    Assert.assertEquals("remove", op.getDescription());
    Assert.assertEquals(0, op.getSignature().length);

    childInfo = connection.getMBeanInfo(child2ObjectName);
    Assert.assertEquals(1, childInfo.getAttributes().length);
    Assert.assertEquals(Integer.class.getName(), childInfo.getAttributes()[0].getType());
    Assert.assertEquals(1, childInfo.getOperations().length);
    op = findOperation(childInfo.getOperations(), REMOVE);
    Assert.assertEquals("remove", op.getDescription());
    Assert.assertEquals(0, op.getSignature().length);

    Assert.assertEquals(123, connection.getAttribute(child1ObjectName, "attr"));
    Assert.assertEquals(456, connection.getAttribute(child2ObjectName, "attr"));

    connection.invoke(child1ObjectName, REMOVE, new Object[]{}, new String[]{});

    names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(2, names.size());
    Assert.assertTrue(names.contains(testObjectName));
    Assert.assertTrue(names.contains(child2ObjectName));

    connection.invoke(child2ObjectName, REMOVE, new Object[]{}, new String[]{});

    names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(1, names.size());
    Assert.assertTrue(names.contains(testObjectName));
}
 
Example #23
Source File: ModelControllerMBeanTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testAddMethodSingleFixedChild() throws Exception {
    final ObjectName testObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test");
    final ObjectName childObjectName = createObjectName(LEGACY_DOMAIN + ":subsystem=test,single=only");
    MBeanServerConnection connection = setupAndGetConnection(new MBeanInfoAdditionalInitialization(ProcessType.STANDALONE_SERVER, new SubystemWithSingleFixedChildExtension()));

    Set<ObjectName> names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(1, names.size());
    Assert.assertTrue(names.contains(testObjectName));

    MBeanInfo subsystemInfo = connection.getMBeanInfo(testObjectName);
    Assert.assertEquals(0, subsystemInfo.getAttributes().length);
    Assert.assertEquals(1, subsystemInfo.getOperations().length);
    OpenMBeanOperationInfo op = findOperation(subsystemInfo.getOperations(), "addSingleOnly");
    Assert.assertEquals("add", op.getDescription());
    Assert.assertEquals(1, op.getSignature().length);
    Assert.assertEquals(Integer.class.getName(), op.getSignature()[0].getType());

    connection.invoke(testObjectName, "addSingleOnly", new Object[]{123}, new String[]{String.class.getName()});

    names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(2, names.size());
    Assert.assertTrue(names.contains(testObjectName));
    Assert.assertTrue(names.contains(childObjectName));

    subsystemInfo = connection.getMBeanInfo(testObjectName);
    Assert.assertEquals(0, subsystemInfo.getAttributes().length);
    Assert.assertEquals(1, subsystemInfo.getOperations().length);
    op = findOperation(subsystemInfo.getOperations(), "addSingleOnly");
    Assert.assertEquals("add", op.getDescription());
    Assert.assertEquals(1, op.getSignature().length);
    Assert.assertEquals(Integer.class.getName(), op.getSignature()[0].getType());

    MBeanInfo childInfo = connection.getMBeanInfo(childObjectName);
    Assert.assertEquals(1, childInfo.getAttributes().length);
    Assert.assertEquals(Integer.class.getName(), childInfo.getAttributes()[0].getType());
    Assert.assertEquals(1, childInfo.getOperations().length);
    op = findOperation(childInfo.getOperations(), REMOVE);
    Assert.assertEquals("remove", op.getDescription());
    Assert.assertEquals(0, op.getSignature().length);

    Assert.assertEquals(123, connection.getAttribute(childObjectName, "attr"));

    try {
        connection.invoke(testObjectName, "addSingleOnly", new Object[]{123}, new String[]{String.class.getName()});
        Assert.fail("Should not have been able to register a duplicate resource");
    } catch (Exception expected) {
        //expected
    }

    connection.invoke(childObjectName, REMOVE, new Object[]{}, new String[]{});

    names = connection.queryNames(createObjectName(LEGACY_DOMAIN + ":subsystem=test,*"), null);
    Assert.assertEquals(1, names.size());
    Assert.assertTrue(names.contains(testObjectName));
}
 
Example #24
Source File: TooManyFooTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #25
Source File: TooManyFooTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #26
Source File: TooManyFooTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #27
Source File: TooManyFooTest.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #28
Source File: TooManyFooTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #29
Source File: TooManyFooTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
Example #30
Source File: TooManyFooTest.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}