public class CombinedBeanDeclaration extends Object implements BeanDeclaration
A special implementation of the BeanDeclaration
interface which
allows combining multiple BeanDeclaration
objects.
An instance of this class can be used if a bean is defined using multiple sources. For instance, there can be one definition with default values and one with actual values; if actual values are provided, they are used; otherwise, the default values apply.
When constructing an instance an arbitrary number of child
BeanDeclaration
objects can be specified. The implementations of the
BeanDeclaration
methods implement a logical combination of the data
returned by these child declarations. The order in which child declarations
are added is relevant; first entries take precedence over later ones. The
comments of the single methods explain in which way a combination of the
child declarations is built.
Constructor and Description |
---|
CombinedBeanDeclaration(BeanDeclaration... decl)
Creates a new instance of
CombinedBeanDeclaration and initializes
it with the given child declarations. |
Modifier and Type | Method and Description |
---|---|
String |
getBeanClassName()
Returns the name of the bean class, from which an instance is to be
created.
|
String |
getBeanFactoryName()
Returns the name of the
BeanFactory that should be used
for creating the bean instance. |
Object |
getBeanFactoryParameter()
Here an arbitrary object can be returned that will be passed to the bean
factory.
|
Map<String,Object> |
getBeanProperties()
Returns a map with properties that should be initialized on the newly
created bean.
|
Collection<ConstructorArg> |
getConstructorArgs()
Returns a collection with constructor arguments.
|
Map<String,Object> |
getNestedBeanDeclarations()
Returns a map with declarations for beans that should be set as
properties of the newly created bean.
|
public CombinedBeanDeclaration(BeanDeclaration... decl)
CombinedBeanDeclaration
and initializes
it with the given child declarations.decl
- the child declarationsNullPointerException
- if the array with child declarations is
nullpublic String getBeanFactoryName()
BeanFactory
that should be used
for creating the bean instance. This can be null, then a default
factory will be used. This implementation iterates over the list of child
declarations and asks them for a bean factory name. The first
non-null value is returned. If none of the child declarations have
a defined bean factory name, result is null.getBeanFactoryName
in interface BeanDeclaration
public Object getBeanFactoryParameter()
getBeanFactoryParameter
in interface BeanDeclaration
public String getBeanClassName()
getBeanClassName
in interface BeanDeclaration
public Map<String,Object> getBeanProperties()
getBeanProperties
in interface BeanDeclaration
public Map<String,Object> getNestedBeanDeclarations()
BeanDeclaration
implementations or collections thereof. They will be treated like this
declaration (in a recursive manner), and the resulting beans are
assigned to the corresponding properties. This implementation creates a union of the nested bean
declarations returned by all child declarations. If a complex property is
defined in multiple child declarations, the declaration that comes before
in the list of children takes precedence.getNestedBeanDeclarations
in interface BeanDeclaration
public Collection<ConstructorArg> getConstructorArgs()
getConstructorArgs
in interface BeanDeclaration
Copyright © 2001–2020 The Apache Software Foundation. All rights reserved.