Skip to content

Commit 4ebf09a

Browse files
committed
Restructure bootstrap classes to a foundational layer
Move bootstrap code from `org.springframework.boot` to `org.springframework.boot.bootstrap` and make them a foundational layer. This move helps reduce `org.springframework.boot.context.config` dependencies to `org.springframework.boot`. See gh-47232
1 parent b02371f commit 4ebf09a

File tree

50 files changed

+120
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+120
-89
lines changed

config/checkstyle/import-control.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
<!-- Allow other imports -->
1414
<allow pkg=".*" regex="true" />
1515

16-
<!-- Keep foundation packages away from SpringApplication package -->
16+
<!-- Keep foundation packages away from 'org.springframework.boot' package -->
17+
<subpackage name="bootstrap">
18+
<disallow pkg="org.springframework.boot" exact-match="true"/>
19+
</subpackage>
1720
<subpackage name="ssl">
1821
<disallow pkg="org.springframework.boot" exact-match="true"/>
1922
</subpackage>

core/spring-boot-test/src/main/java/org/springframework/boot/test/context/ConfigDataApplicationContextInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
package org.springframework.boot.test.context;
1818

19-
import org.springframework.boot.DefaultBootstrapContext;
2019
import org.springframework.boot.DefaultPropertiesPropertySource;
20+
import org.springframework.boot.bootstrap.DefaultBootstrapContext;
2121
import org.springframework.boot.context.config.ConfigData;
2222
import org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor;
2323
import org.springframework.boot.env.RandomValuePropertySource;

core/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
import org.springframework.beans.BeanUtils;
3131
import org.springframework.boot.ApplicationContextFactory;
3232
import org.springframework.boot.Banner;
33-
import org.springframework.boot.ConfigurableBootstrapContext;
3433
import org.springframework.boot.SpringApplication;
3534
import org.springframework.boot.SpringApplication.AbandonedRunException;
3635
import org.springframework.boot.SpringApplicationHook;
3736
import org.springframework.boot.SpringApplicationRunListener;
3837
import org.springframework.boot.SpringBootConfiguration;
3938
import org.springframework.boot.WebApplicationType;
39+
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
4040
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
4141
import org.springframework.boot.test.context.SpringBootTest.UseMainMethod;
4242
import org.springframework.boot.test.mock.web.SpringBootMockServletContext;

core/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
import org.springframework.beans.factory.support.RootBeanDefinition;
5959
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
6060
import org.springframework.boot.Banner.Mode;
61+
import org.springframework.boot.bootstrap.BootstrapRegistry;
62+
import org.springframework.boot.bootstrap.BootstrapRegistryInitializer;
63+
import org.springframework.boot.bootstrap.DefaultBootstrapContext;
6164
import org.springframework.boot.context.properties.bind.Bindable;
6265
import org.springframework.boot.context.properties.bind.Binder;
6366
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;

core/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.jspecify.annotations.Nullable;
2222

23+
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
2324
import org.springframework.context.ApplicationContext;
2425
import org.springframework.context.ConfigurableApplicationContext;
2526
import org.springframework.core.env.ConfigurableEnvironment;

core/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.commons.logging.Log;
2424
import org.jspecify.annotations.Nullable;
2525

26+
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
2627
import org.springframework.context.ConfigurableApplicationContext;
2728
import org.springframework.core.env.ConfigurableEnvironment;
2829
import org.springframework.core.metrics.ApplicationStartup;

core/spring-boot/src/main/java/org/springframework/boot/BootstrapContext.java renamed to core/spring-boot/src/main/java/org/springframework/boot/bootstrap/BootstrapContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot;
17+
package org.springframework.boot.bootstrap;
1818

1919
import java.util.function.Supplier;
2020

@@ -31,7 +31,7 @@
3131
* shared before the {@link ApplicationContext} is available.
3232
*
3333
* @author Phillip Webb
34-
* @since 2.4.0
34+
* @since 4.0.0
3535
*/
3636
public interface BootstrapContext {
3737

core/spring-boot/src/main/java/org/springframework/boot/BootstrapContextClosedEvent.java renamed to core/spring-boot/src/main/java/org/springframework/boot/bootstrap/BootstrapContextClosedEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot;
17+
package org.springframework.boot.bootstrap;
1818

1919
import org.springframework.context.ApplicationEvent;
2020
import org.springframework.context.ConfigurableApplicationContext;
@@ -23,7 +23,7 @@
2323
* {@link ApplicationEvent} published by a {@link BootstrapContext} when it's closed.
2424
*
2525
* @author Phillip Webb
26-
* @since 2.4.0
26+
* @since 4.0.0
2727
* @see BootstrapRegistry#addCloseListener(org.springframework.context.ApplicationListener)
2828
*/
2929
public class BootstrapContextClosedEvent extends ApplicationEvent {

core/spring-boot/src/main/java/org/springframework/boot/BootstrapRegistry.java renamed to core/spring-boot/src/main/java/org/springframework/boot/bootstrap/BootstrapRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot;
17+
package org.springframework.boot.bootstrap;
1818

1919
import java.util.function.Supplier;
2020

@@ -42,7 +42,7 @@
4242
* use.
4343
*
4444
* @author Phillip Webb
45-
* @since 2.4.0
45+
* @since 4.0.0
4646
* @see BootstrapContext
4747
* @see ConfigurableBootstrapContext
4848
*/

core/spring-boot/src/main/java/org/springframework/boot/BootstrapRegistryInitializer.java renamed to core/spring-boot/src/main/java/org/springframework/boot/bootstrap/BootstrapRegistryInitializer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot;
17+
package org.springframework.boot.bootstrap;
1818

1919
/**
2020
* Callback interface that can be used to initialize a {@link BootstrapRegistry} before it
2121
* is used.
2222
*
2323
* @author Phillip Webb
24-
* @since 2.4.5
25-
* @see SpringApplication#addBootstrapRegistryInitializer(BootstrapRegistryInitializer)
24+
* @since 4.0.0
2625
* @see BootstrapRegistry
2726
*/
2827
@FunctionalInterface

0 commit comments

Comments
 (0)