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