    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 (e.g. 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     * Gets the class of the bean to be created.
    035     *
    036     * @return the bean class
    037     */
    038    Class<?> getBeanClass();
    039
    040    /**
    041     * Gets the {@code BeanDeclaration} with the data for the new bean. This data is used to initialize the bean's
    042     * properties.
    043     *
    044     * @return the {@code BeanDeclaration} defining the bean to be created
    045     */
    046    BeanDeclaration getBeanDeclaration();
    047
    048    /**
    049     * Gets the (optional) parameter object for the bean factory. This is a mechanism which can be used to pass custom
    050     * parameters to a {@link BeanFactory}.
    051     *
    052     * @return the parameter for the bean factory
    053     */
    054    Object getParameter();
    055
    056    /**
    057     * Initializes a bean's property based on the given {@code BeanDeclaration}.
    058     *
    059     * @param bean the bean to be initialized
    060     * @param data the {@code BeanDeclaration} with initialization data for this bean
    061     */
    062    void initBean(Object bean, BeanDeclaration data);
    063
    064    /**
    065     * Creates a bean based on the given {@code BeanDeclaration}. This method can be used to create dependent beans needed
    066     * for the initialization of the bean that is actually created.
    067     *
    068     * @param data the {@code BeanDeclaration} describing the bean
    069     * @return the bean created based on this declaration
    070     */
    071    Object createBean(BeanDeclaration data);
    072}