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     */
017    package org.apache.commons.configuration.beanutils;
018    
019    import 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 Oliver Heger
044     * @version $Id: BeanDeclaration.java 439648 2006-09-02 20:42:10Z oheger $
045     */
046    public interface BeanDeclaration
047    {
048        /**
049         * Returns the name of the <code>BeanFactory</code> that should be used
050         * for creating the bean instance. This can be <b>null</b>, then a default
051         * factory will be used.
052         *
053         * @return the name of the bean factory
054         */
055        String getBeanFactoryName();
056    
057        /**
058         * Here an arbitrary object can be returned that will be passed to the bean
059         * factory. Its meaning is not further specified. The purpose of this
060         * additional parameter is to support a further configuration of the bean
061         * factory that can be placed directly at the bean declaration.
062         *
063         * @return a parameter for the bean factory
064         */
065        Object getBeanFactoryParameter();
066    
067        /**
068         * Returns the name of the bean class, from which an instance is to be
069         * created. This value must be defined unless a default class is provided
070         * for the bean creation operation.
071         *
072         * @return the name of the bean class
073         */
074        String getBeanClassName();
075    
076        /**
077         * Returns a map with properties that should be initialized on the newly
078         * created bean. The map's keys are the names of the properties; the
079         * corresponding values are the properties' values. The return value can be
080         * <b>null</b> if no properties should be set.
081         *
082         * @return a map with properties to be initialized
083         */
084        Map getBeanProperties();
085    
086        /**
087         * Returns a map with declarations for beans that should be set as
088         * properties of the newly created bean. This allows for complex
089         * initialization szenarios: a bean for a bean that contains complex
090         * properties (e.g. other beans) can have nested declarations for defining
091         * these complex properties. The returned map's key are the names of the
092         * properties to initialze. The values are <code>BeanDeclaration</code>
093         * implementations. They will be treated like this declaration (in a
094         * recursive manner), and the resulting beans are assigned to the
095         * corresponding properties.
096         *
097         * @return a map with nested bean declarations
098         */
099        Map getNestedBeanDeclarations();
100    }