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)
42
43
*/
43
44
public interface AotContextLoader extends SmartContextLoader {
44
45
46
+ /**
47
+ * Load a new {@link ApplicationContext} for AOT build-time processing based
48
+ * on the supplied {@link MergedContextConfiguration}, configure the context,
49
+ * and return the context.
50
+ * <p>The default implementation of this method throws an
51
+ * {@link UnsupportedOperationException}. Note, however, that the framework
52
+ * invokes {@link #loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints)}
53
+ * as of Spring Framework 6.2.4.
54
+ * @param mergedConfig the merged context configuration to use to load the
55
+ * application context
56
+ * @return a new {@code GenericApplicationContext}
57
+ * @throws ContextLoadException if context loading failed
58
+ * @see #loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints)
59
+ * @see #loadContextForAotRuntime(MergedContextConfiguration, ApplicationContextInitializer)
60
+ * @deprecated as of Spring Framework 6.2.4, in favor of
61
+ * {@link #loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints)};
62
+ * to be removed in Spring Framework 8.0
63
+ */
64
+ @ Deprecated (since = "6.2.4" , forRemoval = true )
65
+ default ApplicationContext loadContextForAotProcessing (MergedContextConfiguration mergedConfig ) throws Exception {
66
+ throw new UnsupportedOperationException (
67
+ "Invoke loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints) instead" );
68
+ }
69
+
45
70
/**
46
71
* Load a new {@link ApplicationContext} for AOT build-time processing based
47
72
* on the supplied {@link MergedContextConfiguration}, configure the context,
@@ -65,13 +90,23 @@ public interface AotContextLoader extends SmartContextLoader {
65
90
* throw new ContextLoadException(context, ex);
66
91
* }
67
92
* </pre>
93
+ * <p>For backward compatibility, the default implementation of this method
94
+ * delegates to {@link #loadContextForAotProcessing(MergedContextConfiguration)}.
95
+ * Note, however, that the framework only invokes this method as of Spring
96
+ * Framework 6.2.4.
68
97
* @param mergedConfig the merged context configuration to use to load the
69
98
* application context
99
+ * @param runtimeHints the runtime hints
70
100
* @return a new {@code GenericApplicationContext}
71
101
* @throws ContextLoadException if context loading failed
102
+ * @since 6.2.4
72
103
* @see #loadContextForAotRuntime(MergedContextConfiguration, ApplicationContextInitializer)
73
104
*/
74
- ApplicationContext loadContextForAotProcessing (MergedContextConfiguration mergedConfig ) throws Exception ;
105
+ default ApplicationContext loadContextForAotProcessing (MergedContextConfiguration mergedConfig ,
106
+ RuntimeHints runtimeHints ) throws Exception {
107
+
108
+ return loadContextForAotProcessing (mergedConfig );
109
+ }
75
110
76
111
/**
77
112
* Load a new {@link ApplicationContext} for AOT run-time execution based on
@@ -98,7 +133,7 @@ public interface AotContextLoader extends SmartContextLoader {
98
133
* be applied to the context in order to recreate bean definitions
99
134
* @return a new {@code GenericApplicationContext}
100
135
* @throws ContextLoadException if context loading failed
101
- * @see #loadContextForAotProcessing(MergedContextConfiguration)
136
+ * @see #loadContextForAotProcessing(MergedContextConfiguration, RuntimeHints )
102
137
*/
103
138
ApplicationContext loadContextForAotRuntime (MergedContextConfiguration mergedConfig ,
104
139
ApplicationContextInitializer <ConfigurableApplicationContext > initializer ) throws Exception ;
0 commit comments