001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.configuration.beanutils;
018
019import java.util.Map;
020
021/**
022 * <p>
023 * Definition of an interface for declaring a bean in a configuration file.
024 * </p>
025 * <p>
026 * Commons Configurations allows to define beans (i.e. simple Java objects) in
027 * configuration files, which can be created at runtime. This is especially
028 * useful if you program against interfaces and want to define the concrete
029 * implementation class is a configuration file.
030 * </p>
031 * <p>
032 * This interface defines methods for retrieving all information about a bean
033 * that should be created from a configuration file, e.g. the bean's properties
034 * or the factory to use for creating the instance. With different
035 * implementations different &quot;layouts&quot; of bean declarations can be
036 * supported. For instance if an XML configuration file is used, all features of
037 * XML (e.g. attributes, nested elements) can be used to define the bean. In a
038 * properties file the declaration format is more limited. The purpose of this
039 * interface is to abstract from the concrete declaration format.
040 * </p>
041 *
042 * @since 1.3
043 * @author <a
044 * href="http://commons.apache.org/configuration/team-list.html">Commons
045 * Configuration team</a>
046 * @version $Id: BeanDeclaration.java 1208756 2011-11-30 20:37:32Z oheger $
047 */
048public interface BeanDeclaration
049{
050    /**
051     * Returns the name of the {@code BeanFactory} that should be used
052     * for creating the bean instance. This can be <b>null</b>, then a default
053     * factory will be used.
054     *
055     * @return the name of the bean factory
056     */
057    String getBeanFactoryName();
058
059    /**
060     * Here an arbitrary object can be returned that will be passed to the bean
061     * factory. Its meaning is not further specified. The purpose of this
062     * additional parameter is to support a further configuration of the bean
063     * factory that can be placed directly at the bean declaration.
064     *
065     * @return a parameter for the bean factory
066     */
067    Object getBeanFactoryParameter();
068
069    /**
070     * Returns the name of the bean class, from which an instance is to be
071     * created. This value must be defined unless a default class is provided
072     * for the bean creation operation.
073     *
074     * @return the name of the bean class
075     */
076    String getBeanClassName();
077
078    /**
079     * Returns a map with properties that should be initialized on the newly
080     * created bean. The map's keys are the names of the properties; the
081     * corresponding values are the properties' values. The return value can be
082     * <b>null</b> if no properties should be set.
083     *
084     * @return a map with properties to be initialized
085     */
086    Map<String, Object> getBeanProperties();
087
088    /**
089     * Returns a map with declarations for beans that should be set as
090     * properties of the newly created bean. This allows for complex
091     * initialization scenarios: a bean for a bean that contains complex
092     * properties (e.g. other beans) can have nested declarations for defining
093     * these complex properties. The returned map's key are the names of the
094     * properties to initialize. The values are either {@code BeanDeclaration}
095     * implementations or collections thereof. They will be treated like this
096     * declaration (in a* recursive manner), and the resulting beans are
097     * assigned to the corresponding properties.
098     *
099     * @return a map with nested bean declarations
100     */
101    Map<String, Object> getNestedBeanDeclarations();
102}