use of org.springframework.core.type.MethodMetadata in project spring-boot by spring-projects.
the class NoSuchBeanDefinitionFailureAnalyzer method collectReportedConditionOutcomes.
private void collectReportedConditionOutcomes(NoSuchBeanDefinitionException cause, List<AutoConfigurationResult> results) {
for (Map.Entry<String, ConditionAndOutcomes> entry : this.report.getConditionAndOutcomesBySource().entrySet()) {
Source source = new Source(entry.getKey());
ConditionAndOutcomes conditionAndOutcomes = entry.getValue();
if (!conditionAndOutcomes.isFullMatch()) {
BeanMethods methods = new BeanMethods(source, cause);
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
if (!conditionAndOutcome.getOutcome().isMatch()) {
for (MethodMetadata method : methods) {
results.add(new AutoConfigurationResult(method, conditionAndOutcome.getOutcome(), source.isMethod()));
}
}
}
}
}
}
use of org.springframework.core.type.MethodMetadata in project spring-boot by spring-projects.
the class BeanTypeRegistry method getFactoryMethod.
private Method getFactoryMethod(ConfigurableListableBeanFactory beanFactory, BeanDefinition definition) throws Exception {
if (definition instanceof AnnotatedBeanDefinition) {
MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition).getFactoryMethodMetadata();
if (factoryMethodMetadata instanceof StandardMethodMetadata) {
return ((StandardMethodMetadata) factoryMethodMetadata).getIntrospectedMethod();
}
}
BeanDefinition factoryDefinition = beanFactory.getBeanDefinition(definition.getFactoryBeanName());
Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(), beanFactory.getBeanClassLoader());
return getFactoryMethod(definition, factoryClass);
}
use of org.springframework.core.type.MethodMetadata in project spring-boot by spring-projects.
the class AbstractConfigurationClassTests method allBeanMethodsArePublic.
@Test
public void allBeanMethodsArePublic() throws IOException, ClassNotFoundException {
Set<String> nonPublicBeanMethods = new HashSet<>();
for (AnnotationMetadata configurationClass : findConfigurationClasses()) {
Set<MethodMetadata> beanMethods = configurationClass.getAnnotatedMethods(Bean.class.getName());
for (MethodMetadata methodMetadata : beanMethods) {
if (!isPublic(methodMetadata)) {
nonPublicBeanMethods.add(methodMetadata.getDeclaringClassName() + "." + methodMetadata.getMethodName());
}
}
}
assertThat(nonPublicBeanMethods).as("Found non-public @Bean methods").isEmpty();
}
use of org.springframework.core.type.MethodMetadata in project spring-data-commons by spring-projects.
the class DefaultMethodsMetadataReaderUnitTests method shouldReadClassMethods.
// DATACMNS-1206
@Test
void shouldReadClassMethods() throws IOException {
MethodsMetadata metadata = getMethodsMetadata(Foo.class);
assertThat(metadata.getMethods()).hasSize(3);
Iterator<MethodMetadata> iterator = metadata.getMethods().iterator();
assertThat(iterator.next().getMethodName()).isEqualTo("one");
assertThat(iterator.next().getMethodName()).isEqualTo("two");
assertThat(iterator.next().getMethodName()).isEqualTo("three");
}
use of org.springframework.core.type.MethodMetadata in project spring-data-commons by spring-projects.
the class DefaultMethodsMetadataReaderUnitTests method shouldReadInterfaceMethods.
// DATACMNS-1206
@Test
void shouldReadInterfaceMethods() throws IOException {
MethodsMetadata metadata = getMethodsMetadata(Baz.class);
assertThat(metadata.getMethods()).hasSize(3);
Iterator<MethodMetadata> iterator = metadata.getMethods().iterator();
assertThat(iterator.next().getMethodName()).isEqualTo("one");
assertThat(iterator.next().getMethodName()).isEqualTo("two");
assertThat(iterator.next().getMethodName()).isEqualTo("three");
}
Aggregations