当前位置: 首页>>代码示例>>Java>>正文


Java JmxUtils.getAttributeName方法代码示例

本文整理汇总了Java中org.springframework.jmx.support.JmxUtils.getAttributeName方法的典型用法代码示例。如果您正苦于以下问题:Java JmxUtils.getAttributeName方法的具体用法?Java JmxUtils.getAttributeName怎么用?Java JmxUtils.getAttributeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jmx.support.JmxUtils的用法示例。


在下文中一共展示了JmxUtils.getAttributeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeAttribute

import org.springframework.jmx.support.JmxUtils; //导入方法依赖的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

示例2: getAttributeInfo

import org.springframework.jmx.support.JmxUtils; //导入方法依赖的package包/类
/**
 * Iterate through all properties on the MBean class and gives subclasses
 * the chance to vote on the inclusion of both the accessor and mutator.
 * If a particular accessor or mutator is voted for inclusion, the appropriate
 * metadata is assembled and passed to the subclass for descriptor population.
 * @param managedBean the bean instance (might be an AOP proxy)
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the attribute metadata
 * @throws JMException in case of errors
 * @see #populateAttributeDescriptor
 */
@Override
protected ModelMBeanAttributeInfo[] getAttributeInfo(Object managedBean, String beanKey) throws JMException {
	PropertyDescriptor[] props = BeanUtils.getPropertyDescriptors(getClassToExpose(managedBean));
	List<ModelMBeanAttributeInfo> infos = new ArrayList<ModelMBeanAttributeInfo>();

	for (PropertyDescriptor prop : props) {
		Method getter = prop.getReadMethod();
		if (getter != null && getter.getDeclaringClass() == Object.class) {
			continue;
		}
		if (getter != null && !includeReadAttribute(getter, beanKey)) {
			getter = null;
		}

		Method setter = prop.getWriteMethod();
		if (setter != null && !includeWriteAttribute(setter, beanKey)) {
			setter = null;
		}

		if (getter != null || setter != null) {
			// If both getter and setter are null, then this does not need exposing.
			String attrName = JmxUtils.getAttributeName(prop, isUseStrictCasing());
			String description = getAttributeDescription(prop, beanKey);
			ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(attrName, description, getter, setter);

			Descriptor desc = info.getDescriptor();
			if (getter != null) {
				desc.setField(FIELD_GET_METHOD, getter.getName());
			}
			if (setter != null) {
				desc.setField(FIELD_SET_METHOD, setter.getName());
			}

			populateAttributeDescriptor(desc, getter, setter, beanKey);
			info.setDescriptor(desc);
			infos.add(info);
		}
	}

	return infos.toArray(new ModelMBeanAttributeInfo[infos.size()]);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:54,代码来源:AbstractReflectiveMBeanInfoAssembler.java


注:本文中的org.springframework.jmx.support.JmxUtils.getAttributeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。