Spring Framework

org.springframework.beans.factory.config
Class BeanDefinitionHolder

java.lang.Object
  extended by org.springframework.beans.factory.config.BeanDefinitionHolder
All Implemented Interfaces:
BeanMetadataElement
Direct Known Subclasses:
BeanComponentDefinition

public class BeanDefinitionHolder
extends java.lang.Object
implements BeanMetadataElement

Holder for a BeanDefinition with name and aliases. Can be registered as a placeholder for an inner bean.

Can also be used for programmatic registration of inner bean definitions. If you don't care about BeanNameAware and the like, registering RootBeanDefinition or ChildBeanDefinition is good enough.

Since:
1.0.2
Author:
Juergen Hoeller
See Also:
BeanNameAware, RootBeanDefinition, ChildBeanDefinition

Constructor Summary
BeanDefinitionHolder(BeanDefinitionHolder beanDefinitionHolder)
          Copy constructor: Create a new BeanDefinitionHolder with the same contents as the given BeanDefinitionHolder instance.
BeanDefinitionHolder(BeanDefinition beanDefinition, java.lang.String beanName)
          Create a new BeanDefinitionHolder.
BeanDefinitionHolder(BeanDefinition beanDefinition, java.lang.String beanName, java.lang.String[] aliases)
          Create a new BeanDefinitionHolder.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.lang.String[] getAliases()
          Return the alias names for the bean, as specified directly for the bean definition.
 BeanDefinition getBeanDefinition()
          Return the wrapped BeanDefinition.
 java.lang.String getBeanName()
          Return the primary name of the bean, as specified for the bean definition.
 java.lang.String getLongDescription()
          Return a long description for the bean, including name and aliases as well as a description of the contained BeanDefinition.
 java.lang.String getShortDescription()
          Return a friendly, short description for the bean, stating name and aliases.
 java.lang.Object getSource()
          Expose the bean definition's source object.
 int hashCode()
           
 boolean matchesName(java.lang.String candidateName)
          Determine whether the given candidate name matches the bean name or the aliases stored in this bean definition.
 java.lang.String toString()
          This implementation returns the long description.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BeanDefinitionHolder

public BeanDefinitionHolder(BeanDefinition beanDefinition,
                            java.lang.String beanName)
Create a new BeanDefinitionHolder.

Parameters:
beanDefinition - the BeanDefinition to wrap
beanName - the name of the bean, as specified for the bean definition

BeanDefinitionHolder

public BeanDefinitionHolder(BeanDefinition beanDefinition,
                            java.lang.String beanName,
                            java.lang.String[] aliases)
Create a new BeanDefinitionHolder.

Parameters:
beanDefinition - the BeanDefinition to wrap
beanName - the name of the bean, as specified for the bean definition
aliases - alias names for the bean, or null if none

BeanDefinitionHolder

public BeanDefinitionHolder(BeanDefinitionHolder beanDefinitionHolder)
Copy constructor: Create a new BeanDefinitionHolder with the same contents as the given BeanDefinitionHolder instance.

Note: The wrapped BeanDefinition reference is taken as-is; it is not deeply copied.

Parameters:
beanDefinitionHolder - the BeanDefinitionHolder to copy
Method Detail

getBeanDefinition

public BeanDefinition getBeanDefinition()
Return the wrapped BeanDefinition.


getBeanName

public java.lang.String getBeanName()
Return the primary name of the bean, as specified for the bean definition.


getAliases

public java.lang.String[] getAliases()
Return the alias names for the bean, as specified directly for the bean definition.

Returns:
the array of alias names, or null if none

getSource

public java.lang.Object getSource()
Expose the bean definition's source object.

Specified by:
getSource in interface BeanMetadataElement
See Also:
BeanMetadataElement.getSource()

matchesName

public boolean matchesName(java.lang.String candidateName)
Determine whether the given candidate name matches the bean name or the aliases stored in this bean definition.


getShortDescription

public java.lang.String getShortDescription()
Return a friendly, short description for the bean, stating name and aliases.

See Also:
getBeanName(), getAliases()

getLongDescription

public java.lang.String getLongDescription()
Return a long description for the bean, including name and aliases as well as a description of the contained BeanDefinition.

See Also:
getShortDescription(), getBeanDefinition()

toString

public java.lang.String toString()
This implementation returns the long description. Can be overridden to return the short description or any kind of custom description instead.

Overrides:
toString in class java.lang.Object
See Also:
getLongDescription(), getShortDescription()

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

Spring Framework