Clarify BeanFactory#containsBean Javadoc

Previously, #containsBean Javadoc advertised that a true return value
indicates that a call to #getBean for the same name would succeed.

This is actually not the case, and has never been.  The semantics
of #containsBean have always been to indicate whether a bean definition
with the given name is definied or a singleton instance with the given
name has been registered.

The Javadoc now reflects this accurately.

Issue: SPR-8690
This commit is contained in:
Chris Beams
2011-09-13 22:09:12 +00:00
parent bc57f72bbb
commit 10be0ef9e7
2 changed files with 25 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -181,12 +181,19 @@ public interface BeanFactory {
Object getBean(String name, Object... args) throws BeansException;
/**
* Does this bean factory contain a bean with the given name? More specifically,
* is {@link #getBean} able to obtain a bean instance for the given name?
* <p>Translates aliases back to the corresponding canonical bean name.
* Will ask the parent factory if the bean cannot be found in this factory instance.
* Does this bean factory contain a bean definition or externally registered singleton
* instance with the given name?
* <p>If the given name is an alias, it will be translated back to the corresponding
* canonical bean name.
* <p>If this factory is hierarchical, will ask any parent factory if the bean cannot
* be found in this factory instance.
* <p>If a bean definition or singleton instance matching the given name is found,
* this method will return {@code true} whether the named bean definition is concrete
* or abstract, lazy or eager, in scope or not. Therefore, note that a {@code true}
* return value from this method does not necessarily indicate that {@link #getBean}
* will be able to obtain an instance for the same name.
* @param name the name of the bean to query
* @return whether a bean with the given name is defined
* @return whether a bean with the given name is present
*/
boolean containsBean(String name);