Bean method metadata exposed through AnnotatedBeanDefinition
Issue: SPR-12232
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.annotation;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
|
||||
/**
|
||||
* Extended {@link org.springframework.beans.factory.config.BeanDefinition}
|
||||
@@ -38,4 +39,11 @@ public interface AnnotatedBeanDefinition extends BeanDefinition {
|
||||
*/
|
||||
AnnotationMetadata getMetadata();
|
||||
|
||||
/**
|
||||
* Obtain metadata for this bean definition's factory method, if any.
|
||||
* @return the factory method metadata, or {@code null} if none
|
||||
* @since 4.1.1
|
||||
*/
|
||||
MethodMetadata getFactoryMethodMetadata();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package org.springframework.beans.factory.annotation;
|
||||
|
||||
import org.springframework.beans.factory.support.GenericBeanDefinition;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
import org.springframework.core.type.StandardAnnotationMetadata;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -43,6 +44,8 @@ public class AnnotatedGenericBeanDefinition extends GenericBeanDefinition implem
|
||||
|
||||
private final AnnotationMetadata metadata;
|
||||
|
||||
private MethodMetadata factoryMethodMetadata;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new AnnotatedGenericBeanDefinition for the given bean class.
|
||||
@@ -74,10 +77,29 @@ public class AnnotatedGenericBeanDefinition extends GenericBeanDefinition implem
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AnnotatedGenericBeanDefinition for the given annotation metadata,
|
||||
* based on an annotated class and a factory method on that class.
|
||||
* @param metadata the annotation metadata for the bean class in question
|
||||
* @param factoryMethodMetadata metadata for the selected factory method
|
||||
* @since 4.1.1
|
||||
*/
|
||||
public AnnotatedGenericBeanDefinition(AnnotationMetadata metadata, MethodMetadata factoryMethodMetadata) {
|
||||
this(metadata);
|
||||
Assert.notNull(factoryMethodMetadata, "MethodMetadata must not be null");
|
||||
setFactoryMethodName(factoryMethodMetadata.getMethodName());
|
||||
this.factoryMethodMetadata = factoryMethodMetadata;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final AnnotationMetadata getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final MethodMetadata getFactoryMethodMetadata() {
|
||||
return this.factoryMethodMetadata;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user