Class InjectionMetadata
- java.lang.Object
- org.springframework.beans.factory.annotation.InjectionMetadata
public class InjectionMetadata extends Object
Internal class for managing injection metadata. Not intended for direct use in applications.Used by
AutowiredAnnotationBeanPostProcessor,CommonAnnotationBeanPostProcessorandPersistenceAnnotationBeanPostProcessor.- Since:
- 2.5
- Author:
- Juergen Hoeller
Nested Class Summary
Nested Classes Modifier and Type Class Description static classInjectionMetadata.InjectedElementA single injected element.
Field Summary
Fields Modifier and Type Field Description static InjectionMetadataEMPTYAn emptyInjectionMetadatainstance with no-op callbacks.
Constructor Summary
Constructors Constructor Description InjectionMetadata(Class<?> targetClass, Collection<InjectionMetadata.InjectedElement> elements)Create a newInjectionMetadata instance.
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckConfigMembers(RootBeanDefinition beanDefinition)voidclear(PropertyValues pvs)Clear property skipping for the contained elements.static InjectionMetadataforElements(Collection<InjectionMetadata.InjectedElement> elements, Class<?> clazz)Return anInjectionMetadatainstance, possibly for empty elements.voidinject(Object target, String beanName, PropertyValues pvs)protected booleanneedsRefresh(Class<?> clazz)Determine whether this metadata instance needs to be refreshed.static booleanneedsRefresh(InjectionMetadata metadata, Class<?> clazz)Check whether the given injection metadata needs to be refreshed.
Field Detail
EMPTY
public static final InjectionMetadata EMPTY
An emptyInjectionMetadatainstance with no-op callbacks.- Since:
- 5.2
Constructor Detail
InjectionMetadata
public InjectionMetadata(Class<?> targetClass, Collection<InjectionMetadata.InjectedElement> elements)
Create a newInjectionMetadata instance.Preferably use
forElements(java.util.Collection<org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement>, java.lang.Class<?>)for reusing theEMPTYinstance in case of no elements.- Parameters:
targetClass- the target classelements- the associated elements to inject- See Also:
forElements(java.util.Collection<org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement>, java.lang.Class<?>)
Method Detail
needsRefresh
protected boolean needsRefresh(Class<?> clazz)
Determine whether this metadata instance needs to be refreshed.- Parameters:
clazz- the current target class- Returns:
trueindicating a refresh,falseotherwise- Since:
- 5.2.4
checkConfigMembers
public void checkConfigMembers(RootBeanDefinition beanDefinition)
inject
public void inject(Object target, @Nullable String beanName, @Nullable PropertyValues pvs) throws Throwable
- Throws:
Throwable
clear
public void clear(@Nullable PropertyValues pvs)
Clear property skipping for the contained elements.- Since:
- 3.2.13
forElements
public static InjectionMetadata forElements(Collection<InjectionMetadata.InjectedElement> elements, Class<?> clazz)
Return anInjectionMetadatainstance, possibly for empty elements.- Parameters:
elements- the elements to inject (possibly empty)clazz- the target class- Returns:
- a new
InjectionMetadata(Class, Collection)instance - Since:
- 5.2
needsRefresh
public static boolean needsRefresh(@Nullable InjectionMetadata metadata, Class<?> clazz)
Check whether the given injection metadata needs to be refreshed.- Parameters:
metadata- the existing metadata instanceclazz- the current target class- Returns:
trueindicating a refresh,falseotherwise- See Also:
needsRefresh(Class)