From acc4e337d23365d36f8065e40c8b14b541342890 Mon Sep 17 00:00:00 2001 From: FrankBian Date: Sat, 29 Dec 2018 17:21:10 +0800 Subject: [PATCH 1/2] clean code,remove repeat code --- .../com/alibaba/nacos/api/config/ConfigFactory.java | 11 ++--------- .../nacos/api/config/listener/AbstractListener.java | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java b/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java index 1e6e9a9db..4fd1078d6 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java @@ -49,21 +49,14 @@ public class ConfigFactory { /** * Create Config * - * @param ServerAddr serverlist + * @param serverAddr serverlist * @return Config * @throws NacosException Exception */ public static ConfigService createConfigService(String serverAddr) throws NacosException { Properties properties = new Properties(); properties.put(PropertyKeyConst.SERVER_ADDR, serverAddr); - try { - Class driverImplClass = Class.forName("com.alibaba.nacos.client.config.NacosConfigService"); - Constructor constructor = driverImplClass.getConstructor(Properties.class); - ConfigService vendorImpl = (ConfigService)constructor.newInstance(properties); - return vendorImpl; - } catch (Throwable e) { - throw new NacosException(-400, e.getMessage()); - } + return createConfigService(properties); } } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java b/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java index 645f6545c..ea253eda5 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java @@ -18,7 +18,7 @@ package com.alibaba.nacos.api.config.listener; import java.util.concurrent.Executor; /** - * Listner Adapter,use default notify thread + * Listener Adapter,use default notify thread * * @author water.lyl */ From b7e0f344fb696370eefb29c0f5bbc2feb1583981 Mon Sep 17 00:00:00 2001 From: FrankBian Date: Sat, 29 Dec 2018 17:40:15 +0800 Subject: [PATCH 2/2] correct typos,and remove some unnecessary 'public' method modifier --- .../java/com/alibaba/nacos/api/config/ConfigFactory.java | 2 +- .../com/alibaba/nacos/api/config/filter/IConfigContext.java | 4 ++-- .../com/alibaba/nacos/api/config/filter/IConfigFilter.java | 2 +- .../alibaba/nacos/api/config/filter/IConfigFilterChain.java | 4 ++-- .../com/alibaba/nacos/api/config/filter/IConfigRequest.java | 4 ++-- .../alibaba/nacos/api/config/filter/IConfigResponse.java | 4 ++-- .../com/alibaba/nacos/api/config/filter/IFilterConfig.java | 4 ++-- .../alibaba/nacos/api/config/listener/AbstractListener.java | 1 + .../com/alibaba/nacos/api/config/listener/Listener.java | 6 +++--- .../main/java/com/alibaba/nacos/example/ConfigExample.java | 2 +- 10 files changed, 17 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java b/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java index 4fd1078d6..a79d82cd6 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/ConfigFactory.java @@ -49,7 +49,7 @@ public class ConfigFactory { /** * Create Config * - * @param serverAddr serverlist + * @param serverAddr serverList * @return Config * @throws NacosException Exception */ diff --git a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigContext.java b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigContext.java index 8cbff0e8e..4b82cf43e 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigContext.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigContext.java @@ -27,7 +27,7 @@ public interface IConfigContext { * @param key * @return context */ - public Object getParameter(String key); + Object getParameter(String key); /** * set context @@ -35,5 +35,5 @@ public interface IConfigContext { * @param key key * @param value value */ - public void setParameter(String key, Object value); + void setParameter(String key, Object value); } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilter.java b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilter.java index c8ae51251..bdc8f02f2 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilter.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilter.java @@ -24,7 +24,7 @@ import com.alibaba.nacos.api.exception.NacosException; */ public interface IConfigFilter { /** - * Init Fuction + * Init Function * * @param filterConfig Filter Config */ diff --git a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilterChain.java b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilterChain.java index 6c9ac180c..1ef90554f 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilterChain.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigFilterChain.java @@ -24,12 +24,12 @@ import com.alibaba.nacos.api.exception.NacosException; */ public interface IConfigFilterChain { /** - * Filter aciton + * Filter action * * @param request request * @param response response * @throws NacosException NacosException */ - public void doFilter(IConfigRequest request, IConfigResponse response) throws NacosException; + void doFilter(IConfigRequest request, IConfigResponse response) throws NacosException; } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigRequest.java b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigRequest.java index 176ea2553..428c39d39 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigRequest.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigRequest.java @@ -27,13 +27,13 @@ public interface IConfigRequest { * @param key key * @return value */ - public Object getParameter(String key); + Object getParameter(String key); /** * get config context * * @return */ - public IConfigContext getConfigContext(); + IConfigContext getConfigContext(); } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigResponse.java b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigResponse.java index 9dc707fed..872ab3a50 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigResponse.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/filter/IConfigResponse.java @@ -27,13 +27,13 @@ public interface IConfigResponse { * @param key key * @return value */ - public Object getParameter(String key); + Object getParameter(String key); /** * get context * * @return configContext */ - public IConfigContext getConfigContext(); + IConfigContext getConfigContext(); } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/filter/IFilterConfig.java b/api/src/main/java/com/alibaba/nacos/api/config/filter/IFilterConfig.java index a625710e2..c0bf63224 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/filter/IFilterConfig.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/filter/IFilterConfig.java @@ -27,7 +27,7 @@ public interface IFilterConfig { * * @return */ - public String getFilterName(); + String getFilterName(); /** * get param @@ -35,6 +35,6 @@ public interface IFilterConfig { * @param name * @return param */ - public Object getInitParameter(String name); + Object getInitParameter(String name); } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java b/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java index ea253eda5..251ec0a42 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/listener/AbstractListener.java @@ -28,6 +28,7 @@ public abstract class AbstractListener implements Listener { /** * use default Executor */ + @Override public Executor getExecutor() { return null; } diff --git a/api/src/main/java/com/alibaba/nacos/api/config/listener/Listener.java b/api/src/main/java/com/alibaba/nacos/api/config/listener/Listener.java index 2a9fc5103..abaed12a7 100644 --- a/api/src/main/java/com/alibaba/nacos/api/config/listener/Listener.java +++ b/api/src/main/java/com/alibaba/nacos/api/config/listener/Listener.java @@ -25,16 +25,16 @@ import java.util.concurrent.Executor; public interface Listener { /** - * Executor to excute this receive + * Executor to execute this receive * * @return Executor */ - public Executor getExecutor(); + Executor getExecutor(); /** * 接收配置信息 * * @param configInfo 配置值 */ - public void receiveConfigInfo(final String configInfo); + void receiveConfigInfo(final String configInfo); } diff --git a/example/src/main/java/com/alibaba/nacos/example/ConfigExample.java b/example/src/main/java/com/alibaba/nacos/example/ConfigExample.java index d6ab57af1..bf628d370 100644 --- a/example/src/main/java/com/alibaba/nacos/example/ConfigExample.java +++ b/example/src/main/java/com/alibaba/nacos/example/ConfigExample.java @@ -42,7 +42,7 @@ public class ConfigExample { configService.addListener(dataId, group, new Listener() { @Override public void receiveConfigInfo(String configInfo) { - System.out.println("recieve:" + configInfo); + System.out.println("receive:" + configInfo); } @Override