Package org.springframework.context.annotation

# Class ResourceElementResolver

java.lang.Object
org.springframework.context.annotation.ResourceElementResolver

public abstract class ResourceElementResolver extends Object
Resolver for the injection of named beans on a field or method element, following the rules of the `Resource` annotation but without any JNDI support. This is primarily intended for AOT processing.

Since:
  6.1.2
Author:
  Stephane Nicoll, Juergen Hoeller
See Also:
  - `CommonAnnotationBeanPostProcessor`
  - `Resource`

## Method Summary

Modifier and Type
Method
Description
`static ResourceElementResolver`
`forField(String fieldName)`
Create a new `ResourceElementResolver.ResourceFieldResolver` for the specified field.
`static ResourceElementResolver`
`forField(String fieldName, String resourceName)`
Create a new `ResourceElementResolver.ResourceFieldResolver` for the specified field and resource name.
`static ResourceElementResolver`
`forMethod(String methodName, Class<?> parameterType)`
Create a new `ResourceElementResolver.ResourceMethodResolver` for the specified method using a resource name that infers from the method name.
`static ResourceElementResolver`
`forMethod(String methodName, Class<?> parameterType, String resourceName)`
Create a new `ResourceElementResolver.ResourceMethodResolver` for the specified method and resource name.
`<T> T`
`resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean)`
Resolve the value for the specified registered bean.
`abstract void`
`resolveAndSet(org.springframework.beans.factory.support.RegisteredBean registeredBean, Object instance)`
Resolve the value for the specified registered bean and set it using reflection.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### forField

public static ResourceElementResolver forField(String fieldName)
Create a new `ResourceElementResolver.ResourceFieldResolver` for the specified field.

Parameters:
  `fieldName` - the field name
Returns:
  a new `ResourceElementResolver.ResourceFieldResolver` instance

### forField

public static ResourceElementResolver forField(String fieldName, String resourceName)
Create a new `ResourceElementResolver.ResourceFieldResolver` for the specified field and resource name.

Parameters:
  `fieldName` - the field name
  `resourceName` - the resource name
Returns:
  a new `ResourceElementResolver.ResourceFieldResolver` instance

### forMethod

public static ResourceElementResolver forMethod(String methodName, Class<?> parameterType)
Create a new `ResourceElementResolver.ResourceMethodResolver` for the specified method using a resource name that infers from the method name.

Parameters:
  `methodName` - the method name
  `parameterType` - the parameter type.
Returns:
  a new `ResourceElementResolver.ResourceMethodResolver` instance

### forMethod

public static ResourceElementResolver forMethod(String methodName, Class<?> parameterType, String resourceName)
Create a new `ResourceElementResolver.ResourceMethodResolver` for the specified method and resource name.

Parameters:
  `methodName` - the method name
  `parameterType` - the parameter type
  `resourceName` - the resource name
Returns:
  a new `ResourceElementResolver.ResourceMethodResolver` instance

### resolve

@Nullable public <T> T resolve(org.springframework.beans.factory.support.RegisteredBean registeredBean)
Resolve the value for the specified registered bean.

Parameters:
  `registeredBean` - the registered bean
Returns:
  the resolved field or method parameter value

### resolveAndSet

public abstract void resolveAndSet(org.springframework.beans.factory.support.RegisteredBean registeredBean, Object instance)
Resolve the value for the specified registered bean and set it using reflection.

Parameters:
  `registeredBean` - the registered bean
  `instance` - the bean instance