Polish BeanRegistrar Javadoc and add tests for non-invocation semantics

Revise the BeanRegistrar Javadoc to document the two distinct usage
modes: @Configuration/@Import and programmatic GenericApplicationContext
setup.

Clarify that implementations are not Spring components (requiring a
no-arg constructor and no dependency injection), and detail the ordering
guarantees for each mode.

Add missing tests

Signed-off-by: Stéphane Nicoll <stephane.nicoll@broadcom.com>
This commit is contained in:
Stéphane Nicoll
2026-04-02 11:18:58 +02:00
committed by Juergen Hoeller
parent 5dc4a3a7a0
commit d5b6f4a7ee
5 changed files with 176 additions and 65 deletions
@@ -1,46 +0,0 @@
/*
* Copyright 2002-present 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.context;
import org.springframework.beans.factory.BeanRegistrar;
import org.springframework.beans.factory.BeanRegistry;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.env.Environment;
/**
* A variant of {@link BeanRegistrar} which aims to be invoked
* at the end of the bean registration phase, coming after regular
* bean definition reading and configuration class processing.
*
* <p>This allows for seeing all user-registered beans, potentially
* reacting to their presence. The {@code containsBean} methods on
* {@link BeanRegistry} will provide reliable answers, independent
* of the order of user bean registration versus {@code BeanRegistrar}
* import/registration.
*
* @author Juergen Hoeller
* @since 7.1
* @see #register(BeanRegistry, Environment)
* @see BeanRegistry#containsBean(String)
* @see BeanRegistry#containsBean(Class)
* @see BeanRegistry#containsBean(ParameterizedTypeReference)
* @see org.springframework.context.support.GenericApplicationContext#register( BeanRegistrar...)
* @see org.springframework.context.annotation.Import
*/
public interface DeferredBeanRegistrar extends BeanRegistrar {
}