Top Description Inners Fields Constructors Methods
org.springframework.beans.factory.annotation

public Class InjectionMetadata

extends Object
Class Inheritance
Imports
java.beans.PropertyDescriptor, java.lang.reflect.Field, .InvocationTargetException, .Member, .Method, java.util.Collection, .Collections, .LinkedHashSet, .Set, org.springframework.beans.MutablePropertyValues, .PropertyValues, org.springframework.beans.factory.support.RootBeanDefinition, org.springframework.lang.Nullable, org.springframework.util.ReflectionUtils

Internal class for managing injection metadata.

Not intended for direct use in applications.

Used by AutowiredAnnotationBeanPostProcessor, org.springframework.context.annotation.CommonAnnotationBeanPostProcessor, and org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.

Author
Juergen Hoeller
Since
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public abstract static class
InjectionMetadata.InjectedElement

A single injected element.

Field Summary

Modifier and TypeField and Description
private volatile Set<InjectionMetadata.InjectedElement>
public static final InjectionMetadata
EMPTY

An empty InjectionMetadata instance with no-op callbacks.

private final Collection<InjectionMetadata.InjectedElement>
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
InjectionMetadata(Class<?>
the target class
targetClass
,
Collection<InjectionMetadata.InjectedElement>
the associated elements to inject
elements
)

Create a new InjectionMetadata instance.

Method Summary

Modifier and TypeMethod and Description
public void
public void
clear(PropertyValues pvs)

Clear property skipping for the contained elements.

public static InjectionMetadata

Returns:

a new InjectionMetadata(Class, Collection) instance
forElements
(Collection<InjectionMetadata.InjectedElement>
the elements to inject (possibly empty)
elements
,
Class<?>
the target class
clazz
)

Return an InjectionMetadata instance, possibly for empty elements.

public Collection<InjectionMetadata.InjectedElement>

Returns:

the elements to inject
getInjectedElements
()

Return the elements to inject.

public Collection<InjectionMetadata.InjectedElement>

Returns:

the elements to inject
getInjectedElements
(PropertyValues
the property values to consider
pvs
)

Return the elements to inject based on the specified PropertyValues.

public void
inject(Object target, String beanName, PropertyValues pvs)

protected boolean

Returns:

true indicating a refresh, false otherwise
needsRefresh
(Class<?>
the current target class
clazz
)

Determine whether this metadata instance needs to be refreshed.

public static boolean

Returns:

true indicating a refresh, false otherwise
needsRefresh
(InjectionMetadata
the existing metadata instance
metadata
,
Class<?>
the current target class
clazz
)

Check whether the given injection metadata needs to be refreshed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

checkedElementsback to summary
private volatile Set<InjectionMetadata.InjectedElement> checkedElements
Annotations
@Nullable
EMPTYback to summary
public static final InjectionMetadata EMPTY

An empty InjectionMetadata instance with no-op callbacks.

Since
5.2
injectedElementsback to summary
private final Collection<InjectionMetadata.InjectedElement> injectedElements
targetClassback to summary
private final Class<?> targetClass

Constructor Detail

InjectionMetadataback to summary
public InjectionMetadata(Class<?> targetClass, Collection<InjectionMetadata.InjectedElement> elements)

Create a new InjectionMetadata instance.

Preferably use forElements for reusing the EMPTY instance in case of no elements.

Parameters
targetClass:Class<?>

the target class

elements:Collection<InjectionMetadata.InjectedElement>

the associated elements to inject

See Also
forElements

Method Detail

checkConfigMembersback to summary
public void checkConfigMembers(RootBeanDefinition beanDefinition)
clearback to summary
public void clear(PropertyValues pvs)

Clear property skipping for the contained elements.

Since
3.2.13
forElementsback to summary
public static InjectionMetadata forElements(Collection<InjectionMetadata.InjectedElement> elements, Class<?> clazz)

Return an InjectionMetadata instance, possibly for empty elements.

Parameters
elements:Collection<InjectionMetadata.InjectedElement>

the elements to inject (possibly empty)

clazz:Class<?>

the target class

Returns:InjectionMetadata

a new InjectionMetadata(Class, Collection) instance

Since
5.2
getInjectedElementsback to summary
public Collection<InjectionMetadata.InjectedElement> getInjectedElements()

Return the elements to inject.

Returns:Collection<InjectionMetadata.InjectedElement>

the elements to inject

getInjectedElementsback to summary
public Collection<InjectionMetadata.InjectedElement> getInjectedElements(PropertyValues pvs)

Return the elements to inject based on the specified PropertyValues. If a property is already defined for an InjectedElement, it is excluded.

Parameters
pvs:PropertyValues

the property values to consider

Returns:Collection<InjectionMetadata.InjectedElement>

the elements to inject

Since
6.0.10
injectback to summary
public void inject(Object target, String beanName, PropertyValues pvs) throws Throwable
needsRefreshback to summary
protected boolean needsRefresh(Class<?> clazz)

Determine whether this metadata instance needs to be refreshed.

Parameters
clazz:Class<?>

the current target class

Returns:boolean

true indicating a refresh, false otherwise

Since
5.2.4
needsRefreshback to summary
public static boolean needsRefresh(InjectionMetadata metadata, Class<?> clazz)

Check whether the given injection metadata needs to be refreshed.

Parameters
metadata:InjectionMetadata

the existing metadata instance

clazz:Class<?>

the current target class

Returns:boolean

true indicating a refresh, false otherwise

See Also
needsRefresh(Class)
org.springframework.beans.factory.annotation back to summary

public abstract Class InjectionMetadata.InjectedElement

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement
Known Direct Subclasses
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.AutowiredElement

A single injected element.

Field Summary

Modifier and TypeField and Description
protected final boolean
protected final Member
protected final PropertyDescriptor
protected volatile Boolean

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
protected boolean
checkPropertySkipping(PropertyValues pvs)

Check whether this injector's property needs to be skipped due to an explicit property value having been specified.

protected final void
checkResourceType(Class<?> resourceType)

protected void
clearPropertySkipping(PropertyValues pvs)

Clear property skipping for this element.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public final Member
protected Object
getResourceToInject(Object target, String requestingBeanName)

Either this or inject needs to be overridden.

protected final Class<?>
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

protected void
inject(Object target, String requestingBeanName, PropertyValues pvs)

Either this or getResourceToInject needs to be overridden.

protected boolean

Returns:

whether the property values should be injected
shouldInject
(PropertyValues
property values to check
pvs
)

Whether the property values should be injected.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

isFieldback to summary
protected final boolean isField
memberback to summary
protected final Member member
pdback to summary
protected final PropertyDescriptor pd
Annotations
@Nullable
skipback to summary
protected volatile Boolean skip
Annotations
@Nullable

Constructor Detail

InjectedElementback to summary
protected InjectedElement(Member member, PropertyDescriptor pd)

Method Detail

checkPropertySkippingback to summary
protected boolean checkPropertySkipping(PropertyValues pvs)

Check whether this injector's property needs to be skipped due to an explicit property value having been specified. Also marks the affected property as processed for other processors to ignore it.

checkResourceTypeback to summary
protected final void checkResourceType(Class<?> resourceType)
clearPropertySkippingback to summary
protected void clearPropertySkipping(PropertyValues pvs)

Clear property skipping for this element.

Since
3.2.13
equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getMemberback to summary
public final Member getMember()
getResourceToInjectback to summary
protected Object getResourceToInject(Object target, String requestingBeanName)

Either this or inject needs to be overridden.

Annotations
@Nullable
getResourceTypeback to summary
protected final Class<?> getResourceType()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
injectback to summary
protected void inject(Object target, String requestingBeanName, PropertyValues pvs) throws Throwable

Either this or getResourceToInject needs to be overridden.

shouldInjectback to summary
protected boolean shouldInject(PropertyValues pvs)

Whether the property values should be injected.

Parameters
pvs:PropertyValues

property values to check

Returns:boolean

whether the property values should be injected

Since
6.0.10
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override