001: /*
002: * Copyright 2002-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.beans.factory.config;
018:
019: import org.springframework.beans.BeansException;
020: import org.springframework.beans.factory.ListableBeanFactory;
021: import org.springframework.beans.factory.NoSuchBeanDefinitionException;
022:
023: /**
024: * Configuration interface to be implemented by most listable bean factories.
025: * In addition to {@link ConfigurableBeanFactory}, it provides facilities to
026: * analyze and modify bean definitions, and to pre-instantiate singletons.
027: *
028: * <p>This subinterface of {@link org.springframework.beans.factory.BeanFactory}
029: * is not meant to be used in normal application code: Stick to
030: * {@link org.springframework.beans.factory.BeanFactory} or
031: * {@link org.springframework.beans.factory.ListableBeanFactory} for typical
032: * use cases. This interface is just meant to allow for framework-internal
033: * plug'n'play even when needing access to bean factory configuration methods.
034: *
035: * @author Juergen Hoeller
036: * @since 03.11.2003
037: * @see org.springframework.context.support.AbstractApplicationContext#getBeanFactory()
038: */
039: public interface ConfigurableListableBeanFactory extends
040: ListableBeanFactory, AutowireCapableBeanFactory,
041: ConfigurableBeanFactory {
042:
043: /**
044: * Ignore the given dependency type for autowiring:
045: * for example, String. Default is none.
046: * @param type the dependency type to ignore
047: */
048: void ignoreDependencyType(Class type);
049:
050: /**
051: * Ignore the given dependency interface for autowiring.
052: * <p>This will typically be used by application contexts to register
053: * dependencies that are resolved in other ways, like BeanFactory through
054: * BeanFactoryAware or ApplicationContext through ApplicationContextAware.
055: * <p>By default, only the BeanFactoryAware interface is ignored.
056: * For further types to ignore, invoke this method for each type.
057: * @param ifc the dependency interface to ignore
058: * @see org.springframework.beans.factory.BeanFactoryAware
059: * @see org.springframework.context.ApplicationContextAware
060: */
061: void ignoreDependencyInterface(Class ifc);
062:
063: /**
064: * Register a special dependency type with corresponding autowired value.
065: * <p>This is intended for factory/context references that are supposed
066: * to be autowirable but are not defined as beans in the factory:
067: * e.g. a dependency of type ApplicationContext resolved to the
068: * ApplicationContext instance that the bean is living in.
069: * <p>Note: There are no such default types registered in a plain BeanFactory,
070: * not even for the BeanFactory interface itself.
071: * @param dependencyType the dependency type to register. This will typically
072: * be a base interface such as BeanFactory, with extensions of it resolved
073: * as well if declared as an autowiring dependency (e.g. ListableBeanFactory),
074: * as long as the given value actually implements the extended interface.
075: * @param autowiredValue the corresponding autowired value
076: */
077: void registerResolvableDependency(Class dependencyType,
078: Object autowiredValue);
079:
080: /**
081: * Determine whether the specified bean qualifies as an autowire candidate,
082: * to be injected into other beans which declare a dependency of matching type.
083: * <p>This method checks ancestor factories as well.
084: * @param beanName the name of the bean to check
085: * @param descriptor the descriptor of the dependency to resolve
086: * @return whether the bean should be considered as autowire candidate
087: * @throws NoSuchBeanDefinitionException if there is no bean with the given name
088: */
089: boolean isAutowireCandidate(String beanName,
090: DependencyDescriptor descriptor)
091: throws NoSuchBeanDefinitionException;
092:
093: /**
094: * Return whether the bean definition for the given bean name and instance
095: * has been marked as a primary bean.
096: */
097: boolean isPrimary(String beanName, Object beanInstance);
098:
099: /**
100: * Return the registered BeanDefinition for the specified bean, allowing access
101: * to its property values and constructor argument value (which can be
102: * modified during bean factory post-processing).
103: * <p>A returned BeanDefinition object should not be a copy but the original
104: * definition object as registered in the factory. This means that it should
105: * be castable to a more specific implementation type, if necessary.
106: * <p><b>NOTE:</b> This method does <i>not</i> consider ancestor factories.
107: * It is only meant for accessing local bean definitions of this factory.
108: * @param beanName the name of the bean
109: * @return the registered BeanDefinition
110: * @throws NoSuchBeanDefinitionException if there is no bean with the given name
111: * defined in this factory
112: */
113: BeanDefinition getBeanDefinition(String beanName)
114: throws NoSuchBeanDefinitionException;
115:
116: /**
117: * Ensure that all non-lazy-init singletons are instantiated, also considering
118: * {@link org.springframework.beans.factory.FactoryBean FactoryBeans}.
119: * Typically invoked at the end of factory setup, if desired.
120: * @throws BeansException if one of the singleton beans could not be created.
121: * Note: This may have left the factory with some beans already initialized!
122: * Call {@link #destroySingletons()} for full cleanup in this case.
123: * @see #destroySingletons()
124: */
125: void preInstantiateSingletons() throws BeansException;
126:
127: }
|