Top Description Inners Fields Constructors Methods
org.springframework.context.annotation

public abstract Class ResourceElementResolver

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.context.annotation.ResourceElementResolver.ResourceFieldResolver, org.springframework.context.annotation.ResourceElementResolver.ResourceMethodResolver
Imports
java.lang.reflect.AnnotatedElement, .Field, .Method, java.util.Collections, .LinkedHashSet, .Set, org.springframework.aop.TargetSource, org.springframework.aop.framework.ProxyFactory, org.springframework.beans.factory.NoSuchBeanDefinitionException, org.springframework.beans.factory.config.ConfigurableListableBeanFactory, .DependencyDescriptor, org.springframework.beans.factory.support.RegisteredBean, org.springframework.core.MethodParameter, org.springframework.lang.Nullable, org.springframework.util.Assert, .ReflectionUtils, .StringUtils

Resolver for the injection of named beans on a field or method element, following the rules of the jakarta.annotation.Resource annotation but without any JNDI support. This is primarily intended for AOT processing.
Authors
Stephane Nicoll, Juergen Hoeller
Since
6.1.2
See Also
CommonAnnotationBeanPostProcessor, jakarta.annotation.Resource

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ResourceElementResolver.LookupDependencyDescriptor

Extension of the DependencyDescriptor class, overriding the dependency type with the specified resource type.

private static class
private static class

Field Summary

Modifier and TypeField and Description
private final boolean
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
ResourceElementResolver(String name, boolean defaultName)

Method Summary

Modifier and TypeMethod and Description
private Object
pack-priv abstract DependencyDescriptor

Returns:

a descriptor for that bean
createDependencyDescriptor
(RegisteredBean
the registered bean
registeredBean
)

Create a suitable DependencyDescriptor for the specified bean.

private static String
public static ResourceElementResolver

Returns:

a new ResourceFieldResolver instance
forField
(String
the field name
fieldName
)

Create a new ResourceFieldResolver for the specified field.

public static ResourceElementResolver

Returns:

a new ResourceFieldResolver instance
forField
(String
the field name
fieldName
,
String
the resource name
resourceName
)

Create a new ResourceFieldResolver for the specified field and resource name.

public static ResourceElementResolver

Returns:

a new ResourceMethodResolver instance
forMethod
(String
the method name
methodName
,
Class<?>
the parameter type.
parameterType
)

Create a new ResourceMethodResolver for the specified method using a resource name that infers from the method name.

public static ResourceElementResolver

Returns:

a new ResourceMethodResolver instance
forMethod
(String
the method name
methodName
,
Class<?>
the parameter type
parameterType
,
String
the resource name
resourceName
)

Create a new ResourceMethodResolver for the specified method and resource name.

pack-priv abstract AnnotatedElement
pack-priv abstract Class<?>
getLookupType(RegisteredBean registeredBean)

pack-priv boolean
isLazyLookup(RegisteredBean registeredBean)

public <T> T

Returns:

the resolved field or method parameter value
resolve
(RegisteredBean
the registered bean
registeredBean
)

Resolve the value for the specified registered bean.

public abstract void
resolveAndSet(RegisteredBean
the registered bean
registeredBean
,
Object
the bean instance
instance
)

Resolve the value for the specified registered bean and set it using reflection.

private Object

Returns:

the value to inject
resolveValue
(RegisteredBean
the bean registration
registeredBean
)

Resolve the value to inject for this instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultNameback to summary
private final boolean defaultName
nameback to summary
private final String name

Constructor Detail

ResourceElementResolverback to summary
pack-priv ResourceElementResolver(String name, boolean defaultName)

Method Detail

buildLazyResourceProxyback to summary
private Object buildLazyResourceProxy(RegisteredBean registeredBean)
createDependencyDescriptorback to summary
pack-priv abstract DependencyDescriptor createDependencyDescriptor(RegisteredBean registeredBean)

Create a suitable DependencyDescriptor for the specified bean.

Parameters
registeredBean:RegisteredBean

the registered bean

Returns:DependencyDescriptor

a descriptor for that bean

defaultResourceNameForMethodback to summary
private static String defaultResourceNameForMethod(String methodName)
forFieldback to summary
public static ResourceElementResolver forField(String fieldName)

Create a new ResourceFieldResolver for the specified field.

Parameters
fieldName:String

the field name

Returns:ResourceElementResolver

a new ResourceFieldResolver instance

forFieldback to summary
public static ResourceElementResolver forField(String fieldName, String resourceName)

Create a new ResourceFieldResolver for the specified field and resource name.

Parameters
fieldName:String

the field name

resourceName:String

the resource name

Returns:ResourceElementResolver

a new ResourceFieldResolver instance

forMethodback to summary
public static ResourceElementResolver forMethod(String methodName, Class<?> parameterType)

Create a new ResourceMethodResolver for the specified method using a resource name that infers from the method name.

Parameters
methodName:String

the method name

parameterType:Class<?>

the parameter type.

Returns:ResourceElementResolver

a new ResourceMethodResolver instance

forMethodback to summary
public static ResourceElementResolver forMethod(String methodName, Class<?> parameterType, String resourceName)

Create a new ResourceMethodResolver for the specified method and resource name.

Parameters
methodName:String

the method name

parameterType:Class<?>

the parameter type

resourceName:String

the resource name

Returns:ResourceElementResolver

a new ResourceMethodResolver instance

getAnnotatedElementback to summary
pack-priv abstract AnnotatedElement getAnnotatedElement(RegisteredBean registeredBean)
getLookupTypeback to summary
pack-priv abstract Class<?> getLookupType(RegisteredBean registeredBean)
isLazyLookupback to summary
pack-priv boolean isLazyLookup(RegisteredBean registeredBean)
resolveback to summary
public <T> T resolve(RegisteredBean registeredBean)

Resolve the value for the specified registered bean.

Parameters
registeredBean:RegisteredBean

the registered bean

Returns:T

the resolved field or method parameter value

Annotations
@Nullable
@SuppressWarnings:unchecked
resolveAndSetback to summary
public abstract void resolveAndSet(RegisteredBean registeredBean, Object instance)

Resolve the value for the specified registered bean and set it using reflection.

Parameters
registeredBean:RegisteredBean

the registered bean

instance:Object

the bean instance

resolveValueback to summary
private Object resolveValue(RegisteredBean registeredBean)

Resolve the value to inject for this instance.

Parameters
registeredBean:RegisteredBean

the bean registration

Returns:Object

the value to inject

org.springframework.context.annotation back to summary

pack-priv Class ResourceElementResolver.LookupDependencyDescriptor

extends DependencyDescriptor
Class Inheritance
Annotations
@SuppressWarnings:serial

Extension of the DependencyDescriptor class, overriding the dependency type with the specified resource type.

Field Summary

Modifier and TypeField and Description
private final boolean
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
LookupDependencyDescriptor(Field field, Class<?> lookupType, boolean lazyLookup)

public
LookupDependencyDescriptor(Method method, Class<?> lookupType, boolean lazyLookup)

Method Summary

Modifier and TypeMethod and Description
public Class<?>
getDependencyType()

Overrides org.springframework.beans.factory.config.DependencyDescriptor.getDependencyType.

Determine the declared (non-generic) type of the wrapped parameter/field.

public boolean
supportsLazyResolution()

Overrides org.springframework.beans.factory.config.DependencyDescriptor.supportsLazyResolution.

Determine whether this dependency supports lazy resolution, e.g. through extra proxying.

Inherited from org.springframework.beans.factory.config.DependencyDescriptor:
equalsfallbackMatchAllowedforFallbackMatchgetDependencyNamegetResolvableTypegetTypeDescriptorhashCodeincreaseNestingLevelinitParameterNameDiscoveryisEagerisRequiredresolveCandidateresolveNotUniqueresolveShortcutsetContainingClass

Field Detail

lazyLookupback to summary
private final boolean lazyLookup
lookupTypeback to summary
private final Class<?> lookupType

Constructor Detail

LookupDependencyDescriptorback to summary
public LookupDependencyDescriptor(Field field, Class<?> lookupType, boolean lazyLookup)
LookupDependencyDescriptorback to summary
public LookupDependencyDescriptor(Method method, Class<?> lookupType, boolean lazyLookup)

Method Detail

getDependencyTypeback to summary
public Class<?> getDependencyType()

Overrides org.springframework.beans.factory.config.DependencyDescriptor.getDependencyType.

Doc from org.springframework.beans.factory.config.DependencyDescriptor.getDependencyType.

Determine the declared (non-generic) type of the wrapped parameter/field.

Returns:Class<?>

the declared type (never null)

Annotations
@Override
supportsLazyResolutionback to summary
public boolean supportsLazyResolution()

Overrides org.springframework.beans.factory.config.DependencyDescriptor.supportsLazyResolution.

Doc from org.springframework.beans.factory.config.DependencyDescriptor.supportsLazyResolution.

Determine whether this dependency supports lazy resolution, e.g. through extra proxying. The default is true.

Annotations
@Override
org.springframework.context.annotation back to summary

private final Class ResourceElementResolver.ResourceFieldResolver

extends ResourceElementResolver
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public
ResourceFieldResolver(String name, boolean defaultName, String fieldName)

Method Summary

Modifier and TypeMethod and Description
protected DependencyDescriptor
createDependencyDescriptor(RegisteredBean
the registered bean
registeredBean
)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.createDependencyDescriptor.

Create a suitable DependencyDescriptor for the specified bean.

protected AnnotatedElement
private Field
getField(RegisteredBean registeredBean)

protected Class<?>
public void
resolveAndSet(RegisteredBean
the registered bean
registeredBean
,
Object
the bean instance
instance
)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.resolveAndSet.

Resolve the value for the specified registered bean and set it using reflection.

Inherited from org.springframework.context.annotation.ResourceElementResolver:
forFieldforFieldforMethodforMethodisLazyLookupresolve

Field Detail

fieldNameback to summary
private final String fieldName

Constructor Detail

ResourceFieldResolverback to summary
public ResourceFieldResolver(String name, boolean defaultName, String fieldName)

Method Detail

createDependencyDescriptorback to summary
protected DependencyDescriptor createDependencyDescriptor(RegisteredBean registeredBean)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.createDependencyDescriptor.

Doc from org.springframework.context.annotation.ResourceElementResolver.createDependencyDescriptor.

Create a suitable DependencyDescriptor for the specified bean.

Parameters
registeredBean:RegisteredBean

the registered bean

Returns:DependencyDescriptor

a descriptor for that bean

Annotations
@Override
getAnnotatedElementback to summary
protected AnnotatedElement getAnnotatedElement(RegisteredBean registeredBean)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.getAnnotatedElement.

Annotations
@Override
getFieldback to summary
private Field getField(RegisteredBean registeredBean)
getLookupTypeback to summary
protected Class<?> getLookupType(RegisteredBean registeredBean)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.getLookupType.

Annotations
@Override
resolveAndSetback to summary
public void resolveAndSet(RegisteredBean registeredBean, Object instance)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.resolveAndSet.

Doc from org.springframework.context.annotation.ResourceElementResolver.resolveAndSet.

Resolve the value for the specified registered bean and set it using reflection.

Parameters
registeredBean:RegisteredBean

the registered bean

instance:Object

the bean instance

Annotations
@Override
org.springframework.context.annotation back to summary

private final Class ResourceElementResolver.ResourceMethodResolver

extends ResourceElementResolver
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final String

Constructor Summary

AccessConstructor and Description
private
ResourceMethodResolver(String name, boolean defaultName, String methodName, Class<?> lookupType)

Method Summary

Modifier and TypeMethod and Description
protected DependencyDescriptor
createDependencyDescriptor(RegisteredBean
the registered bean
registeredBean
)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.createDependencyDescriptor.

Create a suitable DependencyDescriptor for the specified bean.

protected AnnotatedElement
protected Class<?>
private Method
getMethod(RegisteredBean registeredBean)

public void
resolveAndSet(RegisteredBean
the registered bean
registeredBean
,
Object
the bean instance
instance
)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.resolveAndSet.

Resolve the value for the specified registered bean and set it using reflection.

Inherited from org.springframework.context.annotation.ResourceElementResolver:
forFieldforFieldforMethodforMethodisLazyLookupresolve

Field Detail

lookupTypeback to summary
private final Class<?> lookupType
methodNameback to summary
private final String methodName

Constructor Detail

ResourceMethodResolverback to summary
private ResourceMethodResolver(String name, boolean defaultName, String methodName, Class<?> lookupType)

Method Detail

createDependencyDescriptorback to summary
protected DependencyDescriptor createDependencyDescriptor(RegisteredBean registeredBean)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.createDependencyDescriptor.

Doc from org.springframework.context.annotation.ResourceElementResolver.createDependencyDescriptor.

Create a suitable DependencyDescriptor for the specified bean.

Parameters
registeredBean:RegisteredBean

the registered bean

Returns:DependencyDescriptor

a descriptor for that bean

Annotations
@Override
getAnnotatedElementback to summary
protected AnnotatedElement getAnnotatedElement(RegisteredBean registeredBean)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.getAnnotatedElement.

Annotations
@Override
getLookupTypeback to summary
protected Class<?> getLookupType(RegisteredBean bean)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.getLookupType.

Annotations
@Override
getMethodback to summary
private Method getMethod(RegisteredBean registeredBean)
resolveAndSetback to summary
public void resolveAndSet(RegisteredBean registeredBean, Object instance)

Implements abstract org.springframework.context.annotation.ResourceElementResolver.resolveAndSet.

Doc from org.springframework.context.annotation.ResourceElementResolver.resolveAndSet.

Resolve the value for the specified registered bean and set it using reflection.

Parameters
registeredBean:RegisteredBean

the registered bean

instance:Object

the bean instance

Annotations
@Override