|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2025 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
16 | 16 |
|
17 | 17 | package org.springframework.test.context.aot;
|
18 | 18 |
|
| 19 | +import org.springframework.aot.hint.RuntimeHints; |
19 | 20 | import org.springframework.context.ApplicationContext;
|
20 | 21 | import org.springframework.context.ApplicationContextInitializer;
|
21 | 22 | import org.springframework.context.ConfigurableApplicationContext;
|
|
25 | 26 |
|
26 | 27 | /**
|
27 | 28 | * Strategy interface for loading an {@link ApplicationContext} for build-time
|
28 |
| - * {@linkplain #loadContextForAotProcessing AOT processing} as well as run-time |
29 |
| - * {@linkplain #loadContextForAotRuntime AOT execution} for an integration test |
30 |
| - * managed by the Spring TestContext Framework. |
| 29 | + * {@linkplain #loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints) |
| 30 | + * AOT processing} as well as run-time {@linkplain #loadContextForAotRuntime |
| 31 | + * AOT execution} for an integration test managed by the Spring TestContext Framework. |
31 | 32 | *
|
32 | 33 | * <p>{@code AotContextLoader} is an extension of the {@link SmartContextLoader}
|
33 | 34 | * SPI that allows a context loader to optionally provide ahead-of-time (AOT)
|
@@ -69,10 +70,38 @@ public interface AotContextLoader extends SmartContextLoader {
|
69 | 70 | * application context
|
70 | 71 | * @return a new {@code GenericApplicationContext}
|
71 | 72 | * @throws ContextLoadException if context loading failed
|
| 73 | + * @see #loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints) |
72 | 74 | * @see #loadContextForAotRuntime(MergedContextConfiguration, ApplicationContextInitializer)
|
73 | 75 | */
|
74 | 76 | ApplicationContext loadContextForAotProcessing(MergedContextConfiguration mergedConfig) throws Exception;
|
75 | 77 |
|
| 78 | + /** |
| 79 | + * Load a new {@link ApplicationContext} for AOT build-time processing based |
| 80 | + * on the supplied {@link MergedContextConfiguration}, configure the context, |
| 81 | + * and return the context. |
| 82 | + * <p>This variant of {@code loadContextForAotProcessing(...)} accepts a |
| 83 | + * {@link RuntimeHints} argument. See the documentation for |
| 84 | + * {@link #loadContextForAotProcessing(MergedContextConfiguration)} for details |
| 85 | + * regarding the contract of this method. |
| 86 | + * <p>The default implementation of this method delegates to |
| 87 | + * {@code loadContextForAotProcessing(MergedContextConfiguration)}. Note, |
| 88 | + * however, that the framework only invokes this method as of Spring Framework |
| 89 | + * 6.2.4. |
| 90 | + * @param mergedConfig the merged context configuration to use to load the |
| 91 | + * application context |
| 92 | + * @param runtimeHints the runtime hints |
| 93 | + * @return a new {@code GenericApplicationContext} |
| 94 | + * @throws ContextLoadException if context loading failed |
| 95 | + * @see #loadContextForAotProcessing(MergedContextConfiguration) |
| 96 | + * @see #loadContextForAotRuntime(MergedContextConfiguration, ApplicationContextInitializer) |
| 97 | + * @since 6.2.4 |
| 98 | + */ |
| 99 | + default ApplicationContext loadContextForAotProcessing(MergedContextConfiguration mergedConfig, |
| 100 | + RuntimeHints runtimeHints) throws Exception { |
| 101 | + |
| 102 | + return loadContextForAotProcessing(mergedConfig); |
| 103 | + } |
| 104 | + |
76 | 105 | /**
|
77 | 106 | * Load a new {@link ApplicationContext} for AOT run-time execution based on
|
78 | 107 | * the supplied {@link MergedContextConfiguration} and
|
|
0 commit comments