org.springframework.jmx.export.metadata.InvalidMetadataException Java Examples
The following examples show how to use
org.springframework.jmx.export.metadata.InvalidMetadataException.
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 spring-analysis-note with MIT License | 6 votes |
@Override @Nullable public org.springframework.jmx.export.metadata.ManagedAttribute getManagedAttribute(Method method) throws InvalidMetadataException { MergedAnnotation<ManagedAttribute> ann = MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE) .get(ManagedAttribute.class).withNonMergedAttributes(); if (!ann.isPresent()) { return null; } org.springframework.jmx.export.metadata.ManagedAttribute bean = new org.springframework.jmx.export.metadata.ManagedAttribute(); Map<String, Object> map = ann.asMap(); MutablePropertyValues pvs = new MutablePropertyValues(map); pvs.removePropertyValue("defaultValue"); PropertyAccessorFactory.forBeanPropertyAccess(bean).setPropertyValues(pvs); String defaultValue = (String) map.get("defaultValue"); if (defaultValue.length() > 0) { bean.setDefaultValue(defaultValue); } return bean; }
Example #2
Source File: AnnotationJmxAttributeSource.java From java-technology-stack with MIT License | 6 votes |
@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 #3
Source File: MetadataMBeanInfoAssembler.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Adds descriptor fields from the {@code ManagedResource} attribute * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit}, * {@code persistPolicy}, {@code persistPeriod}, {@code persistLocation} * and {@code persistName} descriptor fields if they are present in the metadata. */ @Override protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) { ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean)); if (mr == null) { throw new InvalidMetadataException( "No ManagedResource attribute found for class: " + getClassToExpose(managedBean)); } applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit()); if (mr.isLog()) { desc.setField(FIELD_LOG, "true"); } if (StringUtils.hasLength(mr.getLogFile())) { desc.setField(FIELD_LOG_FILE, mr.getLogFile()); } if (StringUtils.hasLength(mr.getPersistPolicy())) { desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); } if (mr.getPersistPeriod() >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); } if (StringUtils.hasLength(mr.getPersistName())) { desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); } if (StringUtils.hasLength(mr.getPersistLocation())) { desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation()); } }
Example #4
Source File: AnnotationJmxAttributeSource.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public org.springframework.jmx.export.metadata.ManagedResource getManagedResource(Class<?> beanClass) throws InvalidMetadataException { MergedAnnotation<ManagedResource> ann = MergedAnnotations.from(beanClass, SearchStrategy.EXHAUSTIVE) .get(ManagedResource.class).withNonMergedAttributes(); if (!ann.isPresent()) { return null; } Class<?> declaringClass = (Class<?>) ann.getSource(); 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 bean = new org.springframework.jmx.export.metadata.ManagedResource(); Map<String, Object> map = ann.asMap(); List<PropertyValue> list = new ArrayList<>(map.size()); map.forEach((attrName, attrValue) -> { if (!"value".equals(attrName)) { Object value = attrValue; if (this.embeddedValueResolver != null && value instanceof String) { value = this.embeddedValueResolver.resolveStringValue((String) value); } list.add(new PropertyValue(attrName, value)); } }); PropertyAccessorFactory.forBeanPropertyAccess(bean).setPropertyValues(new MutablePropertyValues(list)); return bean; }
Example #5
Source File: AnnotationJmxAttributeSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException { Set<ManagedNotification> anns = AnnotationUtils.getRepeatableAnnotations( clazz, ManagedNotification.class, ManagedNotifications.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedNotification.class); }
Example #6
Source File: AnnotationJmxAttributeSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException { Set<ManagedOperationParameter> anns = AnnotationUtils.getRepeatableAnnotations( method, ManagedOperationParameter.class, ManagedOperationParameters.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedOperationParameter.class); }
Example #7
Source File: AnnotationJmxAttributeSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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 #8
Source File: AnnotationJmxAttributeSource.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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 #9
Source File: MetadataMBeanInfoAssembler.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Adds descriptor fields from the {@code ManagedResource} attribute * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit}, * {@code persistPolicy}, {@code persistPeriod}, {@code persistLocation} * and {@code persistName} descriptor fields if they are present in the metadata. */ @Override protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) { ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean)); if (mr == null) { throw new InvalidMetadataException( "No ManagedResource attribute found for class: " + getClassToExpose(managedBean)); } applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit()); if (mr.isLog()) { desc.setField(FIELD_LOG, "true"); } if (StringUtils.hasLength(mr.getLogFile())) { desc.setField(FIELD_LOG_FILE, mr.getLogFile()); } if (StringUtils.hasLength(mr.getPersistPolicy())) { desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); } if (mr.getPersistPeriod() >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); } if (StringUtils.hasLength(mr.getPersistName())) { desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); } if (StringUtils.hasLength(mr.getPersistLocation())) { desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation()); } }
Example #10
Source File: AnnotationJmxAttributeSource.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException { Set<ManagedNotification> anns = AnnotationUtils.getRepeatableAnnotations( clazz, ManagedNotification.class, ManagedNotifications.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedNotification.class); }
Example #11
Source File: AnnotationJmxAttributeSource.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException { Set<ManagedOperationParameter> anns = AnnotationUtils.getRepeatableAnnotations( method, ManagedOperationParameter.class, ManagedOperationParameters.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedOperationParameter.class); }
Example #12
Source File: AnnotationJmxAttributeSource.java From lams with GNU General Public License v2.0 | 5 votes |
@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 #13
Source File: AnnotationJmxAttributeSource.java From lams with GNU General Public License v2.0 | 5 votes |
@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 #14
Source File: EnableMBeanExportConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("resource") public void testPackagePrivateImplementationCantBeExposed() { this.thrown.expect(InvalidMetadataException.class); this.thrown.expectMessage(PackagePrivateAnnotationTestBean.class.getName()); this.thrown.expectMessage("must be public"); new AnnotationConfigApplicationContext(PackagePrivateInterfaceImplementationConfiguration.class); }
Example #15
Source File: EnableMBeanExportConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test @SuppressWarnings("resource") public void testPackagePrivateExtensionCantBeExposed() { this.thrown.expect(InvalidMetadataException.class); this.thrown.expectMessage(PackagePrivateTestBean.class.getName()); this.thrown.expectMessage("must be public"); new AnnotationConfigApplicationContext(PackagePrivateConfiguration.class); }
Example #16
Source File: EnableMBeanExportConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("resource") public void testPackagePrivateImplementationCantBeExposed() { assertThatExceptionOfType(InvalidMetadataException.class).isThrownBy(() -> new AnnotationConfigApplicationContext(PackagePrivateInterfaceImplementationConfiguration.class)) .withMessageContaining(PackagePrivateAnnotationTestBean.class.getName()) .withMessageContaining("must be public"); }
Example #17
Source File: AnnotationJmxAttributeSource.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public org.springframework.jmx.export.metadata.ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException { MergedAnnotation<ManagedMetric> ann = MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE) .get(ManagedMetric.class).withNonMergedAttributes(); return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedMetric.class); }
Example #18
Source File: AnnotationJmxAttributeSource.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public org.springframework.jmx.export.metadata.ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException { MergedAnnotation<ManagedOperation> ann = MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE) .get(ManagedOperation.class).withNonMergedAttributes(); return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedOperation.class); }
Example #19
Source File: AnnotationJmxAttributeSource.java From spring-analysis-note with MIT License | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException { List<MergedAnnotation<? extends Annotation>> anns = getRepeatableAnnotations( method, ManagedOperationParameter.class, ManagedOperationParameters.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedOperationParameter.class); }
Example #20
Source File: AnnotationJmxAttributeSource.java From spring-analysis-note with MIT License | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException { List<MergedAnnotation<? extends Annotation>> anns = getRepeatableAnnotations( clazz, ManagedNotification.class, ManagedNotifications.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedNotification.class); }
Example #21
Source File: MetadataMBeanInfoAssembler.java From spring-analysis-note with MIT License | 5 votes |
/** * Adds descriptor fields from the {@code ManagedResource} attribute * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit}, * {@code persistPolicy}, {@code persistPeriod}, {@code persistLocation} * and {@code persistName} descriptor fields if they are present in the metadata. */ @Override protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) { ManagedResource mr = obtainAttributeSource().getManagedResource(getClassToExpose(managedBean)); if (mr == null) { throw new InvalidMetadataException( "No ManagedResource attribute found for class: " + getClassToExpose(managedBean)); } applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit()); if (mr.isLog()) { desc.setField(FIELD_LOG, "true"); } if (StringUtils.hasLength(mr.getLogFile())) { desc.setField(FIELD_LOG_FILE, mr.getLogFile()); } if (StringUtils.hasLength(mr.getPersistPolicy())) { desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); } if (mr.getPersistPeriod() >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); } if (StringUtils.hasLength(mr.getPersistName())) { desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); } if (StringUtils.hasLength(mr.getPersistLocation())) { desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation()); } }
Example #22
Source File: EnableMBeanExportConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test @SuppressWarnings("resource") public void testPackagePrivateExtensionCantBeExposed() { assertThatExceptionOfType(InvalidMetadataException.class).isThrownBy(() -> new AnnotationConfigApplicationContext(PackagePrivateConfiguration.class)) .withMessageContaining(PackagePrivateTestBean.class.getName()) .withMessageContaining("must be public"); }
Example #23
Source File: MetadataMBeanInfoAssembler.java From java-technology-stack with MIT License | 5 votes |
/** * Adds descriptor fields from the {@code ManagedResource} attribute * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit}, * {@code persistPolicy}, {@code persistPeriod}, {@code persistLocation} * and {@code persistName} descriptor fields if they are present in the metadata. */ @Override protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) { ManagedResource mr = obtainAttributeSource().getManagedResource(getClassToExpose(managedBean)); if (mr == null) { throw new InvalidMetadataException( "No ManagedResource attribute found for class: " + getClassToExpose(managedBean)); } applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit()); if (mr.isLog()) { desc.setField(FIELD_LOG, "true"); } if (StringUtils.hasLength(mr.getLogFile())) { desc.setField(FIELD_LOG_FILE, mr.getLogFile()); } if (StringUtils.hasLength(mr.getPersistPolicy())) { desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy()); } if (mr.getPersistPeriod() >= 0) { desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod())); } if (StringUtils.hasLength(mr.getPersistName())) { desc.setField(FIELD_PERSIST_NAME, mr.getPersistName()); } if (StringUtils.hasLength(mr.getPersistLocation())) { desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation()); } }
Example #24
Source File: AnnotationJmxAttributeSource.java From java-technology-stack with MIT License | 5 votes |
@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 #25
Source File: AnnotationJmxAttributeSource.java From java-technology-stack with MIT License | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedOperationParameter[] getManagedOperationParameters(Method method) throws InvalidMetadataException { Set<ManagedOperationParameter> anns = AnnotationUtils.getRepeatableAnnotations( method, ManagedOperationParameter.class, ManagedOperationParameters.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedOperationParameter.class); }
Example #26
Source File: AnnotationJmxAttributeSource.java From java-technology-stack with MIT License | 5 votes |
@Override public org.springframework.jmx.export.metadata.ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException { Set<ManagedNotification> anns = AnnotationUtils.getRepeatableAnnotations( clazz, ManagedNotification.class, ManagedNotifications.class); return copyPropertiesToBeanArray(anns, org.springframework.jmx.export.metadata.ManagedNotification.class); }
Example #27
Source File: AnnotationJmxAttributeSource.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public org.springframework.jmx.export.metadata.ManagedOperation getManagedOperation(Method method) throws InvalidMetadataException { ManagedOperation ann = AnnotationUtils.findAnnotation(method, ManagedOperation.class); return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedOperation.class); }
Example #28
Source File: AnnotationJmxAttributeSource.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public org.springframework.jmx.export.metadata.ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException { ManagedMetric ann = AnnotationUtils.findAnnotation(method, ManagedMetric.class); return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedMetric.class); }
Example #29
Source File: AnnotationJmxAttributeSource.java From java-technology-stack with MIT License | 4 votes |
@Override @Nullable public org.springframework.jmx.export.metadata.ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException { ManagedMetric ann = AnnotationUtils.findAnnotation(method, ManagedMetric.class); return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedMetric.class); }
Example #30
Source File: AnnotationJmxAttributeSource.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public org.springframework.jmx.export.metadata.ManagedMetric getManagedMetric(Method method) throws InvalidMetadataException { ManagedMetric ann = AnnotationUtils.findAnnotation(method, ManagedMetric.class); return copyPropertiesToBean(ann, org.springframework.jmx.export.metadata.ManagedMetric.class); }