@Override public ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException { ManagedOperationParameters params = AnnotationUtils.findAnnotation(method, ManagedOperationParameters.class); ManagedOperationParameter[] result = null; if (params == null) { result = new ManagedOperationParameter[0]; } else { Annotation[] paramData = params.value(); result = new ManagedOperationParameter[paramData.length]; for (int i = 0; i < paramData.length; i++) { Annotation annotation = paramData[i]; ManagedOperationParameter managedOperationParameter = new ManagedOperationParameter(); AnnotationBeanUtils.copyPropertiesToBean(annotation, managedOperationParameter); result[i] = managedOperationParameter; } } return result; }
@Override public ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException { ManagedNotifications notificationsAnn = clazz.getAnnotation(ManagedNotifications.class); if(notificationsAnn == null) { return new ManagedNotification[0]; } Annotation[] notifications = notificationsAnn.value(); ManagedNotification[] result = new ManagedNotification[notifications.length]; for (int i = 0; i < notifications.length; i++) { Annotation notification = notifications[i]; ManagedNotification managedNotification = new ManagedNotification(); AnnotationBeanUtils.copyPropertiesToBean(notification, managedNotification); result[i] = managedNotification; } return result; }
public ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException { ManagedOperationParameters params = AnnotationUtils.findAnnotation(method, ManagedOperationParameters.class); ManagedOperationParameter[] result = null; if (params == null) { result = new ManagedOperationParameter[0]; } else { Annotation[] paramData = params.value(); result = new ManagedOperationParameter[paramData.length]; for (int i = 0; i < paramData.length; i++) { Annotation annotation = paramData[i]; ManagedOperationParameter managedOperationParameter = new ManagedOperationParameter(); AnnotationBeanUtils.copyPropertiesToBean(annotation, managedOperationParameter); result[i] = managedOperationParameter; } } return result; }
@Override public ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException { org.springframework.jmx.export.annotation.ManagedAttribute ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedAttribute.class); if (ann == null) { return null; } ManagedAttribute managedAttribute = new ManagedAttribute(); AnnotationBeanUtils.copyPropertiesToBean(ann, managedAttribute, "defaultValue"); if (ann.defaultValue().length() > 0) { managedAttribute.setDefaultValue(ann.defaultValue()); } return managedAttribute; }
@Override public ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException { org.springframework.jmx.export.annotation.ManagedMetric ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedMetric.class); if (ann == null) { return null; } ManagedMetric managedMetric = new ManagedMetric(); AnnotationBeanUtils.copyPropertiesToBean(ann, managedMetric); return managedMetric; }
@Override public ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException { Annotation ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedOperation.class); if (ann == null) { return null; } ManagedOperation op = new ManagedOperation(); AnnotationBeanUtils.copyPropertiesToBean(ann, op); return op; }
@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; }
@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; }
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; }
@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; }
public ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException { org.springframework.jmx.export.annotation.ManagedAttribute ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedAttribute.class); if (ann == null) { return null; } ManagedAttribute managedAttribute = new ManagedAttribute(); AnnotationBeanUtils.copyPropertiesToBean(ann, managedAttribute, "defaultValue"); if (ann.defaultValue().length() > 0) { managedAttribute.setDefaultValue(ann.defaultValue()); } return managedAttribute; }
public ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException { org.springframework.jmx.export.annotation.ManagedMetric ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedMetric.class); if (ann == null) { return null; } ManagedMetric managedMetric = new ManagedMetric(); AnnotationBeanUtils.copyPropertiesToBean(ann, managedMetric); return managedMetric; }
public ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException { Annotation ann = AnnotationUtils.findAnnotation(method, org.springframework.jmx.export.annotation.ManagedOperation.class); if (ann == null) { return null; } ManagedOperation op = new ManagedOperation(); AnnotationBeanUtils.copyPropertiesToBean(ann, op); return op; }
public ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException { ManagedNotifications notificationsAnn = clazz.getAnnotation(ManagedNotifications.class); if(notificationsAnn == null) { return new ManagedNotification[0]; } Annotation[] notifications = notificationsAnn.value(); ManagedNotification[] result = new ManagedNotification[notifications.length]; for (int i = 0; i < notifications.length; i++) { Annotation notification = notifications[i]; ManagedNotification managedNotification = new ManagedNotification(); AnnotationBeanUtils.copyPropertiesToBean(notification, managedNotification); result[i] = managedNotification; } return result; }