24
24
import java .util .function .Consumer ;
25
25
26
26
import org .jspecify .annotations .Nullable ;
27
+
28
+ import org .springframework .aot .generate .GenerationContext ;
27
29
import org .springframework .beans .factory .BeanFactory ;
28
30
import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
29
31
import org .springframework .beans .factory .config .BeanDefinition ;
40
42
41
43
/**
42
44
* The context in which the AOT processing happens. Grants access to the {@link ConfigurableListableBeanFactory
43
- * beanFactory} and {@link ClassLoader}. Holds a few convenience methods to check if a type
44
- * {@link TypeIntrospector#isTypePresent() is present} and allows resolution of them through {@link TypeIntrospector}
45
- * and {@link IntrospectedBeanDefinition}.
45
+ * beanFactory} and {@link ClassLoader}.
46
46
* <p>
47
47
* Mainly for internal use within the framework.
48
48
*
@@ -99,7 +99,7 @@ static AotContext from(BeanFactory beanFactory, Environment environment) {
99
99
* @param moduleName name of the module. Can be {@literal null} or {@literal empty}, in which case it will only check
100
100
* the general {@link #GENERATED_REPOSITORIES_ENABLED} flag.
101
101
* @return indicator if repository code generation is enabled.
102
- * @since 5 .0
102
+ * @since 4 .0
103
103
*/
104
104
default boolean isGeneratedRepositoriesEnabled (@ Nullable String moduleName ) {
105
105
@@ -119,13 +119,13 @@ default boolean isGeneratedRepositoriesEnabled(@Nullable String moduleName) {
119
119
}
120
120
121
121
/**
122
- * Checks if repository metadata file writing is enabled by checking environment variables for general
123
- * enablement ({@link #GENERATED_REPOSITORIES_JSON_ENABLED})
122
+ * Checks if repository metadata file writing is enabled by checking environment variables for general enablement
123
+ * ({@link #GENERATED_REPOSITORIES_JSON_ENABLED})
124
124
* <p>
125
125
* Unset properties are considered being {@literal true}.
126
126
*
127
127
* @return indicator if repository metadata should be written
128
- * @since 5 .0
128
+ * @since 4 .0
129
129
*/
130
130
default boolean isGeneratedRepositoriesMetadataEnabled () {
131
131
return getEnvironment ().getProperty (GENERATED_REPOSITORIES_JSON_ENABLED , Boolean .class , true );
@@ -177,8 +177,12 @@ default ClassLoader getRequiredClassLoader() {
177
177
*
178
178
* @param typeName {@link String name} of the {@link Class type} to evaluate; must not be {@literal null}.
179
179
* @return the type introspector for further type-based introspection.
180
+ * @deprecated since 4.0 as this isn't widely used and can be easily implemented within user code.
180
181
*/
181
- TypeIntrospector introspectType (String typeName );
182
+ @ Deprecated (since = "4.0" , forRemoval = true )
183
+ default TypeIntrospector introspectType (String typeName ) {
184
+ throw new UnsupportedOperationException (); // preparation for implementation removal.
185
+ }
182
186
183
187
/**
184
188
* Returns a new {@link TypeScanner} used to scan for {@link Class types} that will be contributed to the AOT
@@ -201,7 +205,9 @@ default TypeScanner getTypeScanner() {
201
205
* @param packageNames {@link Collection} of {@link String package names} to scan.
202
206
* @return a {@link Set} of {@link Class types} found during the scan.
203
207
* @see #getTypeScanner()
208
+ * @deprecated since 4.0, use {@link #getTypeScanner()} directly
204
209
*/
210
+ @ Deprecated (since = "4.0" , forRemoval = true )
205
211
default Set <Class <?>> scanPackageForTypes (Collection <Class <? extends Annotation >> identifyingAnnotations ,
206
212
Collection <String > packageNames ) {
207
213
@@ -214,7 +220,9 @@ default Set<Class<?>> scanPackageForTypes(Collection<Class<? extends Annotation>
214
220
*
215
221
* @param reference {@link BeanReference} to the managed bean.
216
222
* @return the introspected bean definition.
223
+ * @deprecated since 4.0, use {@link #getBeanFactory()} and interact with the bean factory directly.
217
224
*/
225
+ @ Deprecated (since = "4.0" , forRemoval = true )
218
226
default IntrospectedBeanDefinition introspectBeanDefinition (BeanReference reference ) {
219
227
return introspectBeanDefinition (reference .getBeanName ());
220
228
}
@@ -225,40 +233,50 @@ default IntrospectedBeanDefinition introspectBeanDefinition(BeanReference refere
225
233
*
226
234
* @param beanName {@link String} containing the {@literal name} of the bean to evaluate; must not be {@literal null}.
227
235
* @return the introspected bean definition.
236
+ * @deprecated since 4.0, use {@link #getBeanFactory()} and interact with the bean factory directly.
228
237
*/
229
- IntrospectedBeanDefinition introspectBeanDefinition (String beanName );
238
+ @ Deprecated (since = "4.0" , forRemoval = true )
239
+ default IntrospectedBeanDefinition introspectBeanDefinition (String beanName ) {
240
+ throw new UnsupportedOperationException (); // preparation for implementation removal.
241
+ }
230
242
231
243
/**
232
244
* Obtain a {@link AotTypeConfiguration} for the given {@link ResolvableType} to customize the AOT processing for the
233
- * given type.
245
+ * given type. Repeated calls to the same type will result in merging the configuration.
234
246
*
235
247
* @param resolvableType the resolvable type to configure.
236
248
* @param configurationConsumer configuration consumer function.
249
+ * @since 4.0
237
250
*/
238
251
default void typeConfiguration (ResolvableType resolvableType , Consumer <AotTypeConfiguration > configurationConsumer ) {
239
252
typeConfiguration (resolvableType .toClass (), configurationConsumer );
240
253
}
241
254
242
255
/**
243
256
* Obtain a {@link AotTypeConfiguration} for the given {@link ResolvableType} to customize the AOT processing for the
244
- * given type.
257
+ * given type. Repeated calls to the same type will result in merging the configuration.
245
258
*
246
259
* @param type the type to configure.
247
260
* @param configurationConsumer configuration consumer function.
261
+ * @since 4.0
248
262
*/
249
263
void typeConfiguration (Class <?> type , Consumer <AotTypeConfiguration > configurationConsumer );
250
264
251
265
/**
252
- * Return all type configurations registered with this {@link AotContext}.
266
+ * Contribute type configurations to the given {@link GenerationContext}. This method is called once per
267
+ * {@link GenerationContext} after all type configurations have been registered.
253
268
*
254
- * @return all type configurations registered with this {@link AotContext} .
269
+ * @param generationContext the context to contribute the type configurations to .
255
270
*/
256
- Collection < AotTypeConfiguration > typeConfigurations ( );
271
+ void contributeTypeConfigurations ( GenerationContext generationContext );
257
272
258
273
/**
259
274
* Type-based introspector to resolve {@link Class} from a type name and to introspect the bean factory for presence
260
275
* of beans.
276
+ *
277
+ * @deprecated since 4.0 as this isn't widely used and can be easily implemented within user code.
261
278
*/
279
+ @ Deprecated (since = "4.0" , forRemoval = true )
262
280
interface TypeIntrospector {
263
281
264
282
/**
@@ -318,7 +336,10 @@ default void ifTypePresent(Consumer<Class<?>> action) {
318
336
319
337
/**
320
338
* Interface defining introspection methods for bean definitions.
339
+ *
340
+ * @deprecated since 4.0 as this isn't widely used and can be easily implemented within user code.
321
341
*/
342
+ @ Deprecated (since = "4.0" , forRemoval = true )
322
343
interface IntrospectedBeanDefinition {
323
344
324
345
/**
0 commit comments