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


Java MBeanAttributeInfo.isReadable方法代碼示例

本文整理匯總了Java中javax.management.MBeanAttributeInfo.isReadable方法的典型用法代碼示例。如果您正苦於以下問題:Java MBeanAttributeInfo.isReadable方法的具體用法?Java MBeanAttributeInfo.isReadable怎麽用?Java MBeanAttributeInfo.isReadable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.management.MBeanAttributeInfo的用法示例。


在下文中一共展示了MBeanAttributeInfo.isReadable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: printMBeanInfo

import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
/**
 * Dumps the details of a single MBean.
 * 
 * @param connection
 *            the server connection (or server itself)
 * @param objectName
 *            the object name
 * @param out
 *            PrintWriter to write the output to
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws JMException
 *             Signals a JMX error
 */
private static void printMBeanInfo(MBeanServerConnection connection, ObjectName objectName, PrintWriter out)
        throws IOException, JMException
{
    Map<String, Object> attributes = new TreeMap<String, Object>();
    MBeanInfo info = connection.getMBeanInfo(objectName);
    attributes.put("** Object Name", objectName.toString());
    attributes.put("** Object Type", info.getClassName());
    for (MBeanAttributeInfo element : info.getAttributes())
    {
        Object value;
        if (element.isReadable())
        {
            try
            {
                value = connection.getAttribute(objectName, element.getName());
            }
            catch (Exception e)
            {
                value = JmxDumpUtil.PROTECTED_VALUE;
            }
        }
        else
        {
            value = JmxDumpUtil.PROTECTED_VALUE;
        }
        attributes.put(element.getName(), value);
    }
    if (objectName.getCanonicalName().equals("Alfresco:Name=SystemProperties"))
    {
        String osName = (String) attributes.get(OS_NAME);
        if (osName != null && osName.toLowerCase().startsWith("linux"))
        {
            attributes.put(OS_NAME, updateOSNameAttributeForLinux(osName));
        }
    }
    tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, 0);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:52,代碼來源:JmxDumpUtil.java

示例2: invokeAttribute

import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
private Object invokeAttribute(PropertyDescriptor pd, MethodInvocation invocation)
		throws JMException, IOException {

	String attributeName = JmxUtils.getAttributeName(pd, this.useStrictCasing);
	MBeanAttributeInfo inf = this.allowedAttributes.get(attributeName);
	// If no attribute is returned, we know that it is not defined in the
	// management interface.
	if (inf == null) {
		throw new InvalidInvocationException(
				"Attribute '" + pd.getName() + "' is not exposed on the management interface");
	}
	if (invocation.getMethod().equals(pd.getReadMethod())) {
		if (inf.isReadable()) {
			return this.serverToUse.getAttribute(this.objectName, attributeName);
		}
		else {
			throw new InvalidInvocationException("Attribute '" + attributeName + "' is not readable");
		}
	}
	else if (invocation.getMethod().equals(pd.getWriteMethod())) {
		if (inf.isWritable()) {
			this.serverToUse.setAttribute(this.objectName, new Attribute(attributeName, invocation.getArguments()[0]));
			return null;
		}
		else {
			throw new InvalidInvocationException("Attribute '" + attributeName + "' is not writable");
		}
	}
	else {
		throw new IllegalStateException(
				"Method [" + invocation.getMethod() + "] is neither a bean property getter nor a setter");
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:34,代碼來源:MBeanClientInterceptor.java

示例3: testMXBean

import javax.management.MBeanAttributeInfo; //導入方法依賴的package包/類
private static void testMXBean(MBeanServer mbs, ObjectName on)
        throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    int nattrs = attrs.length;
    if (mbi.getAttributes().length != 1)
        failure("wrong number of attributes: " + attrs);
    else {
        MBeanAttributeInfo mbai = attrs[0];
        if (mbai.getName().equals("Ints")
            && mbai.isReadable() && !mbai.isWritable()
            && mbai.getDescriptor().getFieldValue("openType")
                .equals(new ArrayType<int[]>(SimpleType.INTEGER, true))
            && attrs[0].getType().equals("[I"))
            success("MBeanAttributeInfo");
        else
            failure("MBeanAttributeInfo: " + mbai);
    }

    int[] ints = (int[]) mbs.getAttribute(on, "Ints");
    if (equal(ints, new int[] {1, 2, 3}, null))
        success("getAttribute");
    else
        failure("getAttribute: " + Arrays.toString(ints));

    ExplicitMXBean proxy =
        JMX.newMXBeanProxy(mbs, on, ExplicitMXBean.class);
    int[] pints = proxy.getInts();
    if (equal(pints, new int[] {1, 2, 3}, null))
        success("getAttribute through proxy");
    else
        failure("getAttribute through proxy: " + Arrays.toString(pints));
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:34,代碼來源:MXBeanTest.java


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