org.springframework.jmx.export.metadata.ManagedAttribute Java Examples

The following examples show how to use org.springframework.jmx.export.metadata.ManagedAttribute. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MetadataMBeanInfoAssembler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Creates a description for the attribute corresponding to this property
 * descriptor. Attempts to create the description using metadata from either
 * the getter or setter attributes, otherwise uses the property name.
 */
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
	Method readMethod = propertyDescriptor.getReadMethod();
	Method writeMethod = propertyDescriptor.getWriteMethod();

	ManagedAttribute getter =
			(readMethod != null ? obtainAttributeSource().getManagedAttribute(readMethod) : null);
	ManagedAttribute setter =
			(writeMethod != null ? obtainAttributeSource().getManagedAttribute(writeMethod) : null);

	if (getter != null && StringUtils.hasText(getter.getDescription())) {
		return getter.getDescription();
	}
	else if (setter != null && StringUtils.hasText(setter.getDescription())) {
		return setter.getDescription();
	}

	ManagedMetric metric = (readMethod != null ? obtainAttributeSource().getManagedMetric(readMethod) : null);
	if (metric != null && StringUtils.hasText(metric.getDescription())) {
		return metric.getDescription();
	}

	return propertyDescriptor.getDisplayName();
}
 
Example #2
Source File: MetadataMBeanInfoAssembler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Retrieves the description for the supplied {@code Method} from the
 * metadata. Uses the method name is no description is present in the metadata.
 */
@Override
protected String getOperationDescription(Method method, String beanKey) {
	PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
	if (pd != null) {
		ManagedAttribute ma = obtainAttributeSource().getManagedAttribute(method);
		if (ma != null && StringUtils.hasText(ma.getDescription())) {
			return ma.getDescription();
		}
		ManagedMetric metric = obtainAttributeSource().getManagedMetric(method);
		if (metric != null && StringUtils.hasText(metric.getDescription())) {
			return metric.getDescription();
		}
		return method.getName();
	}
	else {
		ManagedOperation mo = obtainAttributeSource().getManagedOperation(method);
		if (mo != null && StringUtils.hasText(mo.getDescription())) {
			return mo.getDescription();
		}
		return method.getName();
	}
}
 
Example #3
Source File: MetadataMBeanInfoAssembler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
/**
 * Adds descriptor fields from the {@code ManagedAttribute} attribute or the {@code ManagedMetric} attribute
 * to the attribute descriptor.
 */
@Override
protected void populateAttributeDescriptor(
		Descriptor desc, @Nullable Method getter, @Nullable Method setter, String beanKey) {

	if (getter != null) {
		ManagedMetric metric = obtainAttributeSource().getManagedMetric(getter);
		if (metric != null) {
			populateMetricDescriptor(desc, metric);
			return;
		}
	}

	ManagedAttribute gma = (getter != null ? obtainAttributeSource().getManagedAttribute(getter) : null);
	ManagedAttribute sma = (setter != null ? obtainAttributeSource().getManagedAttribute(setter) : null);
	populateAttributeDescriptor(desc,
			(gma != null ? gma : ManagedAttribute.EMPTY),
			(sma != null ? sma : ManagedAttribute.EMPTY));
}
 
Example #4
Source File: MetadataMBeanInfoAssembler.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Creates a description for the attribute corresponding to this property
 * descriptor. Attempts to create the description using metadata from either
 * the getter or setter attributes, otherwise uses the property name.
 */
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
	Method readMethod = propertyDescriptor.getReadMethod();
	Method writeMethod = propertyDescriptor.getWriteMethod();

	ManagedAttribute getter =
			(readMethod != null ? obtainAttributeSource().getManagedAttribute(readMethod) : null);
	ManagedAttribute setter =
			(writeMethod != null ? obtainAttributeSource().getManagedAttribute(writeMethod) : null);

	if (getter != null && StringUtils.hasText(getter.getDescription())) {
		return getter.getDescription();
	}
	else if (setter != null && StringUtils.hasText(setter.getDescription())) {
		return setter.getDescription();
	}

	ManagedMetric metric = (readMethod != null ? obtainAttributeSource().getManagedMetric(readMethod) : null);
	if (metric != null && StringUtils.hasText(metric.getDescription())) {
		return metric.getDescription();
	}

	return propertyDescriptor.getDisplayName();
}
 
Example #5
Source File: MetadataMBeanInfoAssembler.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Retrieves the description for the supplied {@code Method} from the
 * metadata. Uses the method name is no description is present in the metadata.
 */
@Override
protected String getOperationDescription(Method method, String beanKey) {
	PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
	if (pd != null) {
		ManagedAttribute ma = obtainAttributeSource().getManagedAttribute(method);
		if (ma != null && StringUtils.hasText(ma.getDescription())) {
			return ma.getDescription();
		}
		ManagedMetric metric = obtainAttributeSource().getManagedMetric(method);
		if (metric != null && StringUtils.hasText(metric.getDescription())) {
			return metric.getDescription();
		}
		return method.getName();
	}
	else {
		ManagedOperation mo = obtainAttributeSource().getManagedOperation(method);
		if (mo != null && StringUtils.hasText(mo.getDescription())) {
			return mo.getDescription();
		}
		return method.getName();
	}
}
 
Example #6
Source File: MetadataMBeanInfoAssembler.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Adds descriptor fields from the {@code ManagedAttribute} attribute or the {@code ManagedMetric} attribute
 * to the attribute descriptor.
 */
@Override
protected void populateAttributeDescriptor(
		Descriptor desc, @Nullable Method getter, @Nullable Method setter, String beanKey) {

	if (getter != null) {
		ManagedMetric metric = obtainAttributeSource().getManagedMetric(getter);
		if (metric != null) {
			populateMetricDescriptor(desc, metric);
			return;
		}
	}

	ManagedAttribute gma = (getter != null ? obtainAttributeSource().getManagedAttribute(getter) : null);
	ManagedAttribute sma = (setter != null ? obtainAttributeSource().getManagedAttribute(setter) : null);
	populateAttributeDescriptor(desc,
			(gma != null ? gma : ManagedAttribute.EMPTY),
			(sma != null ? sma : ManagedAttribute.EMPTY));
}
 
Example #7
Source File: MetadataMBeanInfoAssembler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a description for the attribute corresponding to this property
 * descriptor. Attempts to create the description using metadata from either
 * the getter or setter attributes, otherwise uses the property name.
 */
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
	Method readMethod = propertyDescriptor.getReadMethod();
	Method writeMethod = propertyDescriptor.getWriteMethod();

	ManagedAttribute getter =
			(readMethod != null ? this.attributeSource.getManagedAttribute(readMethod) : null);
	ManagedAttribute setter =
			(writeMethod != null ? this.attributeSource.getManagedAttribute(writeMethod) : null);

	if (getter != null && StringUtils.hasText(getter.getDescription())) {
		return getter.getDescription();
	}
	else if (setter != null && StringUtils.hasText(setter.getDescription())) {
		return setter.getDescription();
	}

	ManagedMetric metric = (readMethod != null ? this.attributeSource.getManagedMetric(readMethod) : null);
	if (metric != null && StringUtils.hasText(metric.getDescription())) {
		return metric.getDescription();
	}

	return propertyDescriptor.getDisplayName();
}
 
Example #8
Source File: MetadataMBeanInfoAssembler.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Retrieves the description for the supplied {@code Method} from the
 * metadata. Uses the method name is no description is present in the metadata.
 */
@Override
protected String getOperationDescription(Method method, String beanKey) {
	PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
	if (pd != null) {
		ManagedAttribute ma = this.attributeSource.getManagedAttribute(method);
		if (ma != null && StringUtils.hasText(ma.getDescription())) {
			return ma.getDescription();
		}
		ManagedMetric metric = this.attributeSource.getManagedMetric(method);
		if (metric != null && StringUtils.hasText(metric.getDescription())) {
			return metric.getDescription();
		}
		return method.getName();
	}
	else {
		ManagedOperation mo = this.attributeSource.getManagedOperation(method);
		if (mo != null && StringUtils.hasText(mo.getDescription())) {
			return mo.getDescription();
		}
		return method.getName();
	}
}
 
Example #9
Source File: MetadataMBeanInfoAssembler.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a description for the attribute corresponding to this property
 * descriptor. Attempts to create the description using metadata from either
 * the getter or setter attributes, otherwise uses the property name.
 */
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
	Method readMethod = propertyDescriptor.getReadMethod();
	Method writeMethod = propertyDescriptor.getWriteMethod();

	ManagedAttribute getter =
			(readMethod != null ? this.attributeSource.getManagedAttribute(readMethod) : null);
	ManagedAttribute setter =
			(writeMethod != null ? this.attributeSource.getManagedAttribute(writeMethod) : null);

	if (getter != null && StringUtils.hasText(getter.getDescription())) {
		return getter.getDescription();
	}
	else if (setter != null && StringUtils.hasText(setter.getDescription())) {
		return setter.getDescription();
	}

	ManagedMetric metric = (readMethod != null ? this.attributeSource.getManagedMetric(readMethod) : null);
	if (metric != null && StringUtils.hasText(metric.getDescription())) {
		return metric.getDescription();
	}

	return propertyDescriptor.getDisplayName();
}
 
Example #10
Source File: MetadataMBeanInfoAssembler.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieves the description for the supplied {@code Method} from the
 * metadata. Uses the method name is no description is present in the metadata.
 */
@Override
protected String getOperationDescription(Method method, String beanKey) {
	PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
	if (pd != null) {
		ManagedAttribute ma = this.attributeSource.getManagedAttribute(method);
		if (ma != null && StringUtils.hasText(ma.getDescription())) {
			return ma.getDescription();
		}
		ManagedMetric metric = this.attributeSource.getManagedMetric(method);
		if (metric != null && StringUtils.hasText(metric.getDescription())) {
			return metric.getDescription();
		}
		return method.getName();
	}
	else {
		ManagedOperation mo = this.attributeSource.getManagedOperation(method);
		if (mo != null && StringUtils.hasText(mo.getDescription())) {
			return mo.getDescription();
		}
		return method.getName();
	}
}
 
Example #11
Source File: MetadataMBeanInfoAssembler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma) {
	applyCurrencyTimeLimit(desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit()));

	Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue());
	desc.setField(FIELD_DEFAULT, defaultValue);

	String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy());
	if (StringUtils.hasLength(persistPolicy)) {
		desc.setField(FIELD_PERSIST_POLICY, persistPolicy);
	}
	int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod());
	if (persistPeriod >= 0) {
		desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod));
	}
}
 
Example #12
Source File: MetadataMBeanInfoAssembler.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma) {
	applyCurrencyTimeLimit(desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit()));

	Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue());
	desc.setField(FIELD_DEFAULT, defaultValue);

	String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy());
	if (StringUtils.hasLength(persistPolicy)) {
		desc.setField(FIELD_PERSIST_POLICY, persistPolicy);
	}
	int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod());
	if (persistPeriod >= 0) {
		desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod));
	}
}
 
Example #13
Source File: MetadataMBeanInfoAssembler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds descriptor fields from the {@code ManagedAttribute} attribute or the {@code ManagedMetric} attribute
 * to the attribute descriptor.
 */
@Override
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey) {
	if (getter != null && hasManagedMetric(getter)) {
		populateMetricDescriptor(desc, this.attributeSource.getManagedMetric(getter));
	}
	else {
		ManagedAttribute gma =
				(getter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(getter);
		ManagedAttribute sma =
				(setter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(setter);
		populateAttributeDescriptor(desc,gma,sma);
	}
}
 
Example #14
Source File: MetadataMBeanInfoAssembler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma) {
	applyCurrencyTimeLimit(desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit()));

	Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue());
	desc.setField(FIELD_DEFAULT, defaultValue);

	String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy());
	if (StringUtils.hasLength(persistPolicy)) {
		desc.setField(FIELD_PERSIST_POLICY, persistPolicy);
	}
	int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod());
	if (persistPeriod >= 0) {
		desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod));
	}
}
 
Example #15
Source File: MetadataMBeanInfoAssembler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Adds descriptor fields from the {@code ManagedAttribute} attribute or the {@code ManagedMetric} attribute
 * to the attribute descriptor.
 */
@Override
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey) {
	if (getter != null && hasManagedMetric(getter)) {
		populateMetricDescriptor(desc, this.attributeSource.getManagedMetric(getter));
	}
	else {
		ManagedAttribute gma =
			(getter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(getter);
		ManagedAttribute sma =
			(setter == null) ? ManagedAttribute.EMPTY : this.attributeSource.getManagedAttribute(setter);
		populateAttributeDescriptor(desc,gma,sma);
	}
}
 
Example #16
Source File: MetadataMBeanInfoAssembler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void populateAttributeDescriptor(Descriptor desc, ManagedAttribute gma, ManagedAttribute sma) {
	applyCurrencyTimeLimit(desc, resolveIntDescriptor(gma.getCurrencyTimeLimit(), sma.getCurrencyTimeLimit()));

	Object defaultValue = resolveObjectDescriptor(gma.getDefaultValue(), sma.getDefaultValue());
	desc.setField(FIELD_DEFAULT, defaultValue);

	String persistPolicy = resolveStringDescriptor(gma.getPersistPolicy(), sma.getPersistPolicy());
	if (StringUtils.hasLength(persistPolicy)) {
		desc.setField(FIELD_PERSIST_POLICY, persistPolicy);
	}
	int persistPeriod = resolveIntDescriptor(gma.getPersistPeriod(), sma.getPersistPeriod());
	if (persistPeriod >= 0) {
		desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(persistPeriod));
	}
}