當前位置: 首頁>>代碼示例>>Java>>正文


Java MBeanAttributeInfo.getName方法代碼示例

本文整理匯總了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);
    }

}
 
開發者ID:baloise,項目名稱:eZooKeeper,代碼行數:27,代碼來源:MBean.java

示例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;
    }
}
 
開發者ID:christian-schlichtherle,項目名稱:truevfs,代碼行數:26,代碼來源:JmxBufferView.java

示例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);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:OldMBeanServerTest.java

示例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;
    }
    }
     */
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:15,代碼來源:AttributeToPropertyAdapter.java

示例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;
    }
}
 
開發者ID:christian-schlichtherle,項目名稱:truevfs,代碼行數:16,代碼來源:JmxManagerView.java

示例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;
    }
}
 
開發者ID:christian-schlichtherle,項目名稱:truevfs,代碼行數:30,代碼來源:JmxModelView.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:HotSpotGraalMBeanTest.java

示例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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:47,代碼來源:TypeNameTest.java

示例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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:66,代碼來源:HotSpotGraalMBeanTest.java

示例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);

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:35,代碼來源:HotSpotGraalMBeanTest.java


注:本文中的javax.management.MBeanAttributeInfo.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。