Skip to content

Commit

Permalink
[DUBBO-3137]: step3, remove constants completely. (#4053)
Browse files Browse the repository at this point in the history
* [DUBBO-3137]: step3, start to use ConfigConstants, FilterConstants, and remove Constants.java completely.

* remove Constants imports
  • Loading branch information
beiwei30 authored and CrazyHZM committed May 14, 2019
1 parent d24d614 commit 0b380e3
Show file tree
Hide file tree
Showing 69 changed files with 483 additions and 573 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.rpc.cluster.directory;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
Expand All @@ -32,6 +31,7 @@
import java.util.List;
import java.util.Map;

import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_PROTOCOL;

Expand Down Expand Up @@ -66,7 +66,7 @@ public AbstractDirectory(URL url, URL consumerUrl, RouterChain<T> routerChain) {
}

if (url.getProtocol().equals(REGISTRY_PROTOCOL)) {
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
this.url = url.addParameters(queryMap).removeParameter(MONITOR_KEY);
} else {
this.url = url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.rpc.cluster.router.condition;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.logger.Logger;
import org.apache.dubbo.common.logger.LoggerFactory;
Expand Down Expand Up @@ -48,6 +47,7 @@
import static org.apache.dubbo.common.constants.CommonConstants.ENABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METHODS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.METHOD_KEY;
import static org.apache.dubbo.common.constants.ConfigConstants.HOST_KEY;

/**
* ConditionRouter
Expand Down Expand Up @@ -233,7 +233,7 @@ private boolean matchCondition(Map<String, MatchPair> condition, URL url, URL pa
sampleValue = invocation.getMethodName();
} else if (ADDRESS_KEY.equals(key)) {
sampleValue = url.getAddress();
} else if (Constants.HOST_KEY.equals(key)) {
} else if (HOST_KEY.equals(key)) {
sampleValue = url.getHost();
} else {
sampleValue = sample.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.rpc.cluster.support;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.common.utils.NetUtils;
Expand Down Expand Up @@ -50,6 +49,7 @@

import static org.apache.dubbo.common.constants.ClusterConstants.CLUSTER_AVAILABLE_CHECK_KEY;
import static org.apache.dubbo.common.constants.ClusterConstants.INVOCATION_NEED_MOCK;
import static org.apache.dubbo.common.constants.ConfigConstants.REFER_KEY;
import static org.apache.dubbo.common.constants.MonitorConstants.MONITOR_KEY;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -225,7 +225,7 @@ public void testSelect_multiInvokers() throws Exception {
@Test
public void testCloseAvailablecheck() {
LoadBalance lb = mock(LoadBalance.class);
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(Constants.REFER_KEY));
Map<String, String> queryMap = StringUtils.parseQueryString(url.getParameterAndDecoded(REFER_KEY));
URL tmpUrl = url.addParameters(queryMap).removeParameter(MONITOR_KEY);
given(lb.select(invokers, tmpUrl, invocation)).willReturn(invoker1);
initlistsize5();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.rpc.cluster.support;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.URLBuilder;

Expand All @@ -33,6 +32,7 @@
import static org.apache.dubbo.common.constants.CommonConstants.THREADS_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.ConfigConstants.DUBBO_PROTOCOL;
import static org.apache.dubbo.common.constants.RpcConstants.DUBBO_VERSION_KEY;

public class ClusterUtilsTest {
Expand Down Expand Up @@ -62,7 +62,7 @@ public void testMergeUrl() throws Exception {
.addParameter(DEFAULT_KEY_PREFIX + THREAD_NAME_KEY, "test")
.build();

URL consumerURL = new URLBuilder(Constants.DUBBO_PROTOCOL, "localhost", 55555)
URL consumerURL = new URLBuilder(DUBBO_PROTOCOL, "localhost", 55555)
.addParameter(PID_KEY, "1234")
.addParameter(THREADPOOL_KEY, "foo")
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.dubbo.rpc.cluster.support.wrapper;

import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.rpc.Invocation;
Expand Down
211 changes: 0 additions & 211 deletions dubbo-common/src/main/java/org/apache/dubbo/common/Constants.java

This file was deleted.

20 changes: 12 additions & 8 deletions dubbo-common/src/main/java/org/apache/dubbo/common/URL.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;

import static org.apache.dubbo.common.constants.ConfigConstants.HOST_KEY;
import static org.apache.dubbo.common.constants.ConfigConstants.PORT_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
Expand All @@ -50,6 +52,8 @@
import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
import static org.apache.dubbo.common.constants.ConfigConstants.PASSWORD_KEY;
import static org.apache.dubbo.common.constants.ConfigConstants.USERNAME_KEY;

/**
* URL - Uniform Resource Locator (Immutable, ThreadSafe)
Expand Down Expand Up @@ -1137,16 +1141,16 @@ public String getRawParameter(String key) {
if (PROTOCOL_KEY.equals(key)) {
return protocol;
}
if (Constants.USERNAME_KEY.equals(key)) {
if (USERNAME_KEY.equals(key)) {
return username;
}
if (Constants.PASSWORD_KEY.equals(key)) {
if (PASSWORD_KEY.equals(key)) {
return password;
}
if (Constants.HOST_KEY.equals(key)) {
if (HOST_KEY.equals(key)) {
return host;
}
if (Constants.PORT_KEY.equals(key)) {
if (PORT_KEY.equals(key)) {
return String.valueOf(port);
}
if (PATH_KEY.equals(key)) {
Expand All @@ -1161,16 +1165,16 @@ public Map<String, String> toMap() {
map.put(PROTOCOL_KEY, protocol);
}
if (username != null) {
map.put(Constants.USERNAME_KEY, username);
map.put(USERNAME_KEY, username);
}
if (password != null) {
map.put(Constants.USERNAME_KEY, password);
map.put(USERNAME_KEY, password);
}
if (host != null) {
map.put(Constants.HOST_KEY, host);
map.put(HOST_KEY, host);
}
if (port > 0) {
map.put(Constants.PORT_KEY, String.valueOf(port));
map.put(PORT_KEY, String.valueOf(port));
}
if (path != null) {
map.put(PATH_KEY, path);
Expand Down
Loading

0 comments on commit 0b380e3

Please sign in to comment.