类javax.management.openmbean.OpenMBeanOperationInfo源码实例Demo

下面列出了怎么用javax.management.openmbean.OpenMBeanOperationInfo的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: wildfly-core   文件: MBeanInfoFactory.java
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());
}
 
源代码2 项目: jdk1.8-source-analysis   文件: StandardMBean.java
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());
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: StandardMBean.java
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());
    }
}
 
源代码4 项目: TencentKona-8   文件: StandardMBean.java
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());
    }
}
 
源代码5 项目: jdk8u60   文件: StandardMBean.java
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());
    }
}
 
源代码6 项目: JDKSourceCode1.8   文件: StandardMBean.java
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());
    }
}
 
private OpenMBeanOperationInfo greetOpenOperationInfo() {
    return new OpenMBeanOperationInfoSupport(
            GREET_METHOD_NAME,                // 操作方法名称
            "greet 方法",           // 操作方法描述
            of(nameOpenMBeanParameterInfo()), // 操作方法参数信息
            SimpleType.STRING,                // 操作方法返回类型
            ACTION);
}
 
源代码8 项目: openjdk-jdk8u   文件: StandardMBean.java
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());
    }
}
 
源代码9 项目: openjdk-jdk8u-backup   文件: StandardMBean.java
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());
    }
}
 
源代码10 项目: openjdk-jdk9   文件: StandardMBean.java
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());
    }
}
 
源代码11 项目: jdk8u-jdk   文件: StandardMBean.java
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());
    }
}
 
源代码12 项目: Java8CN   文件: StandardMBean.java
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());
    }
}
 
源代码13 项目: hottub   文件: StandardMBean.java
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());
    }
}
 
源代码14 项目: openjdk-8-source   文件: StandardMBean.java
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());
    }
}
 
源代码15 项目: openjdk-8   文件: StandardMBean.java
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());
    }
}
 
源代码16 项目: jdk8u_jdk   文件: StandardMBean.java
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());
    }
}
 
源代码17 项目: jdk8u-jdk   文件: StandardMBean.java
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());
    }
}
 
源代码18 项目: jdk8u-dev-jdk   文件: StandardMBean.java
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());
    }
}
 
源代码19 项目: wildfly-core   文件: MBeanInfoFactory.java
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()]);
}
 
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;
}
 
源代码21 项目: dragonwell8_jdk   文件: TooManyFooTest.java
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);
    }
}
 
源代码22 项目: TencentKona-8   文件: TooManyFooTest.java
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);
    }
}
 
源代码23 项目: jdk8u60   文件: TooManyFooTest.java
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);
    }
}
 
源代码24 项目: openjdk-jdk8u   文件: TooManyFooTest.java
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);
    }
}
 
源代码25 项目: openjdk-jdk8u-backup   文件: TooManyFooTest.java
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);
    }
}
 
源代码26 项目: openjdk-jdk9   文件: TooManyFooTest.java
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);
    }
}
 
源代码27 项目: jdk8u-jdk   文件: TooManyFooTest.java
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);
    }
}
 
源代码28 项目: hottub   文件: TooManyFooTest.java
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);
    }
}
 
源代码29 项目: openjdk-8-source   文件: TooManyFooTest.java
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);
    }
}
 
源代码30 项目: openjdk-8   文件: TooManyFooTest.java
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);
    }
}
 
 类所在包
 同包方法