Fixed broken compilation
This commit is contained in:
@@ -31,8 +31,12 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.loadbalancer.CompletionContext;
|
||||
import org.springframework.cloud.client.loadbalancer.DefaultResponse;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerLifecycle;
|
||||
import org.springframework.cloud.client.loadbalancer.Request;
|
||||
import org.springframework.cloud.client.loadbalancer.Response;
|
||||
import org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer;
|
||||
import org.springframework.cloud.contract.stubrunner.RunningStubs;
|
||||
import org.springframework.cloud.contract.stubrunner.StubConfiguration;
|
||||
@@ -79,36 +83,15 @@ public class SpringCloudLoadBalancerAutoConfiguration {
|
||||
class StubRunnerLoadBalancerClientFactory extends LoadBalancerClientFactory
|
||||
implements Closeable {
|
||||
|
||||
private StubFinder stubFinder;
|
||||
|
||||
private StubMapperProperties stubMapperProperties;
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
StubRunnerLoadBalancerClientFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
private StubFinder stubFinder() {
|
||||
if (this.stubFinder == null) {
|
||||
this.stubFinder = this.beanFactory.getBean(StubFinder.class);
|
||||
}
|
||||
return this.stubFinder;
|
||||
}
|
||||
|
||||
private StubMapperProperties stubMapperProperties() {
|
||||
if (this.stubMapperProperties == null) {
|
||||
this.stubMapperProperties = this.beanFactory
|
||||
.getBean(StubMapperProperties.class);
|
||||
}
|
||||
return this.stubMapperProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReactiveLoadBalancer<ServiceInstance> getInstance(String serviceId) {
|
||||
return (ReactorServiceInstanceLoadBalancer) request -> Mono
|
||||
.just(new DefaultResponse(new StubbedServiceInstance(stubFinder(),
|
||||
stubMapperProperties(), serviceId)));
|
||||
return new ContractReactorServiceInstanceLoadBalancer(this.beanFactory, serviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,3 +197,51 @@ class StubbedServiceInstance implements ServiceInstance {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ContractReactorServiceInstanceLoadBalancer implements ReactorServiceInstanceLoadBalancer, LoadBalancerLifecycle {
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
private final String serviceId;
|
||||
|
||||
private StubFinder stubFinder;
|
||||
|
||||
private StubMapperProperties stubMapperProperties;
|
||||
|
||||
ContractReactorServiceInstanceLoadBalancer(BeanFactory beanFactory, String serviceId) {
|
||||
this.beanFactory = beanFactory;
|
||||
this.serviceId = serviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart(Request request) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(CompletionContext completionContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Response<ServiceInstance>> choose(Request request) {
|
||||
return Mono
|
||||
.just(new DefaultResponse(new StubbedServiceInstance(stubFinder(),
|
||||
stubMapperProperties(), this.serviceId)));
|
||||
}
|
||||
|
||||
private StubFinder stubFinder() {
|
||||
if (this.stubFinder == null) {
|
||||
this.stubFinder = this.beanFactory.getBean(StubFinder.class);
|
||||
}
|
||||
return this.stubFinder;
|
||||
}
|
||||
|
||||
private StubMapperProperties stubMapperProperties() {
|
||||
if (this.stubMapperProperties == null) {
|
||||
this.stubMapperProperties = this.beanFactory
|
||||
.getBean(StubMapperProperties.class);
|
||||
}
|
||||
return this.stubMapperProperties;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user