6767 * not match due to customization of the factory bean by the user, at least the target repository type is provided via
6868 * the {@link FactoryBean#OBJECT_TYPE_ATTRIBUTE}.
6969 * <p>
70- * With {@link RepositoryRegistrationAotProcessor#contributeRepositoryHints (AotRepositoryContext, GenerationContext)}
71- * and {@link RepositoryRegistrationAotProcessor #contributeAotRepository(AotRepositoryContext)}, stores can provide
72- * custom logic for contributing additional (e.g. reflection) configuration. By default, reflection configuration will
73- * be added for types reachable from the repository declaration and query methods as well as all used {@link Annotation
74- * annotations} from the {@literal org.springframework.data} namespace.
70+ * With {@link #registerRepositoryCompositionHints (AotRepositoryContext, GenerationContext)} (specifically
71+ * {@link #configureTypeContribution(Class, AotContext)} and {@link #contributeAotRepository(AotRepositoryContext)},
72+ * stores can provide custom logic for contributing additional (e.g. reflection) configuration. By default, reflection
73+ * configuration will be added for types reachable from the repository declaration and query methods as well as all used
74+ * {@link Annotation annotations} from the {@literal org.springframework.data} namespace.
7575 * <p>
7676 * The processor is typically configured via {@link RepositoryConfigurationExtension#getRepositoryAotProcessor()} and
7777 * gets added by the {@link org.springframework.data.repository.config.RepositoryConfigurationDelegate}.
@@ -163,8 +163,8 @@ protected ConfigurableListableBeanFactory getBeanFactory() {
163163
164164 BeanRegistrationAotContribution contribution = (generationContext , beanRegistrationCode ) -> {
165165
166- contributeRepositoryHints (repositoryContext , generationContext );
167- contributeTypes (repositoryContext , generationContext );
166+ registerRepositoryCompositionHints (repositoryContext , generationContext );
167+ configureTypeContributions (repositoryContext , generationContext );
168168
169169 repositoryContext .contributeTypeConfigurations (generationContext );
170170 };
@@ -181,7 +181,7 @@ protected ConfigurableListableBeanFactory getBeanFactory() {
181181 * @param generationContext the generation context.
182182 * @since 4.0
183183 */
184- protected void contributeRepositoryHints (AotRepositoryContext repositoryContext ,
184+ protected void registerRepositoryCompositionHints (AotRepositoryContext repositoryContext ,
185185 GenerationContext generationContext ) {
186186
187187 RepositoryInformation repositoryInformation = repositoryContext .getRepositoryInformation ();
@@ -200,7 +200,7 @@ protected void contributeRepositoryHints(AotRepositoryContext repositoryContext,
200200 .forReflectiveAccess (MemberCategory .INVOKE_DECLARED_CONSTRUCTORS , MemberCategory .INVOKE_PUBLIC_METHODS ));
201201
202202 // Repository Fragments
203- contributeFragments (repositoryInformation .getFragments (), generationContext );
203+ registerFragmentsHints (repositoryInformation .getFragments (), generationContext );
204204
205205 // Kotlin
206206 if (isKotlinCoroutineRepository (repositoryInformation )) {
@@ -209,20 +209,19 @@ protected void contributeRepositoryHints(AotRepositoryContext repositoryContext,
209209 }
210210
211211 /**
212- * Contribute types for reflection, proxies, etc. Customization hook for subclasses that wish to customize type
213- * contribution hints .
212+ * Register type-specific hints and AOT artifacts for domain types, reachable types, projection interfaces derived
213+ * from query method return types, and annotations from {@literal org.springframework.data} packages .
214214 *
215215 * @param repositoryContext the repository context.
216216 * @param generationContext the generation context.
217217 * @since 4.0
218218 */
219- protected void contributeTypes (AotRepositoryContext repositoryContext , GenerationContext generationContext ) {
220-
221- contributeDomainTypes (repositoryContext , generationContext );
222- contributeResolvedTypes (repositoryContext , generationContext );
219+ private void configureTypeContributions (AotRepositoryContext repositoryContext , GenerationContext generationContext ) {
223220
224221 RepositoryInformation information = repositoryContext .getRepositoryInformation ();
225222
223+ configureDomainTypeContributions (repositoryContext , generationContext );
224+
226225 // Repository query methods
227226 information .getQueryMethods ().stream ().map (information ::getReturnedDomainClass ).filter (Class ::isInterface )
228227 .forEach (type -> {
@@ -238,44 +237,50 @@ protected void contributeTypes(AotRepositoryContext repositoryContext, Generatio
238237 }
239238
240239 /**
241- * Customization hook for subclasses that wish to customize domain type contribution hints.
240+ * Customization hook for subclasses that wish to customize domain type hint contributions.
241+ * <p>
242+ * Type hints are registered for the domain, alternative domain types, and types reachable from there
243+ * ({@link AotRepositoryContext#getResolvedTypes()})
242244 *
243245 * @param repositoryContext the repository context.
244246 * @param generationContext the generation context.
245247 * @since 4.0
246248 */
247- protected void contributeDomainTypes (AotRepositoryContext repositoryContext , GenerationContext generationContext ) {
249+ protected void configureDomainTypeContributions (AotRepositoryContext repositoryContext ,
250+ GenerationContext generationContext ) {
248251
249252 RepositoryInformation information = repositoryContext .getRepositoryInformation ();
250-
251253 RuntimeHints hints = generationContext .getRuntimeHints ();
252254
253255 // Domain types, related types, projections
254- repositoryContext .typeConfiguration (information .getDomainType (), config -> config .forDataBinding ().forQuerydsl ());
255-
256256 ReflectiveRuntimeHintsRegistrar registrar = new ReflectiveRuntimeHintsRegistrar ();
257257 Stream .concat (Stream .of (information .getDomainType ()), information .getAlternativeDomainTypes ().stream ())
258258 .forEach (it -> {
259259
260- // TODO cross check with #contributeResolvedTypes
261260 registrar .registerRuntimeHints (hints , it );
262- repositoryContext . typeConfiguration (it , AotTypeConfiguration :: contributeAccessors );
261+ configureTypeContribution (it , repositoryContext );
263262 });
264- }
265263
266- private void contributeResolvedTypes (AotRepositoryContext repositoryContext , GenerationContext generationContext ) {
267-
268- RepositoryInformation information = repositoryContext .getRepositoryInformation ();
269-
270- // TODO: These are twice.
264+ // TODO: Looks like a duplicate
271265 repositoryContext .getResolvedTypes ().stream ()
272266 .filter (it -> TypeContributor .isPartOf (it , Set .of (information .getDomainType ().getPackageName ())))
273- .forEach (it -> repositoryContext . typeConfiguration (it , AotTypeConfiguration :: contributeAccessors ));
267+ .forEach (it -> configureTypeContribution (it , repositoryContext ));
274268
275269 repositoryContext .getResolvedTypes ().stream ().filter (it -> !isJavaOrPrimitiveType (it ))
276270 .forEach (it -> contributeType (it , generationContext ));
277271 }
278272
273+ /**
274+ * Customization hook to configure the {@link TypeContributor} used to register the given {@literal type}.
275+ *
276+ * @param type the class to configure the contribution for.
277+ * @param aotContext AOT context for type configuration.
278+ * @since 4.0
279+ */
280+ protected void configureTypeContribution (Class <?> type , AotContext aotContext ) {
281+ aotContext .typeConfiguration (type , config -> config .forDataBinding ().contributeAccessors ().forQuerydsl ());
282+ }
283+
279284 /**
280285 * This method allows for the creation to be overridden by subclasses.
281286 *
@@ -308,11 +313,11 @@ private void contributeType(Class<?> type, GenerationContext context) {
308313 TypeContributor .contribute (type , it -> true , context );
309314 }
310315
311- private void contributeFragments (Iterable <RepositoryFragment <?>> fragments , GenerationContext contribution ) {
312- fragments .forEach (it -> contributeFragment (it , contribution ));
316+ private void registerFragmentsHints (Iterable <RepositoryFragment <?>> fragments , GenerationContext contribution ) {
317+ fragments .forEach (it -> registerFragmentHints (it , contribution ));
313318 }
314319
315- private static void contributeFragment (RepositoryFragment <?> fragment , GenerationContext context ) {
320+ private static void registerFragmentHints (RepositoryFragment <?> fragment , GenerationContext context ) {
316321
317322 Class <?> repositoryFragmentType = fragment .getSignatureContributor ();
318323 Optional <Class <?>> implementation = fragment .getImplementationClass ();
0 commit comments