下面列出了javax.management.openmbean.OpenMBeanAttributeInfoSupport#javax.management.openmbean.OpenMBeanAttributeInfo 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private static MBeanAttributeInfo
customize(MBeanAttributeInfo ai,
String description) {
if (equal(description, ai.getDescription()))
return ai;
if (ai instanceof OpenMBeanAttributeInfo) {
OpenMBeanAttributeInfo oai = (OpenMBeanAttributeInfo) ai;
return new OpenMBeanAttributeInfoSupport(ai.getName(),
description,
oai.getOpenType(),
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
} else {
return new MBeanAttributeInfo(ai.getName(),
ai.getType(),
description,
ai.isReadable(),
ai.isWritable(),
ai.isIs(),
ai.getDescriptor());
}
}
private OpenMBeanAttributeInfo getAttribute(String name) {
final String escapedName = NameConverter.convertToCamelCase(name);
ModelNode attribute = providedDescription.require(ATTRIBUTES).require(name);
AttributeAccess access = resourceRegistration.getAttributeAccess(PathAddress.EMPTY_ADDRESS, name);
if (access == null) {
// Check for a bogus attribute in the description that's really a child
Set<String> childTypes = resourceRegistration.getChildNames(PathAddress.EMPTY_ADDRESS);
if (childTypes.contains(name)) {
return null;
}
}
final boolean writable = mutabilityChecker.mutable(pathAddress) && (access != null && access.getAccessType() == AccessType.READ_WRITE);
return new OpenMBeanAttributeInfoSupport(
escapedName,
getDescription(attribute),
converters.convertToMBeanType(attribute),
true,
writable,
false,
createAttributeDescriptor(attribute));
}
private OpenMBeanAttributeInfo[] getAttributes() {
List<OpenMBeanAttributeInfo> infos = new LinkedList<OpenMBeanAttributeInfo>();
if (providedDescription.hasDefined(ATTRIBUTES)) {
for (final String name : providedDescription.require(ATTRIBUTES).keys()) {
OpenMBeanAttributeInfo attributeInfo = getAttribute(name);
if (attributeInfo != null) {
infos.add(getAttribute(name));
}
}
}
return infos.toArray(new OpenMBeanAttributeInfo[infos.size()]);
}
private void checkMBeanInfoAttributes(MBeanInfo info, boolean writable, boolean expressions) {
//All attributes should be read-only
MBeanAttributeInfo[] attributes = info.getAttributes();
Assert.assertEquals(14, attributes.length);
Arrays.sort(attributes, new Comparator<MBeanAttributeInfo>() {
@Override
public int compare(MBeanAttributeInfo o1, MBeanAttributeInfo o2) {
return o1.getName().compareTo(o2.getName());
}
});
assertAttributeDescription(attributes[0], "bigdec", expressions ? String.class.getName() : BigDecimal.class.getName(), "bigdec", true, writable);
assertAttributeDescription(attributes[1], "bigint", expressions ? String.class.getName() : BigInteger.class.getName(), "bigint", true, writable);
assertAttributeDescription(attributes[2], "boolean", expressions ? String.class.getName() : Boolean.class.getName(), "boolean", true, writable);
assertAttributeDescription(attributes[3], "bytes", byte[].class.getName(), "bytes", true, writable);
checkComplexTypeInfo(assertCast(CompositeType.class, assertCast(OpenMBeanAttributeInfo.class, attributes[4]).getOpenType()), expressions, "complex.");
assertAttributeDescription(attributes[5], "double", expressions ? String.class.getName() : Double.class.getName(), "double", true, writable);
assertAttributeDescription(attributes[6], "int", expressions ? String.class.getName() : Integer.class.getName(), "int", true, writable);
assertAttributeDescription(attributes[7], "list", expressions ? String[].class.getName() : Integer[].class.getName(), "list", true, writable);
assertAttributeDescription(attributes[8], "long", expressions ? String.class.getName() : Long.class.getName(), "long", true, writable);
//type=OBJECT, value-type=a simple type -> a map
assertAttributeDescription(attributes[9], "map", TabularData.class.getName(), "map", true, writable);
assertMapType(assertCast(OpenMBeanAttributeInfo.class, attributes[9]).getOpenType(), SimpleType.STRING, expressions ? SimpleType.STRING : SimpleType.INTEGER);
assertAttributeDescription(attributes[10], "roInt", expressions ? String.class.getName() : Integer.class.getName(), "ro-int", true, false);
assertAttributeDescription(attributes[11], "string", expressions ? String.class.getName() : String.class.getName(), "string", true, writable);
assertAttributeDescription(attributes[12], "type", String.class.getName(), "type", true, writable);
assertAttributeDescription(attributes[13], "undefinedInt", expressions ? String.class.getName() : Integer.class.getName(), "undefined-int", true, writable);
}
private OpenMBeanAttributeInfo findAttribute(MBeanAttributeInfo[] attrs, String name) {
for (MBeanAttributeInfo attr : attrs) {
Assert.assertNotNull(attr.getName());
if (attr.getName().equals(name)) {
return assertCast(OpenMBeanAttributeInfo.class, attr);
}
}
Assert.fail("No attr called " + name);
return null;
}