|
43 | 43 | import org.springframework.aot.generate.AccessVisibility;
|
44 | 44 | import org.springframework.aot.generate.GenerationContext;
|
45 | 45 | import org.springframework.aot.generate.MethodReference;
|
46 |
| -import org.springframework.aot.generator.CodeContribution; |
47 | 46 | import org.springframework.aot.hint.ExecutableHint;
|
48 | 47 | import org.springframework.aot.hint.ExecutableMode;
|
49 | 48 | import org.springframework.aot.hint.FieldHint;
|
|
59 | 58 | import org.springframework.beans.factory.InjectionPoint;
|
60 | 59 | import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
61 | 60 | import org.springframework.beans.factory.UnsatisfiedDependencyException;
|
62 |
| -import org.springframework.beans.factory.annotation.InjectionMetadata.InjectedElement; |
63 | 61 | import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
64 | 62 | import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
|
65 | 63 | import org.springframework.beans.factory.aot.BeanRegistrationCode;
|
66 | 64 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
67 | 65 | import org.springframework.beans.factory.config.DependencyDescriptor;
|
68 | 66 | import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
|
69 |
| -import org.springframework.beans.factory.generator.AotContributingBeanPostProcessor; |
70 |
| -import org.springframework.beans.factory.generator.BeanInstantiationContribution; |
71 |
| -import org.springframework.beans.factory.generator.InjectionGenerator; |
72 | 67 | import org.springframework.beans.factory.support.LookupOverride;
|
73 | 68 | import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
|
74 | 69 | import org.springframework.beans.factory.support.RegisteredBean;
|
|
157 | 152 | * @see Value
|
158 | 153 | */
|
159 | 154 | public class AutowiredAnnotationBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor,
|
160 |
| - MergedBeanDefinitionPostProcessor, AotContributingBeanPostProcessor, BeanRegistrationAotProcessor, |
161 |
| - PriorityOrdered, BeanFactoryAware { |
| 155 | + MergedBeanDefinitionPostProcessor, BeanRegistrationAotProcessor, PriorityOrdered, BeanFactoryAware { |
162 | 156 |
|
163 | 157 | protected final Log logger = LogFactory.getLog(getClass());
|
164 | 158 |
|
@@ -285,15 +279,6 @@ public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, C
|
285 | 279 | findInjectionMetadata(beanName, beanType, beanDefinition);
|
286 | 280 | }
|
287 | 281 |
|
288 |
| - @Override |
289 |
| - public BeanInstantiationContribution contribute(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) { |
290 |
| - InjectionMetadata metadata = findInjectionMetadata(beanName, beanType, beanDefinition); |
291 |
| - Collection<InjectedElement> injectedElements = metadata.getInjectedElements(); |
292 |
| - return (!ObjectUtils.isEmpty(injectedElements) |
293 |
| - ? new AutowiredAnnotationBeanInstantiationContribution(injectedElements) |
294 |
| - : null); |
295 |
| - } |
296 |
| - |
297 | 282 | @Override
|
298 | 283 | public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
299 | 284 | Class<?> beanClass = registeredBean.getBeanClass();
|
@@ -866,52 +851,6 @@ private Object[] resolveMethodArguments(Method method, Object bean, @Nullable St
|
866 | 851 | }
|
867 | 852 | }
|
868 | 853 |
|
869 |
| - private static final class AutowiredAnnotationBeanInstantiationContribution implements BeanInstantiationContribution { |
870 |
| - |
871 |
| - private final Collection<InjectedElement> injectedElements; |
872 |
| - |
873 |
| - private final InjectionGenerator generator; |
874 |
| - |
875 |
| - AutowiredAnnotationBeanInstantiationContribution(Collection<InjectedElement> injectedElements) { |
876 |
| - this.injectedElements = injectedElements; |
877 |
| - this.generator = new InjectionGenerator(); |
878 |
| - } |
879 |
| - |
880 |
| - @Override |
881 |
| - public void applyTo(CodeContribution contribution) { |
882 |
| - this.injectedElements.forEach(element -> { |
883 |
| - boolean isRequired = isRequired(element); |
884 |
| - Member member = element.getMember(); |
885 |
| - analyzeMember(contribution, member); |
886 |
| - contribution.statements().addStatement(this.generator.generateInjection(member, isRequired)); |
887 |
| - }); |
888 |
| - } |
889 |
| - |
890 |
| - private boolean isRequired(InjectedElement element) { |
891 |
| - if (element instanceof AutowiredMethodElement injectedMethod) { |
892 |
| - return injectedMethod.required; |
893 |
| - } |
894 |
| - else if (element instanceof AutowiredFieldElement injectedField) { |
895 |
| - return injectedField.required; |
896 |
| - } |
897 |
| - return true; |
898 |
| - } |
899 |
| - |
900 |
| - private void analyzeMember(CodeContribution contribution, Member member) { |
901 |
| - if (member instanceof Method method) { |
902 |
| - contribution.runtimeHints().reflection().registerMethod(method, |
903 |
| - hint -> hint.setModes(ExecutableMode.INTROSPECT)); |
904 |
| - contribution.protectedAccess().analyze(member, |
905 |
| - this.generator.getProtectedAccessInjectionOptions(member)); |
906 |
| - } |
907 |
| - else if (member instanceof Field field) { |
908 |
| - contribution.runtimeHints().reflection().registerField(field); |
909 |
| - contribution.protectedAccess().analyze(member, |
910 |
| - this.generator.getProtectedAccessInjectionOptions(member)); |
911 |
| - } |
912 |
| - } |
913 |
| - |
914 |
| - } |
915 | 854 |
|
916 | 855 | /**
|
917 | 856 | * DependencyDescriptor variant with a pre-resolved target bean name.
|
|
0 commit comments