/
AwsBinderDelegate.java
50 lines (43 loc) · 1.66 KB
/
AwsBinderDelegate.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.netflix.eureka.aws;
import com.netflix.appinfo.ApplicationInfoManager;
import com.netflix.discovery.EurekaClientConfig;
import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.registry.PeerAwareInstanceRegistry;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class AwsBinderDelegate implements AwsBinder {
private final AwsBinder delegate;
@Inject
public AwsBinderDelegate(EurekaServerConfig serverConfig,
EurekaClientConfig clientConfig,
PeerAwareInstanceRegistry registry,
ApplicationInfoManager applicationInfoManager) {
AwsBindingStrategy bindingStrategy = serverConfig.getBindingStrategy();
switch (bindingStrategy) {
case ROUTE53:
delegate = new Route53Binder(serverConfig, clientConfig, applicationInfoManager);
break;
case EIP:
delegate = new EIPManager(serverConfig, clientConfig, registry, applicationInfoManager);
break;
case ENI:
delegate = new ElasticNetworkInterfaceBinder(serverConfig, clientConfig, registry, applicationInfoManager);
break;
default:
throw new IllegalArgumentException("Unexpected BindingStrategy " + bindingStrategy);
}
}
@Override
@PostConstruct
public void start() throws Exception {
delegate.start();
}
@Override
@PreDestroy
public void shutdown() throws Exception {
delegate.shutdown();
}
}