    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.configuration2.beanutils;
    018
    019/**
    020 * <p>
    021 * Definition of a context object storing all required information for the creation of a bean.
    022 * </p>
    023 * <p>
    024 * An object implementing this interface is passed to a {@link BeanFactory}. The interface also contains methods for the
    025 * creation and initialization of nested beans (for example constructor arguments or complex properties of the bean to be
    026 * created).
    027 * </p>
    028 *
    029 * @since 2.0
    030 */
    031public interface BeanCreationContext {
    032
    033    /**
    034     * Creates a bean based on the given {@code BeanDeclaration}. This method can be used to create dependent beans needed
    035     * for the initialization of the bean that is actually created.
    036     *
    037     * @param data the {@code BeanDeclaration} describing the bean
    038     * @return the bean created based on this declaration
    039     */
    040    Object createBean(BeanDeclaration data);
    041
    042    /**
    043     * Gets the class of the bean to be created.
    044     *
    045     * @return the bean class
    046     */
    047    Class<?> getBeanClass();
    048
    049    /**
    050     * Gets the {@code BeanDeclaration} with the data for the new bean. This data is used to initialize the bean's
    051     * properties.
    052     *
    053     * @return the {@code BeanDeclaration} defining the bean to be created
    054     */
    055    BeanDeclaration getBeanDeclaration();
    056
    057    /**
    058     * Gets the (optional) parameter object for the bean factory. This is a mechanism which can be used to pass custom
    059     * parameters to a {@link BeanFactory}.
    060     *
    061     * @return the parameter for the bean factory
    062     */
    063    Object getParameter();
    064
    065    /**
    066     * Initializes a bean's property based on the given {@code BeanDeclaration}.
    067     *
    068     * @param bean the bean to be initialized
    069     * @param data the {@code BeanDeclaration} with initialization data for this bean
    070     */
    071    void initBean(Object bean, BeanDeclaration data);
    072}