Commit 617dc18c by Nepxion

重构类结构

parent 16999b9d
...@@ -11,9 +11,21 @@ package com.nepxion.discovery.plugin.framework.listener; ...@@ -11,9 +11,21 @@ package com.nepxion.discovery.plugin.framework.listener;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware; import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import com.nepxion.discovery.plugin.framework.event.PluginPublisher;
public class BasicListener implements Listener { public class BasicListener implements Listener {
@Autowired @Autowired
protected RuleCache ruleCache;
@Autowired
protected PluginContextAware pluginContextAware; protected PluginContextAware pluginContextAware;
@Autowired
protected PluginAdapter pluginAdapter;
@Autowired
protected PluginPublisher pluginPublisher;
} }
\ No newline at end of file
...@@ -15,10 +15,8 @@ import java.util.List; ...@@ -15,10 +15,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.ServiceInstance;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity; import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity;
import com.nepxion.discovery.plugin.framework.entity.FilterEntity; import com.nepxion.discovery.plugin.framework.entity.FilterEntity;
...@@ -26,9 +24,6 @@ import com.nepxion.discovery.plugin.framework.entity.FilterType; ...@@ -26,9 +24,6 @@ import com.nepxion.discovery.plugin.framework.entity.FilterType;
import com.nepxion.discovery.plugin.framework.entity.RuleEntity; import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
public class IpAddressFilterDiscoveryListener extends AbstractDiscoveryListener { public class IpAddressFilterDiscoveryListener extends AbstractDiscoveryListener {
@Autowired
private RuleCache ruleCache;
@Override @Override
public void onGetInstances(String serviceId, List<ServiceInstance> instances) { public void onGetInstances(String serviceId, List<ServiceInstance> instances) {
applyIpAddressFilter(serviceId, instances); applyIpAddressFilter(serviceId, instances);
......
...@@ -17,28 +17,15 @@ import java.util.Map; ...@@ -17,28 +17,15 @@ import java.util.Map;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.ServiceInstance;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity; import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity;
import com.nepxion.discovery.plugin.framework.entity.DiscoveryServiceEntity; import com.nepxion.discovery.plugin.framework.entity.DiscoveryServiceEntity;
import com.nepxion.discovery.plugin.framework.entity.RuleEntity; import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
import com.nepxion.discovery.plugin.framework.entity.VersionEntity; import com.nepxion.discovery.plugin.framework.entity.VersionEntity;
public class VersionFilterDiscoveryListener extends AbstractDiscoveryListener { public class VersionFilterDiscoveryListener extends AbstractDiscoveryListener {
@Autowired
private RuleCache ruleCache;
@Autowired
private PluginContextAware pluginContextAware;
@Autowired
private PluginAdapter pluginAdapter;
@Override @Override
public void onGetInstances(String serviceId, List<ServiceInstance> instances) { public void onGetInstances(String serviceId, List<ServiceInstance> instances) {
String consumerServiceId = pluginContextAware.getServiceId(); String consumerServiceId = pluginContextAware.getServiceId();
......
...@@ -15,9 +15,7 @@ import java.util.List; ...@@ -15,9 +15,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity; import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity;
import com.nepxion.discovery.plugin.framework.entity.FilterEntity; import com.nepxion.discovery.plugin.framework.entity.FilterEntity;
...@@ -26,9 +24,6 @@ import com.nepxion.discovery.plugin.framework.entity.RuleEntity; ...@@ -26,9 +24,6 @@ import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.Server;
public class IpAddressFilterLoadBalanceListener extends AbstractLoadBalanceListener { public class IpAddressFilterLoadBalanceListener extends AbstractLoadBalanceListener {
@Autowired
private RuleCache ruleCache;
@Override @Override
public void onGetServers(String serviceId, List<? extends Server> servers) { public void onGetServers(String serviceId, List<? extends Server> servers) {
applyIpAddressFilter(serviceId, servers); applyIpAddressFilter(serviceId, servers);
......
...@@ -17,12 +17,8 @@ import java.util.Map; ...@@ -17,12 +17,8 @@ import java.util.Map;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity; import com.nepxion.discovery.plugin.framework.entity.DiscoveryEntity;
import com.nepxion.discovery.plugin.framework.entity.DiscoveryServiceEntity; import com.nepxion.discovery.plugin.framework.entity.DiscoveryServiceEntity;
import com.nepxion.discovery.plugin.framework.entity.RuleEntity; import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
...@@ -30,15 +26,6 @@ import com.nepxion.discovery.plugin.framework.entity.VersionEntity; ...@@ -30,15 +26,6 @@ import com.nepxion.discovery.plugin.framework.entity.VersionEntity;
import com.netflix.loadbalancer.Server; import com.netflix.loadbalancer.Server;
public class VersionFilterLoadBalanceListener extends AbstractLoadBalanceListener { public class VersionFilterLoadBalanceListener extends AbstractLoadBalanceListener {
@Autowired
private RuleCache ruleCache;
@Autowired
private PluginContextAware pluginContextAware;
@Autowired
private PluginAdapter pluginAdapter;
@Override @Override
public void onGetServers(String serviceId, List<? extends Server> servers) { public void onGetServers(String serviceId, List<? extends Server> servers) {
String consumerServiceId = pluginContextAware.getServiceId(); String consumerServiceId = pluginContextAware.getServiceId();
......
...@@ -14,28 +14,16 @@ import java.util.Map; ...@@ -14,28 +14,16 @@ import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.Registration;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.framework.decorator.DiscoveryClientDecorator; import com.nepxion.discovery.plugin.framework.decorator.DiscoveryClientDecorator;
import com.nepxion.discovery.plugin.framework.entity.CountEntity; import com.nepxion.discovery.plugin.framework.entity.CountEntity;
import com.nepxion.discovery.plugin.framework.entity.RegisterEntity; import com.nepxion.discovery.plugin.framework.entity.RegisterEntity;
import com.nepxion.discovery.plugin.framework.entity.RuleEntity; import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
import com.nepxion.discovery.plugin.framework.event.PluginPublisher;
import com.nepxion.discovery.plugin.framework.event.RegisterFailureEvent; import com.nepxion.discovery.plugin.framework.event.RegisterFailureEvent;
import com.nepxion.discovery.plugin.framework.exception.PluginException; import com.nepxion.discovery.plugin.framework.exception.PluginException;
public class CountFilterRegisterListener extends AbstractRegisterListener { public class CountFilterRegisterListener extends AbstractRegisterListener {
@Autowired @Autowired
private RuleCache ruleCache;
@Autowired
private PluginAdapter pluginAdapter;
@Autowired
private PluginPublisher pluginPublisher;
@Autowired
private DiscoveryClientDecorator discoveryClient; private DiscoveryClientDecorator discoveryClient;
@Override @Override
......
...@@ -14,30 +14,17 @@ import java.util.List; ...@@ -14,30 +14,17 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.serviceregistry.Registration; import org.springframework.cloud.client.serviceregistry.Registration;
import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter;
import com.nepxion.discovery.plugin.framework.cache.RuleCache;
import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant;
import com.nepxion.discovery.plugin.framework.entity.FilterEntity; import com.nepxion.discovery.plugin.framework.entity.FilterEntity;
import com.nepxion.discovery.plugin.framework.entity.FilterType; import com.nepxion.discovery.plugin.framework.entity.FilterType;
import com.nepxion.discovery.plugin.framework.entity.RegisterEntity; import com.nepxion.discovery.plugin.framework.entity.RegisterEntity;
import com.nepxion.discovery.plugin.framework.entity.RuleEntity; import com.nepxion.discovery.plugin.framework.entity.RuleEntity;
import com.nepxion.discovery.plugin.framework.event.PluginPublisher;
import com.nepxion.discovery.plugin.framework.event.RegisterFailureEvent; import com.nepxion.discovery.plugin.framework.event.RegisterFailureEvent;
import com.nepxion.discovery.plugin.framework.exception.PluginException; import com.nepxion.discovery.plugin.framework.exception.PluginException;
public class IpAddressFilterRegisterListener extends AbstractRegisterListener { public class IpAddressFilterRegisterListener extends AbstractRegisterListener {
@Autowired
private RuleCache ruleCache;
@Autowired
private PluginAdapter pluginAdapter;
@Autowired
private PluginPublisher pluginPublisher;
@Override @Override
public void onRegister(Registration registration) { public void onRegister(Registration registration) {
String serviceId = registration.getServiceId(); String serviceId = registration.getServiceId();
......
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