本文整理匯總了Java中javax.management.MBeanAttributeInfo.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java MBeanAttributeInfo.getName方法的具體用法?Java MBeanAttributeInfo.getName怎麽用?Java MBeanAttributeInfo.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.management.MBeanAttributeInfo
的用法示例。
在下文中一共展示了MBeanAttributeInfo.getName方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initAttributeCollections
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
/**
* TODO: Comment.
*
*/
private void initAttributeCollections() {
MBeanAttributeInfo[] attributeInfos = _Info.getAttributes();
int size = 0;
if (attributeInfos != null) {
size = attributeInfos.length;
}
_AttributeNames = new TreeSet<String>();
_AttributeInfoMap = new HashMap<String, MBeanAttributeInfo>(size);
if (size == 0) {
return;
}
for (MBeanAttributeInfo attributeInfo : attributeInfos) {
String attributeName = attributeInfo.getName();
_AttributeNames.add(attributeName);
_AttributeInfoMap.put(attributeName, attributeInfo);
}
}
示例2: getDescription
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
@Override
protected String getDescription(final MBeanAttributeInfo info) {
switch (info.getName()) {
case "Name":
return "The name of this buffer.";
case "SizeOfData":
return "The data size of this buffer.";
case "SizeOfStorage":
return "The storage size of this buffer.";
case "TimeCreatedDate":
return "The time this buffer has been created.";
case "TimeCreatedMillis":
return "The time this buffer has been created in milliseconds.";
case "TimeReadDate":
return "The last time this buffer has been read or accessed.";
case "TimeReadMillis":
return "The last time this buffer has been read or accessed in milliseconds.";
case "TimeWrittenDate":
return "The last time this buffer has been written.";
case "TimeWrittenMillis":
return "The last time this buffer has been written in milliseconds.";
default:
return null;
}
}
示例3: printAttrs
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
private static void printAttrs(
MBeanServerConnection mbsc1, Class<? extends Exception> expectX)
throws Exception {
Set<ObjectName> names = mbsc1.queryNames(null, null);
for (ObjectName name : names) {
System.out.println(name + ":");
MBeanInfo mbi = mbsc1.getMBeanInfo(name);
MBeanAttributeInfo[] mbais = mbi.getAttributes();
for (MBeanAttributeInfo mbai : mbais) {
String attr = mbai.getName();
Object value;
try {
value = mbsc1.getAttribute(name, attr);
} catch (Exception e) {
if (expectX != null && expectX.isInstance(e))
value = "<" + e + ">";
else
throw e;
}
String s = " " + attr + " = " + value;
if (s.length() > 80)
s = s.substring(0, 77) + "...";
System.out.println(s);
}
}
}
示例4: AttributeToPropertyAdapter
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
public AttributeToPropertyAdapter(MBeanAttributeInfo info, DynamicMBean folderMBean) {
super(info.getName());
this.folderMBean = folderMBean;
this.info = info;
// find the attr info
/*for (MBeanAttributeInfo nfo : folderMBean.getAttributeInfos()) {
if (info.getName().equals(attributeName)) {
this.info = nfo;
break;
}
}
*/
}
示例5: getDescription
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
@Override
protected String getDescription(final MBeanAttributeInfo info) {
switch (info.getName()) {
case "FileSystemsMounted":
return "The number of file systems which have been mounted.";
case "FileSystemsTotal":
return "The total number of file systems.";
case "TopLevelArchiveFileSystemsMounted":
return "The number of top level archive file systems which have been mounted.";
case "TopLevelArchiveFileSystemsTotal":
return "The total number of top level archive file systems.";
default:
return null;
}
}
示例6: getDescription
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
@Override
protected String getDescription(final MBeanAttributeInfo info) {
switch (info.getName()) {
case "Mounted":
return "Whether or not this file system is mounted.";
case "MountPoint":
return "The mount point URI of this file system.";
case "MountPointOfParent":
return "The mount point URI of the parent file system.";
case "SizeOfData":
return "The data size of this file system.";
case "SizeOfStorage":
return "The storage size of this file system.";
case "TimeCreatedDate":
return "The time this file system has been created.";
case "TimeCreatedMillis":
return "The time this file system has been created in milliseconds.";
case "TimeReadDate":
return "The last time this file system has been read or accessed.";
case "TimeReadMillis":
return "The last time this file system has been read or accessed in milliseconds.";
case "TimeWrittenDate":
return "The last time this file system has been written.";
case "TimeWrittenMillis":
return "The last time this file system has been written in milliseconds.";
default:
return null;
}
}
示例7: readBeanInfo
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
@Test
public void readBeanInfo() throws Exception {
ObjectName name;
assertNotNull("Server is started", ManagementFactory.getPlatformMBeanServer());
HotSpotGraalMBean realBean = HotSpotGraalMBean.create(null);
assertNotNull("Bean is registered", name = realBean.ensureRegistered(false));
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectInstance bean = server.getObjectInstance(name);
assertNotNull("Bean is registered", bean);
MBeanInfo info = server.getMBeanInfo(name);
assertNotNull("Info is found", info);
MBeanAttributeInfo printCompilation = (MBeanAttributeInfo) findAttributeInfo("PrintCompilation", info);
assertNotNull("PrintCompilation found", printCompilation);
assertEquals("true/false", Boolean.class.getName(), printCompilation.getType());
Attribute printOn = new Attribute(printCompilation.getName(), Boolean.TRUE);
Object before = server.getAttribute(name, printCompilation.getName());
server.setAttribute(name, printOn);
Object after = server.getAttribute(name, printCompilation.getName());
assertNull("Default value was not set", before);
assertEquals("Changed to on", Boolean.TRUE, after);
}
示例8: main
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
TestMXBean testImpl = (TestMXBean) Proxy.newProxyInstance(
TestMXBean.class.getClassLoader(), new Class<?>[] {TestMXBean.class}, nullIH);
Object mxbean = new StandardMBean(testImpl, TestMXBean.class, true);
MBeanServer mbs = MBeanServerFactory.newMBeanServer();
ObjectName name = new ObjectName("a:b=c");
mbs.registerMBean(mxbean, name);
MBeanInfo mbi = mbs.getMBeanInfo(name);
MBeanAttributeInfo[] mbais = mbi.getAttributes();
boolean sawTabular = false;
for (MBeanAttributeInfo mbai : mbais) {
String attrName = mbai.getName();
String attrTypeName = (String) mbai.getDescriptor().getFieldValue("originalType");
String fieldName = attrName + "Name";
Field nameField = TestMXBean.class.getField(fieldName);
String expectedTypeName = (String) nameField.get(null);
if (expectedTypeName.equals(attrTypeName)) {
System.out.println("OK: " + attrName + ": " + attrTypeName);
} else {
fail("For attribute " + attrName + " expected type name \"" +
expectedTypeName + "\", found type name \"" + attrTypeName +
"\"");
}
if (mbai.getType().equals(TabularData.class.getName())) {
sawTabular = true;
TabularType tt = (TabularType) mbai.getDescriptor().getFieldValue("openType");
if (tt.getTypeName().equals(attrTypeName)) {
System.out.println("OK: TabularType name for " + attrName);
} else {
fail("For attribute " + attrName + " expected TabularType " +
"name \"" + attrTypeName + "\", found \"" +
tt.getTypeName());
}
}
}
if (!sawTabular)
fail("Test bug: did not test TabularType name");
if (failure == null)
System.out.println("TEST PASSED");
else
throw new Exception("TEST FAILED: " + failure);
}
示例9: dumpOperation
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
@Test
public void dumpOperation() throws Exception {
Field field = null;
try {
field = stopMBeanServer();
} catch (Exception ex) {
if (ex.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
// skip on JDK9
return;
}
}
assertNull("The platformMBeanServer isn't initialized now", field.get(null));
ObjectName name;
assertNotNull("Server is started", ManagementFactory.getPlatformMBeanServer());
HotSpotGraalMBean realBean = HotSpotGraalMBean.create(null);
assertNotNull("Bean is registered", name = realBean.ensureRegistered(false));
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectInstance bean = server.getObjectInstance(name);
assertNotNull("Bean is registered", bean);
MBeanInfo info = server.getMBeanInfo(name);
assertNotNull("Info is found", info);
final MBeanOperationInfo[] arr = info.getOperations();
assertEquals("Currently three overloads", 3, arr.length);
MBeanOperationInfo dumpOp = null;
for (int i = 0; i < arr.length; i++) {
assertEquals("dumpMethod", arr[i].getName());
if (arr[i].getSignature().length == 3) {
dumpOp = arr[i];
}
}
assertNotNull("three args variant found", dumpOp);
server.invoke(name, "dumpMethod", new Object[]{
"java.util.Arrays", "asList", ":3"
}, null);
MBeanAttributeInfo dump = (MBeanAttributeInfo) findAttributeInfo("Dump", info);
Attribute dumpTo1 = new Attribute(dump.getName(), "");
server.setAttribute(name, dumpTo1);
Object after = server.getAttribute(name, dump.getName());
assertEquals("", after);
OptionValues empty = new OptionValues(EconomicMap.create());
OptionValues unsetDump = realBean.optionsFor(empty, null);
final MetaAccessProvider metaAccess = jdk.vm.ci.runtime.JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Arrays.class.getMethod("asList", Object[].class));
final OptionValues forMethod = realBean.optionsFor(unsetDump, method);
assertNotSame(unsetDump, forMethod);
Object nothing = unsetDump.getMap().get(DebugOptions.Dump);
assertEquals("Empty string", "", nothing);
Object specialValue = forMethod.getMap().get(DebugOptions.Dump);
assertEquals(":3", specialValue);
OptionValues normalMethod = realBean.optionsFor(unsetDump, null);
Object noSpecialValue = normalMethod.getMap().get(DebugOptions.Dump);
assertEquals("Empty string", "", noSpecialValue);
}
示例10: optionsAreCached
import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
@Test
public void optionsAreCached() throws Exception {
ObjectName name;
assertNotNull("Server is started", ManagementFactory.getPlatformMBeanServer());
HotSpotGraalMBean realBean = HotSpotGraalMBean.create(null);
OptionValues original = new OptionValues(EconomicMap.create());
assertSame(original, realBean.optionsFor(original, null));
assertNotNull("Bean is registered", name = realBean.ensureRegistered(false));
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
ObjectInstance bean = server.getObjectInstance(name);
assertNotNull("Bean is registered", bean);
MBeanInfo info = server.getMBeanInfo(name);
assertNotNull("Info is found", info);
MBeanAttributeInfo dump = (MBeanAttributeInfo) findAttributeInfo("Dump", info);
Attribute dumpTo1 = new Attribute(dump.getName(), 1);
server.setAttribute(name, dumpTo1);
Object after = server.getAttribute(name, dump.getName());
assertEquals(1, after);
final OptionValues modified1 = realBean.optionsFor(original, null);
assertNotSame(original, modified1);
final OptionValues modified2 = realBean.optionsFor(original, null);
assertSame("Options are cached", modified1, modified2);
}