Java Code Examples for org.springframework.beans.annotation.AnnotationBeanUtils#copyPropertiesToBean()

The following examples show how to use org.springframework.beans.annotation.AnnotationBeanUtils#copyPropertiesToBean() . 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: AnnotationJmxAttributeSource.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedResource getManagedResource(Class<?> beanClass) throws InvalidMetadataException {
	ManagedResource ann = AnnotationUtils.findAnnotation(beanClass, ManagedResource.class);
	if (ann == null) {
		return null;
	}
	Class<?> declaringClass = AnnotationUtils.findAnnotationDeclaringClass(ManagedResource.class, beanClass);
	Class<?> target = (declaringClass != null && !declaringClass.isInterface() ? declaringClass : beanClass);
	if (!Modifier.isPublic(target.getModifiers())) {
		throw new InvalidMetadataException("@ManagedResource class '" + target.getName() + "' must be public");
	}
	org.springframework.jmx.export.metadata.ManagedResource managedResource = new org.springframework.jmx.export.metadata.ManagedResource();
	AnnotationBeanUtils.copyPropertiesToBean(ann, managedResource, this.embeddedValueResolver);
	return managedResource;
}
 
Example 2
Source File: AnnotationJmxAttributeSource.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
@Nullable
public org.springframework.jmx.export.metadata.ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException {
	ManagedAttribute ann = AnnotationUtils.findAnnotation(method, ManagedAttribute.class);
	if (ann == null) {
		return null;
	}
	org.springframework.jmx.export.metadata.ManagedAttribute managedAttribute = new org.springframework.jmx.export.metadata.ManagedAttribute();
	AnnotationBeanUtils.copyPropertiesToBean(ann, managedAttribute, "defaultValue");
	if (ann.defaultValue().length() > 0) {
		managedAttribute.setDefaultValue(ann.defaultValue());
	}
	return managedAttribute;
}
 
Example 3
Source File: AnnotationJmxAttributeSource.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Nullable
private static <T> T copyPropertiesToBean(@Nullable Annotation ann, Class<T> beanClass) {
	if (ann == null) {
		return null;
	}
	T bean = BeanUtils.instantiateClass(beanClass);
	AnnotationBeanUtils.copyPropertiesToBean(ann, bean);
	return bean;
}
 
Example 4
Source File: AnnotationJmxAttributeSource.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public org.springframework.jmx.export.metadata.ManagedResource getManagedResource(Class<?> beanClass) throws InvalidMetadataException {
	ManagedResource ann = AnnotationUtils.findAnnotation(beanClass, ManagedResource.class);
	if (ann == null) {
		return null;
	}
	Class<?> declaringClass = AnnotationUtils.findAnnotationDeclaringClass(ManagedResource.class, beanClass);
	Class<?> target = (declaringClass != null && !declaringClass.isInterface() ? declaringClass : beanClass);
	if (!Modifier.isPublic(target.getModifiers())) {
		throw new InvalidMetadataException("@ManagedResource class '" + target.getName() + "' must be public");
	}
	org.springframework.jmx.export.metadata.ManagedResource managedResource = new org.springframework.jmx.export.metadata.ManagedResource();
	AnnotationBeanUtils.copyPropertiesToBean(ann, managedResource, this.embeddedValueResolver);
	return managedResource;
}
 
Example 5
Source File: AnnotationJmxAttributeSource.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public org.springframework.jmx.export.metadata.ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException {
	ManagedAttribute ann = AnnotationUtils.findAnnotation(method, ManagedAttribute.class);
	if (ann == null) {
		return null;
	}
	org.springframework.jmx.export.metadata.ManagedAttribute managedAttribute = new org.springframework.jmx.export.metadata.ManagedAttribute();
	AnnotationBeanUtils.copyPropertiesToBean(ann, managedAttribute, "defaultValue");
	if (ann.defaultValue().length() > 0) {
		managedAttribute.setDefaultValue(ann.defaultValue());
	}
	return managedAttribute;
}
 
Example 6
Source File: AnnotationJmxAttributeSource.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T copyPropertiesToBean(Annotation ann, Class<T> beanClass) {
	if (ann == null) {
		return null;
	}
	T bean = BeanUtils.instantiateClass(beanClass);
	AnnotationBeanUtils.copyPropertiesToBean(ann, bean);
	return bean;
}
 
Example 7
Source File: AnnotationJmxAttributeSource.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public org.springframework.jmx.export.metadata.ManagedResource getManagedResource(Class<?> beanClass) throws InvalidMetadataException {
	ManagedResource ann = AnnotationUtils.findAnnotation(beanClass, ManagedResource.class);
	if (ann == null) {
		return null;
	}
	org.springframework.jmx.export.metadata.ManagedResource managedResource = new org.springframework.jmx.export.metadata.ManagedResource();
	AnnotationBeanUtils.copyPropertiesToBean(ann, managedResource, this.embeddedValueResolver);
	return managedResource;
}
 
Example 8
Source File: AnnotationJmxAttributeSource.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public org.springframework.jmx.export.metadata.ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException {
	ManagedAttribute ann = AnnotationUtils.findAnnotation(method, ManagedAttribute.class);
	if (ann == null) {
		return null;
	}
	org.springframework.jmx.export.metadata.ManagedAttribute managedAttribute = new org.springframework.jmx.export.metadata.ManagedAttribute();
	AnnotationBeanUtils.copyPropertiesToBean(ann, managedAttribute, "defaultValue");
	if (ann.defaultValue().length() > 0) {
		managedAttribute.setDefaultValue(ann.defaultValue());
	}
	return managedAttribute;
}
 
Example 9
Source File: AnnotationJmxAttributeSource.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private static <T> T copyPropertiesToBean(Annotation ann, Class<T> beanClass) {
	if (ann == null) {
		return null;
	}
	T bean = BeanUtils.instantiate(beanClass);
	AnnotationBeanUtils.copyPropertiesToBean(ann, bean);
	return bean;
}