|
|
@ -25,6 +25,7 @@ import javax.lang.model.element.Modifier; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.aot.generate.GenerationContext; |
|
|
|
import org.springframework.aot.generate.GenerationContext; |
|
|
|
import org.springframework.aot.generate.MethodReference; |
|
|
|
import org.springframework.aot.generate.MethodReference; |
|
|
|
|
|
|
|
import org.springframework.aot.hint.ProxyHints; |
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
import org.springframework.beans.MutablePropertyValues; |
|
|
|
import org.springframework.beans.factory.BeanFactory; |
|
|
|
import org.springframework.beans.factory.BeanFactory; |
|
|
|
import org.springframework.beans.factory.FactoryBean; |
|
|
|
import org.springframework.beans.factory.FactoryBean; |
|
|
@ -100,16 +101,20 @@ public class FeignClientBeanFactoryInitializationAotProcessor |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void applyTo(GenerationContext generationContext, |
|
|
|
public void applyTo(GenerationContext generationContext, |
|
|
|
BeanFactoryInitializationCode beanFactoryInitializationCode) { |
|
|
|
BeanFactoryInitializationCode beanFactoryInitializationCode) { |
|
|
|
|
|
|
|
ProxyHints proxyHints = generationContext.getRuntimeHints().proxies(); |
|
|
|
Set<String> feignClientRegistrationMethods = feignClientBeanDefinitions.values().stream() |
|
|
|
Set<String> feignClientRegistrationMethods = feignClientBeanDefinitions.values().stream() |
|
|
|
.map(beanDefinition -> { |
|
|
|
.map(beanDefinition -> { |
|
|
|
Assert.notNull(beanDefinition, "beanDefinition cannot be null"); |
|
|
|
Assert.notNull(beanDefinition, "beanDefinition cannot be null"); |
|
|
|
Assert.isInstanceOf(GenericBeanDefinition.class, beanDefinition); |
|
|
|
Assert.isInstanceOf(GenericBeanDefinition.class, beanDefinition); |
|
|
|
GenericBeanDefinition registeredBeanDefinition = (GenericBeanDefinition) beanDefinition; |
|
|
|
GenericBeanDefinition registeredBeanDefinition = (GenericBeanDefinition) beanDefinition; |
|
|
|
MutablePropertyValues feignClientProperties = registeredBeanDefinition.getPropertyValues(); |
|
|
|
MutablePropertyValues feignClientProperties = registeredBeanDefinition.getPropertyValues(); |
|
|
|
|
|
|
|
String className = (String) feignClientProperties.get("type"); |
|
|
|
|
|
|
|
Assert.notNull(className, "className cannot be null"); |
|
|
|
|
|
|
|
Class clazz = ClassUtils.resolveClassName(className, null); |
|
|
|
|
|
|
|
proxyHints.registerJdkProxy(clazz); |
|
|
|
return beanFactoryInitializationCode.getMethods() |
|
|
|
return beanFactoryInitializationCode.getMethods() |
|
|
|
.add(buildMethodName((String) feignClientProperties.get("type")), |
|
|
|
.add(buildMethodName(className), method -> generateFeignClientRegistrationMethod(method, |
|
|
|
method -> generateFeignClientRegistrationMethod(method, feignClientProperties, |
|
|
|
feignClientProperties, registeredBeanDefinition)) |
|
|
|
registeredBeanDefinition)) |
|
|
|
|
|
|
|
.getName(); |
|
|
|
.getName(); |
|
|
|
}).collect(Collectors.toSet()); |
|
|
|
}).collect(Collectors.toSet()); |
|
|
|
MethodReference initializerMethod = beanFactoryInitializationCode.getMethods() |
|
|
|
MethodReference initializerMethod = beanFactoryInitializationCode.getMethods() |
|
|
|