本文整理汇总了Java中javax.management.modelmbean.DescriptorSupport类的典型用法代码示例。如果您正苦于以下问题:Java DescriptorSupport类的具体用法?Java DescriptorSupport怎么用?Java DescriptorSupport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DescriptorSupport类属于javax.management.modelmbean包,在下文中一共展示了DescriptorSupport类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAttributeInfo
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName,
"descriptorType=attribute", "currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName, "getMethod=getJmxValue", "setMethod=setJmxValue"});
Assert.assertTrue(this.config != null, "Config target object is null!");
desc.setField("targetObject", this.config);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例2: createAttributeInfo
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(new String[] {"name=" + this.displayName,
"descriptorType=attribute", "currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName, "getMethod=getValue"});
Assert.assertTrue(this.stat != null, "Stat target object is null!");
desc.setField("targetObject", this.stat);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例3: main
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
boolean failed = false;
String xmlDesc = "<DESCRIPTOR>"
+ "<FIELD name=\"field1\" value=\"dummy\">"
+ "</FIELD>"
+ "</DESCRIPTOR>";
Locale loc = Locale.getDefault();
try {
Locale.setDefault(new Locale("tr", "TR"));
new DescriptorSupport(xmlDesc);
} catch (Exception e) {
e.printStackTrace(System.out);
failed = true;
}finally{
Locale.setDefault(loc);
}
if (!failed) {
System.out.println("OK: all tests passed");
} else {
System.out.println("TEST FAILED");
throw new IllegalArgumentException("Test Failed");
}
}
示例4: createAttributeInfo
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(
new String[] {
"name=" + this.displayName,
"descriptorType=attribute",
"currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName,
"getMethod=getJmxValue",
"setMethod=setJmxValue"
});
Assert.assertTrue(this.config != null, "Config target object is null!");
desc.setField("targetObject", this.config);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例5: createAttributeInfo
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
Descriptor desc = new DescriptorSupport(
new String[] {
"name=" + this.displayName,
"descriptorType=attribute",
"currencyTimeLimit=-1", // always stale
"displayName=" + this.displayName,
"getMethod=getValue" });
Assert.assertTrue(this.stat != null, "Stat target object is null!");
desc.setField("targetObject", this.stat);
ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(
this.displayName, // name
this.type, // type
this.description, // description
this.readable, // isReadable
this.writeable, // isWritable
this.is, // isIs
desc);
return info;
}
示例6: commonCheck
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
/**
* Test xml conversions, isValid() and toString() methods of
* DescriptorSupport at end of each test case.
*/
public void commonCheck() throws Exception {
assertTrue(descriptor.isValid());
DescriptorSupport descriptorSupport = new DescriptorSupport(descriptor
.getFields());
// verify DescriptorSupport(String[]) constructor.
compareArrays(descriptor.getFields(), descriptorSupport.getFields());
// verify DescriptorSupport(String xmlString) constructor.
// System.out.println(descriptorSupport.toXMLString());
DescriptorSupport descriptorSupport2 = new DescriptorSupport(
descriptorSupport.toXMLString());
assertTrue(compareArrays(descriptor.getFields(), descriptorSupport2
.getFields()));
// verify toString()
String[] fieldAndValues = trimForStringArrays(descriptorSupport
.toString().split(","));
String[] fieldAndValues2 = trimForStringArrays(descriptorSupport
.getFields());
assertTrue(compareArrays(fieldAndValues, fieldAndValues2));
}
示例7: buildAttributeInfo
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
/**
* Builds an AttributeInfo in a default way
* @param name
* @param displayName
* @param description
* @param deflt
* @param operName
* @param signature
* @return the default modelMBeanAttributeInfo object
*/
public static ModelMBeanAttributeInfo buildAttributeInfo(String name, String displayName, String description, String deflt, String operName, String signature){
Descriptor attrDesc = new DescriptorSupport();
attrDesc.setField("name", name);
attrDesc.setField("descriptorType", "attribute");
attrDesc.setField("default", deflt);
attrDesc.setField("displayName", displayName);
attrDesc.setField(
"getMethod",
operName);
ModelMBeanAttributeInfo result=new ModelMBeanAttributeInfo(name,
signature,
description,
true,
false,
false,
attrDesc);
return result;
}
示例8: getMBeanInfo
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
@Override
public MBeanInfo getMBeanInfo() {
List<MBeanAttributeInfo> attributeInfos = new ArrayList<>();
for (ConfigItem item : serverConfigurationService.getConfigData().getItems()) {
String type = item.getType();
switch (type) {
case ServerConfigurationService.TYPE_BOOLEAN:
type = "boolean";
break;
case ServerConfigurationService.TYPE_INT:
type = "int";
break;
case ServerConfigurationService.TYPE_STRING:
type = "java.lang.String";
break;
}
attributeInfos.add(new MBeanAttributeInfo(item.getName(), type, item.getDescription(), !item.isSecured(), true, false));
}
List<MBeanOperationInfo> operationInfos = new ArrayList<>();
try {
Method method = getClass().getMethod("addAttribute", String.class, String.class);
operationInfos.add(new MBeanOperationInfo("addAttribute", method));
} catch (NoSuchMethodException e) {
// Ignore
}
Descriptor descriptor = new DescriptorSupport();
descriptor.setField("immutableInfo", "false");
return new MBeanInfo(getClass().getName(), "Sakai Server Configuration",
attributeInfos.toArray(new MBeanAttributeInfo[]{}),
null,
operationInfos.toArray(new MBeanOperationInfo[]{}),
null,
descriptor);
}
示例9: testFieldValue
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
/**
* TODO: add comments.
*
* @throws Exception
*/
private void testFieldValue() throws Exception {
String fieldName = "simple field";
ArrayList arrayList = new ArrayList();
String valueOfElement = "value";
arrayList.add(valueOfElement);
DescriptorSupport descriptorSupport = new DescriptorSupport(
new String[] { fieldName }, new Object[] { arrayList });
assertEquals(((ArrayList)descriptorSupport.getFieldValue(fieldName))
.get(0), valueOfElement);
descriptor = descriptorSupport;
// TODO: following line throws exception
// descriptorSupport.toXMLString();
// commonCheck();
}
示例10: buildGetterDescriptor
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
/**
* Builds a default Descriptor object for getter operations
* @param name the name of the getter
* @param klass
* @return the descriptor
*/
private static Descriptor buildGetterDescriptor(
String name,
String klass) {
Descriptor resultDesc = new DescriptorSupport();
resultDesc.setField("name", name);
resultDesc.setField("descriptorType", "operation");
resultDesc.setField("class", klass);
resultDesc.setField("role", "getter");
return resultDesc;
}
示例11: main
import javax.management.modelmbean.DescriptorSupport; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
ImmutableDescriptor immutableEmpty = new ImmutableDescriptor();
DescriptorSupport mutableEmpty = new DescriptorSupport();
checkEmpty(union());
checkEmpty(union(immutableEmpty));
checkEmpty(union(mutableEmpty));
checkEmpty(union(EMPTY_DESCRIPTOR, immutableEmpty, mutableEmpty));
checkEmpty(union(null, immutableEmpty, null));
ImmutableDescriptor immutableNumbers =
new ImmutableDescriptor(new String[] {"one", "two", "three"},
new Object[] {1, 2, 3});
final String[] noNames = null;
DescriptorSupport mutableNumbers =
new DescriptorSupport(immutableNumbers.getFieldNames(),
immutableNumbers.getFieldValues(noNames));
ImmutableDescriptor immutableOne =
new ImmutableDescriptor(Collections.singletonMap("one", 1));
DescriptorSupport mutableOne =
new DescriptorSupport(new String[] {"one"}, new Object[] {1});
ImmutableDescriptor immutableTwo =
new ImmutableDescriptor(Collections.singletonMap("two", 2));
DescriptorSupport mutableTwo =
new DescriptorSupport(new String[] {"two"}, new Object[] {2});
ImmutableDescriptor immutableOneTwo =
new ImmutableDescriptor(new String[] {"one", "two"},
new Object[] {1, 2});
checkEqual(union(immutableNumbers), immutableNumbers);
checkEqual(union(immutableNumbers, mutableNumbers), immutableNumbers);
checkEqual(union(mutableNumbers, immutableNumbers), immutableNumbers);
checkEqual(union(mutableEmpty, immutableEmpty, immutableNumbers,
mutableNumbers, immutableOne), immutableNumbers);
checkEqual(union(immutableOne, immutableTwo, immutableNumbers),
immutableNumbers);
checkEquivalent(union(immutableOne, mutableNumbers), immutableNumbers);
checkEquivalent(union(immutableOne, immutableTwo), immutableOneTwo);
checkEquivalent(union(mutableOne, mutableTwo), immutableOneTwo);
if (failure != null)
throw new Exception("TEST FAILED: " + failure);
System.out.println("TEST PASSED");
}