1 /*The Spring Framework ConfigurableListableBeanFactory.java */ 2 3 /* 4 * Copyright 2002-2008 the original author or authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 package org.springframework.beans.factory.config; 20 21 import org.springframework.beans.BeansException; 22 import org.springframework.beans.factory.ListableBeanFactory; 23 import org.springframework.beans.factory.NoSuchBeanDefinitionException; 24 25 /** 26 * Configuration interface to be implemented by most listable bean factories. In 27 * addition to {@link ConfigurableBeanFactory}, it provides facilities to 28 * analyze and modify bean definitions, and to pre-instantiate singletons. 29 * 30 * <p> 31 * This subinterface of {@link org.springframework.beans.factory.BeanFactory} is 32 * not meant to be used in normal application code: Stick to 33 * {@link org.springframework.beans.factory.BeanFactory} or 34 * {@link org.springframework.beans.factory.ListableBeanFactory} for typical use 35 * cases. This interface is just meant to allow for framework-internal 36 * plug'n'play even when needing access to bean factory configuration methods. 37 * 38 * @author Juergen Hoeller 39 * @since 03.11.2003 40 * @see org.springframework.context.support.AbstractApplicationContext#getBeanFactory() 41 */ 42 public interface ConfigurableListableBeanFactory extends ListableBeanFactory, AutowireCapableBeanFactory, ConfigurableBeanFactory { 43 44 /** 45 * Ignore the given dependency type for autowiring: for example, String. 46 * Default is none. 47 * 48 * @param type 49 * the dependency type to ignore 50 */ 51 void ignoreDependencyType(Class type); 52 53 /** 54 * Ignore the given dependency interface for autowiring. 55 * <p> 56 * This will typically be used by application contexts to register 57 * dependencies that are resolved in other ways, like BeanFactory through 58 * BeanFactoryAware or ApplicationContext through ApplicationContextAware. 59 * <p> 60 * By default, only the BeanFactoryAware interface is ignored. For further 61 * types to ignore, invoke this method for each type. 62 * 63 * @param ifc 64 * the dependency interface to ignore 65 * @see org.springframework.beans.factory.BeanFactoryAware 66 * @see org.springframework.context.ApplicationContextAware 67 */ 68 void ignoreDependencyInterface(Class ifc); 69 70 /** 71 * Register a special dependency type with corresponding autowired value. 72 * <p> 73 * This is intended for factory/context references that are supposed to be 74 * autowirable but are not defined as beans in the factory: e.g. a 75 * dependency of type ApplicationContext resolved to the ApplicationContext 76 * instance that the bean is living in. 77 * <p> 78 * Note: There are no such default types registered in a plain BeanFactory, 79 * not even for the BeanFactory interface itself. 80 * 81 * @param dependencyType 82 * the dependency type to register. This will typically be a base 83 * interface such as BeanFactory, with extensions of it resolved 84 * as well if declared as an autowiring dependency (e.g. 85 * ListableBeanFactory), as long as the given value actually 86 * implements the extended interface. 87 * @param autowiredValue 88 * the corresponding autowired value. This may also be an 89 * implementation of the 90 * {@link org.springframework.beans.factory.ObjectFactory} 91 * interface, which allows for lazy resolution of the actual 92 * target value. 93 */ 94 void registerResolvableDependency(Class dependencyType, Object autowiredValue); 95 96 /** 97 * Determine whether the specified bean qualifies as an autowire candidate, 98 * to be injected into other beans which declare a dependency of matching 99 * type. 100 * <p> 101 * This method checks ancestor factories as well. 102 * 103 * @param beanName 104 * the name of the bean to check 105 * @param descriptor 106 * the descriptor of the dependency to resolve 107 * @return whether the bean should be considered as autowire candidate 108 * @throws NoSuchBeanDefinitionException 109 * if there is no bean with the given name 110 */ 111 boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException; 112 113 /** 114 * Return the registered BeanDefinition for the specified bean, allowing 115 * access to its property values and constructor argument value (which can 116 * be modified during bean factory post-processing). 117 * <p> 118 * A returned BeanDefinition object should not be a copy but the original 119 * definition object as registered in the factory. This means that it should 120 * be castable to a more specific implementation type, if necessary. 121 * <p> 122 * NOTE: This method does not consider ancestor factories. It is only meant 123 * for accessing local bean definitions of this factory. 124 * 125 * @param beanName 126 * the name of the bean 127 * @return the registered BeanDefinition 128 * @throws NoSuchBeanDefinitionException 129 * if there is no bean with the given name defined in this 130 * factory 131 */ 132 BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException; 133 134 /** 135 * Freeze all bean definitions, signalling that the registered bean 136 * definitions will not be modified or post-processed any further. 137 * <p> 138 * This allows the factory to aggressively cache bean definition metadata. 139 */ 140 void freezeConfiguration(); 141 142 /** 143 * Return whether this factory's bean definitions are frozen, i.e. are not 144 * supposed to be modified or post-processed any further. 145 * 146 * @return <code>true if the factory's configuration is considered frozen 147 */ 148 boolean isConfigurationFrozen(); 149 150 /** 151 * Ensure that all non-lazy-init singletons are instantiated, also 152 * considering {@link org.springframework.beans.factory.FactoryBean 153 * FactoryBeans}. Typically invoked at the end of factory setup, if desired. 154 * 155 * @throws BeansException 156 * if one of the singleton beans could not be created. Note: 157 * This may have left the factory with some beans already 158 * initialized! Call {@link #destroySingletons()} for full 159 * cleanup in this case. 160 * @see #destroySingletons() 161 */ 162 void preInstantiateSingletons() throws BeansException; 163 164 }