Package org.springframework.beans.factory.support

# Class RegisteredBean

java.lang.Object
org.springframework.beans.factory.support.RegisteredBean

public final class RegisteredBean extends Object
A `RegisteredBean` represents a bean that has been registered with a `BeanFactory`, but has not necessarily been instantiated. It provides access to the bean factory that contains the bean as well as the bean name. In the case of inner-beans, the bean name may have been generated.

Since:
  6.0
Author:
  Phillip Webb, Stephane Nicoll, Juergen Hoeller

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final record`
`RegisteredBean.InstantiationDescriptor`
Descriptor for how a bean should be instantiated.

## Method Summary

Modifier and Type
Method
Description
`Class<?>`
`getBeanClass()`
Return the user-defined class of the bean.
`ConfigurableListableBeanFactory`
`getBeanFactory()`
Return the bean factory containing the bean.
`String`
`getBeanName()`
Return the name of the bean.
`org.springframework.core.ResolvableType`
`getBeanType()`
Return the `ResolvableType` of the bean.
`RootBeanDefinition`
`getMergedBeanDefinition()`
Return the merged bean definition of the bean.
`RegisteredBean`
`getParent()`
Return the parent of this instance or `null` if not an inner-bean.
`boolean`
`isGeneratedBeanName()`
Return if the bean name is generated.
`boolean`
`isInnerBean()`
Return if this instance is for an inner-bean.
`static RegisteredBean`
`of(ConfigurableListableBeanFactory beanFactory, String beanName)`
Create a new `RegisteredBean` instance for a regular bean.
`static RegisteredBean`
`ofInnerBean(RegisteredBean parent, String innerBeanName, BeanDefinition innerBeanDefinition)`
Create a new `RegisteredBean` instance for an inner-bean.
`static RegisteredBean`
`ofInnerBean(RegisteredBean parent, BeanDefinition innerBeanDefinition)`
Create a new `RegisteredBean` instance for an inner-bean.
`static RegisteredBean`
`ofInnerBean(RegisteredBean parent, BeanDefinitionHolder innerBean)`
Create a new `RegisteredBean` instance for an inner-bean.
`Object`
`resolveAutowiredArgument(DependencyDescriptor descriptor, TypeConverter typeConverter, Set<String> autowiredBeanNames)`
Resolve an autowired argument.
`Executable`
`resolveConstructorOrFactoryMethod()`
Deprecated.
in favor of `resolveInstantiationDescriptor()`
`RegisteredBean.InstantiationDescriptor`
`resolveInstantiationDescriptor()`
Resolve the descriptor to use to instantiate this bean.
`String`
`toString()`

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

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

## Method Details

### of

public static RegisteredBean of(ConfigurableListableBeanFactory beanFactory, String beanName)
Create a new `RegisteredBean` instance for a regular bean.

Parameters:
  `beanFactory` - the source bean factory
  `beanName` - the bean name
Returns:
  a new `RegisteredBean` instance

### ofInnerBean

public static RegisteredBean ofInnerBean(RegisteredBean parent, BeanDefinitionHolder innerBean)
Create a new `RegisteredBean` instance for an inner-bean.

Parameters:
  `parent` - the parent of the inner-bean
  `innerBean` - a `BeanDefinitionHolder` for the inner bean
Returns:
  a new `RegisteredBean` instance

### ofInnerBean

public static RegisteredBean ofInnerBean(RegisteredBean parent, BeanDefinition innerBeanDefinition)
Create a new `RegisteredBean` instance for an inner-bean.

Parameters:
  `parent` - the parent of the inner-bean
  `innerBeanDefinition` - the inner-bean definition
Returns:
  a new `RegisteredBean` instance

### ofInnerBean

public static RegisteredBean ofInnerBean(RegisteredBean parent, @Nullable String innerBeanName, BeanDefinition innerBeanDefinition)
Create a new `RegisteredBean` instance for an inner-bean.

Parameters:
  `parent` - the parent of the inner-bean
  `innerBeanName` - the name of the inner bean or `null` to generate a name
  `innerBeanDefinition` - the inner-bean definition
Returns:
  a new `RegisteredBean` instance

### getBeanName

public String getBeanName()
Return the name of the bean.

Returns:
  the beanName the bean name

### isGeneratedBeanName

public boolean isGeneratedBeanName()
Return if the bean name is generated.

Returns:
  `true` if the name was generated

### getBeanFactory

public ConfigurableListableBeanFactory getBeanFactory()
Return the bean factory containing the bean.

Returns:
  the bean factory

### getBeanClass

public Class<?> getBeanClass()
Return the user-defined class of the bean.

Returns:
  the bean class

### getBeanType

public org.springframework.core.ResolvableType getBeanType()
Return the `ResolvableType` of the bean.

Returns:
  the bean type

### getMergedBeanDefinition

public RootBeanDefinition getMergedBeanDefinition()
Return the merged bean definition of the bean.

Returns:
  the merged bean definition
See Also:
  - `ConfigurableBeanFactory.getMergedBeanDefinition(String)`

### isInnerBean

public boolean isInnerBean()
Return if this instance is for an inner-bean.

Returns:
  if an inner-bean

### getParent

@Nullable public RegisteredBean getParent()
Return the parent of this instance or `null` if not an inner-bean.

Returns:
  the parent

### resolveConstructorOrFactoryMethod

@Deprecated(since="6.1.7") public Executable resolveConstructorOrFactoryMethod()
Deprecated.
in favor of `resolveInstantiationDescriptor()`
Resolve the constructor or factory method to use for this bean.

Returns:
  the `Constructor` or `Method`

### resolveInstantiationDescriptor

public RegisteredBean.InstantiationDescriptor resolveInstantiationDescriptor()
Resolve the descriptor to use to instantiate this bean. It defines the `Constructor` or `Method` to use as well as additional metadata.

Since:
  6.1.7

### resolveAutowiredArgument

@Nullable public Object resolveAutowiredArgument(DependencyDescriptor descriptor, TypeConverter typeConverter, Set<String> autowiredBeanNames)
Resolve an autowired argument.

Parameters:
  `descriptor` - the descriptor for the dependency (field/method/constructor)
  `typeConverter` - the TypeConverter to use for populating arrays and collections
  `autowiredBeanNames` - a Set that all names of autowired beans (used for resolving the given dependency) are supposed to be added to
Returns:
  the resolved object, or `null` if none found
Since:
  6.0.9

### toString

public String toString()

Overrides:
  `toString` in class `Object`