org.apache.commons.configuration2.beanutils

## Interface BeanDeclaration

- All Known Implementing Classes:
    CombinedBeanDeclaration, ConfigurationDeclaration, XMLBeanDeclaration

      public interface BeanDeclaration

  Definition of an interface for declaring a bean in a configuration file.

  Commons Configurations allows to define beans (i.e. simple Java objects) in configuration files, which can be created at runtime. This is especially useful if you program against interfaces and want to define the concrete implementation class is a configuration file.

  This interface defines methods for retrieving all information about a bean that should be created from a configuration file, e.g. the bean's properties or the factory to use for creating the instance. With different implementations different "layouts" of bean declarations can be supported. For instance if an XML configuration file is used, all features of XML (e.g. attributes, nested elements) can be used to define the bean. In a properties file the declaration format is more limited. The purpose of this interface is to abstract from the concrete declaration format.

  Since:
    1.3
  Author:
    Commons Configuration team

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    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.

- - ### Method Detail

    - #### getBeanFactoryName

          String getBeanFactoryName()

      Returns the name of the `BeanFactory` that should be used for creating the bean instance. This can be null, then a default factory will be used.
      Returns:
        the name of the bean factory

    - #### getBeanFactoryParameter

          Object getBeanFactoryParameter()

      Here an arbitrary object can be returned that will be passed to the bean factory. Its meaning is not further specified. The purpose of this additional parameter is to support a further configuration of the bean factory that can be placed directly at the bean declaration.
      Returns:
        a parameter for the bean factory

    - #### getBeanClassName

          String getBeanClassName()

      Returns the name of the bean class, from which an instance is to be created. This value must be defined unless a default class is provided for the bean creation operation.
      Returns:
        the name of the bean class

    - #### getBeanProperties

          Map<String,Object> getBeanProperties()

      Returns a map with properties that should be initialized on the newly created bean. The map's keys are the names of the properties; the corresponding values are the properties' values. The return value can be null if no properties should be set.
      Returns:
        a map with properties to be initialized

    - #### getNestedBeanDeclarations

          Map<String,Object> getNestedBeanDeclarations()

      Returns a map with declarations for beans that should be set as properties of the newly created bean. This allows for complex initialization scenarios: a bean for a bean that contains complex properties (e.g. other beans) can have nested declarations for defining these complex properties. The returned map's key are the names of the properties to initialize. The values are either `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.
      Returns:
        a map with nested bean declarations

    - #### getConstructorArgs

          Collection<ConstructorArg> getConstructorArgs()

      Returns a collection with constructor arguments. This data is used to determine the constructor of the bean class to be invoked. The values of the arguments are passed to the constructor. An implementation can return null or an empty collection; then the standard constructor of the bean class is called.
      Returns:
        a collection with the arguments to be passed to the bean class's constructor

Copyright © 2001–2019 The Apache Software Foundation. All rights reserved.