MBeanClientInterceptor.java 文件源码

java
阅读 28 收藏 0 点赞 0 评论 0

项目:lams 作者:
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");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号