Browse Source

Initialize child contexts at creation.

aot-support
Olga Maciaszek-Sharma 2 years ago
parent
commit
d501773120
  1. 17
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactory.java
  2. 1
      spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java

17
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactory.java

@ -38,16 +38,14 @@ import org.springframework.lang.Nullable; @@ -38,16 +38,14 @@ import org.springframework.lang.Nullable;
*/
public class FeignClientFactory extends NamedContextFactory<FeignClientSpecification> {
private Map<String, ApplicationContextInitializer<GenericApplicationContext>> applicationContextInitializers;
public FeignClientFactory() {
this(new HashMap<>());
}
public FeignClientFactory(
Map<String, ApplicationContextInitializer<GenericApplicationContext>> applicationContextInitializers) {
super(FeignClientsConfiguration.class, "spring.cloud.openfeign", "spring.cloud.openfeign.client.name");
this.applicationContextInitializers = applicationContextInitializers;
super(FeignClientsConfiguration.class, "spring.cloud.openfeign", "spring.cloud.openfeign.client.name",
applicationContextInitializers);
}
@Nullable
@ -79,15 +77,4 @@ public class FeignClientFactory extends NamedContextFactory<FeignClientSpecifica @@ -79,15 +77,4 @@ public class FeignClientFactory extends NamedContextFactory<FeignClientSpecifica
return new FeignClientFactory(convertedInitializers);
}
public void initializeChildContexts() {
applicationContextInitializers.keySet().forEach(contextId -> {
GenericApplicationContext childContext = buildContext(contextId);
applicationContextInitializers.get(contextId).initialize(childContext);
addContext(contextId, childContext);
childContext.refresh();
});
// Ensure the contexts are only initialized once after Aot processing
applicationContextInitializers = new HashMap<>();
}
}

1
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/FeignClientFactoryBean.java

@ -420,7 +420,6 @@ public class FeignClientFactoryBean @@ -420,7 +420,6 @@ public class FeignClientFactoryBean
<T> T getTarget() {
FeignClientFactory feignClientFactory = beanFactory != null ? beanFactory.getBean(FeignClientFactory.class)
: applicationContext.getBean(FeignClientFactory.class);
feignClientFactory.initializeChildContexts();
Feign.Builder builder = feign(feignClientFactory);
if (!StringUtils.hasText(url) && !isUrlAvailableInConfig(contextId)) {

Loading…
Cancel
Save