remove guava
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -161,11 +161,6 @@
|
||||
<version>1.12.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>18.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -40,10 +40,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.springframework.cloud.zookeeper.config;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -13,8 +14,6 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@@ -58,7 +57,7 @@ public class ZookeeperPropertySource extends EnumerablePropertySource<CuratorFra
|
||||
ChildData data = cache.getCurrentData(fullPath);
|
||||
if (data == null)
|
||||
return null;
|
||||
return new String(data.getData(), Charsets.UTF_8);
|
||||
return new String(data.getData(), Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,10 +49,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -52,10 +52,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
package org.springframework.cloud.zookeeper.discovery;
|
||||
|
||||
import static com.google.common.collect.Iterables.concat;
|
||||
import static com.google.common.collect.Iterables.transform;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import org.apache.curator.x.discovery.ServiceDiscovery;
|
||||
@@ -18,9 +13,7 @@ import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Lists;
|
||||
import static org.springframework.util.ReflectionUtils.*;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
@@ -58,53 +51,39 @@ public class ZookeeperDiscoveryClient implements DiscoveryClient {
|
||||
Collection<ServiceInstance<ZookeeperInstance>> zkInstances = discovery
|
||||
.queryForInstances(serviceId);
|
||||
|
||||
Iterable<org.springframework.cloud.client.ServiceInstance> instances = transform(
|
||||
zkInstances,
|
||||
new Function<ServiceInstance<ZookeeperInstance>, org.springframework.cloud.client.ServiceInstance>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public org.springframework.cloud.client.ServiceInstance apply(
|
||||
@Nullable ServiceInstance<ZookeeperInstance> input) {
|
||||
return new DefaultServiceInstance(serviceId, input.getAddress(),
|
||||
input.getPort());
|
||||
}
|
||||
});
|
||||
ArrayList<org.springframework.cloud.client.ServiceInstance> instances = new ArrayList<>();
|
||||
|
||||
return Lists.newArrayList(instances);
|
||||
for (ServiceInstance<ZookeeperInstance> instance : zkInstances) {
|
||||
instances.add(new DefaultServiceInstance(serviceId, instance.getAddress(),
|
||||
instance.getPort()));
|
||||
}
|
||||
|
||||
return instances;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public List<org.springframework.cloud.client.ServiceInstance> getAllInstances() {
|
||||
Iterable<org.springframework.cloud.client.ServiceInstance> instances = transform(
|
||||
concat(transform(
|
||||
discovery.queryForNames(),
|
||||
new Function<String, Collection<ServiceInstance<ZookeeperInstance>>>() {
|
||||
@SneakyThrows
|
||||
public Collection<ServiceInstance<ZookeeperInstance>> apply(
|
||||
String input) {
|
||||
return discovery.queryForInstances(input);
|
||||
}
|
||||
})),
|
||||
new Function<ServiceInstance<ZookeeperInstance>, org.springframework.cloud.client.ServiceInstance>() {
|
||||
public org.springframework.cloud.client.ServiceInstance apply(
|
||||
ServiceInstance<ZookeeperInstance> input) {
|
||||
return new DefaultServiceInstance(input.getName(), input
|
||||
.getAddress(), input.getPort());
|
||||
}
|
||||
});
|
||||
List<org.springframework.cloud.client.ServiceInstance> instances = new ArrayList<>();
|
||||
|
||||
return Lists.newArrayList(instances);
|
||||
for (String name : discovery.queryForNames()) {
|
||||
for (ServiceInstance<ZookeeperInstance> instance: discovery.queryForInstances(name)) {
|
||||
instances.add(new DefaultServiceInstance(instance.getName(), instance
|
||||
.getAddress(), instance.getPort()));
|
||||
}
|
||||
}
|
||||
|
||||
return instances;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getServices() {
|
||||
ArrayList<String> services = null;
|
||||
try {
|
||||
services = Lists.newArrayList(discovery.queryForNames());
|
||||
services = new ArrayList<>(discovery.queryForNames());
|
||||
}
|
||||
catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
rethrowRuntimeException(e);
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package org.springframework.cloud.zookeeper.discovery;
|
||||
|
||||
import static com.google.common.collect.Collections2.transform;
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.curator.x.discovery.ServiceDiscovery;
|
||||
import org.apache.curator.x.discovery.ServiceInstance;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.netflix.client.config.IClientConfig;
|
||||
import com.netflix.loadbalancer.AbstractServerList;
|
||||
|
||||
import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@@ -52,21 +48,15 @@ public class ZookeeperServerList extends AbstractServerList<ZookeeperServer> {
|
||||
if (instances == null || instances.isEmpty()) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
Collection<ZookeeperServer> servers = transform(instances,
|
||||
new Function<ServiceInstance<ZookeeperInstance>, ZookeeperServer>() {
|
||||
@Nullable
|
||||
@Override
|
||||
public ZookeeperServer apply(
|
||||
@Nullable ServiceInstance<ZookeeperInstance> instance) {
|
||||
ZookeeperServer server = new ZookeeperServer(instance);
|
||||
return server;
|
||||
}
|
||||
});
|
||||
List<ZookeeperServer> servers = new ArrayList<>();
|
||||
for (ServiceInstance<ZookeeperInstance> instance : instances) {
|
||||
servers.add(new ZookeeperServer(instance));
|
||||
}
|
||||
|
||||
return newArrayList(servers);
|
||||
return servers;
|
||||
}
|
||||
catch (Exception e) {
|
||||
Throwables.propagate(e);
|
||||
rethrowRuntimeException(e);
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user