Pass GenerationContext to customizeBeanRegistrationCodeFragments
Update `customizeBeanRegistrationCodeFragments` so that it can access the `GenerationContext`. See gh-28557
This commit is contained in:
		
							parent
							
								
									9a9c3ea00e
								
							
						
					
					
						commit
						305055d6b1
					
				|  | @ -88,7 +88,8 @@ class BeanDefinitionMethodGenerator { | ||||||
| 	MethodReference generateBeanDefinitionMethod(GenerationContext generationContext, | 	MethodReference generateBeanDefinitionMethod(GenerationContext generationContext, | ||||||
| 			String featureNamePrefix, BeanRegistrationsCode beanRegistrationsCode) { | 			String featureNamePrefix, BeanRegistrationsCode beanRegistrationsCode) { | ||||||
| 
 | 
 | ||||||
| 		BeanRegistrationCodeFragments codeFragments = getCodeFragments(beanRegistrationsCode, featureNamePrefix); | 		BeanRegistrationCodeFragments codeFragments = getCodeFragments(generationContext, | ||||||
|  | 				beanRegistrationsCode, featureNamePrefix); | ||||||
| 		Class<?> target = codeFragments.getTarget(this.registeredBean, | 		Class<?> target = codeFragments.getTarget(this.registeredBean, | ||||||
| 				this.constructorOrFactoryMethod); | 				this.constructorOrFactoryMethod); | ||||||
| 		if (!target.getName().startsWith("java.")) { | 		if (!target.getName().startsWith("java.")) { | ||||||
|  | @ -113,14 +114,14 @@ class BeanDefinitionMethodGenerator { | ||||||
| 				generatedMethod.getName().toString()); | 				generatedMethod.getName().toString()); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	private BeanRegistrationCodeFragments getCodeFragments( | 	private BeanRegistrationCodeFragments getCodeFragments(GenerationContext generationContext, | ||||||
| 			BeanRegistrationsCode beanRegistrationsCode, String featureNamePrefix) { | 			BeanRegistrationsCode beanRegistrationsCode, String featureNamePrefix) { | ||||||
| 
 | 
 | ||||||
| 		BeanRegistrationCodeFragments codeFragments = new DefaultBeanRegistrationCodeFragments( | 		BeanRegistrationCodeFragments codeFragments = new DefaultBeanRegistrationCodeFragments( | ||||||
| 				beanRegistrationsCode, this.registeredBean, this.methodGeneratorFactory, | 				beanRegistrationsCode, this.registeredBean, this.methodGeneratorFactory, | ||||||
| 				featureNamePrefix); | 				featureNamePrefix); | ||||||
| 		for (BeanRegistrationAotContribution aotContribution : this.aotContributions) { | 		for (BeanRegistrationAotContribution aotContribution : this.aotContributions) { | ||||||
| 			codeFragments = aotContribution.customizeBeanRegistrationCodeFragments(codeFragments); | 			codeFragments = aotContribution.customizeBeanRegistrationCodeFragments(generationContext, codeFragments); | ||||||
| 		} | 		} | ||||||
| 		return codeFragments; | 		return codeFragments; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -36,12 +36,13 @@ public interface BeanRegistrationAotContribution { | ||||||
| 	 * Customize the {@link BeanRegistrationCodeFragments} that will be used to | 	 * Customize the {@link BeanRegistrationCodeFragments} that will be used to | ||||||
| 	 * generate the bean registration code. Custom code fragments can be used if | 	 * generate the bean registration code. Custom code fragments can be used if | ||||||
| 	 * default code generation isn't suitable. | 	 * default code generation isn't suitable. | ||||||
|  | 	 * @param generationContext the generation context | ||||||
| 	 * @param codeFragments the existing code fragments | 	 * @param codeFragments the existing code fragments | ||||||
| 	 * @return the code fragments to use, may be the original instance or a | 	 * @return the code fragments to use, may be the original instance or a | ||||||
| 	 * wrapper | 	 * wrapper | ||||||
| 	 */ | 	 */ | ||||||
| 	default BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments( | 	default BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments( | ||||||
| 			BeanRegistrationCodeFragments codeFragments) { | 			GenerationContext generationContext, BeanRegistrationCodeFragments codeFragments) { | ||||||
| 		return codeFragments; | 		return codeFragments; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -70,7 +71,7 @@ public interface BeanRegistrationAotContribution { | ||||||
| 
 | 
 | ||||||
| 			@Override | 			@Override | ||||||
| 			public BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments( | 			public BeanRegistrationCodeFragments customizeBeanRegistrationCodeFragments( | ||||||
| 					BeanRegistrationCodeFragments codeFragments) { | 					GenerationContext generationContext, BeanRegistrationCodeFragments codeFragments) { | ||||||
| 				return beanRegistrationCodeFragmentsCustomizer.apply(codeFragments); | 				return beanRegistrationCodeFragmentsCustomizer.apply(codeFragments); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue