Commit 88f43e99 by Nepxion

增加扩展性

parent e45482d4
...@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.configuration; ...@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.configuration;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties; import org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties;
import org.springframework.cloud.consul.discovery.ConsulRibbonClientConfiguration; import org.springframework.cloud.consul.discovery.ConsulRibbonClientConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -36,6 +37,7 @@ public class ConsulLoadBalanceConfiguration { ...@@ -36,6 +37,7 @@ public class ConsulLoadBalanceConfiguration {
private ConsulClient client; private ConsulClient client;
@Bean @Bean
@ConditionalOnMissingBean
public ServerList<?> ribbonServerList(IClientConfig config, ConsulDiscoveryProperties properties) { public ServerList<?> ribbonServerList(IClientConfig config, ConsulDiscoveryProperties properties) {
ConsulServerListDecorator serverList = new ConsulServerListDecorator(client, properties); ConsulServerListDecorator serverList = new ConsulServerListDecorator(client, properties);
serverList.initWithNiwsConfig(config); serverList.initWithNiwsConfig(config);
......
...@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.configuration; ...@@ -11,6 +11,7 @@ package com.nepxion.discovery.plugin.framework.configuration;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.zookeeper.discovery.ZookeeperRibbonClientConfiguration; import org.springframework.cloud.zookeeper.discovery.ZookeeperRibbonClientConfiguration;
import org.springframework.cloud.zookeeper.serviceregistry.ZookeeperServiceRegistry; import org.springframework.cloud.zookeeper.serviceregistry.ZookeeperServiceRegistry;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -35,6 +36,7 @@ public class ZookeeperLoadBalanceConfiguration { ...@@ -35,6 +36,7 @@ public class ZookeeperLoadBalanceConfiguration {
private ZookeeperServiceRegistry registry; private ZookeeperServiceRegistry registry;
@Bean @Bean
@ConditionalOnMissingBean
public ServerList<?> ribbonServerList(IClientConfig config) { public ServerList<?> ribbonServerList(IClientConfig config) {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
ZookeeperServerListDecorator serverList = new ZookeeperServerListDecorator(this.registry.getServiceDiscoveryRef().get()); ZookeeperServerListDecorator serverList = new ZookeeperServerListDecorator(this.registry.getServiceDiscoveryRef().get());
......
...@@ -14,7 +14,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; ...@@ -14,7 +14,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.listener.discovery.DiscoveryListener;
import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.Server;
// 因为内置监听触发的时候,需要优先过滤,所以顺序执行 // 因为内置监听触发的时候,需要优先过滤,所以顺序执行
...@@ -26,9 +25,6 @@ public class LoadBalanceListenerExecutor { ...@@ -26,9 +25,6 @@ public class LoadBalanceListenerExecutor {
private VersionFilterLoadBalanceListener versionFilterLoadBalanceListener; private VersionFilterLoadBalanceListener versionFilterLoadBalanceListener;
@Autowired @Autowired
private List<DiscoveryListener> discoveryListenerList;
@Autowired
private ReentrantReadWriteLock reentrantReadWriteLock; private ReentrantReadWriteLock reentrantReadWriteLock;
public void onGetServers(String serviceId, List<? extends Server> servers) { public void onGetServers(String serviceId, List<? extends Server> servers) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment