Skip to content

Commit

Permalink
Make 'META-INF/dubbo-versions' as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
refeccd committed Jun 4, 2024
1 parent a124a9e commit 6d3ea85
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.apache.dubbo.common;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import org.apache.dubbo.common.utils.StringUtils;
Expand Down Expand Up @@ -85,7 +86,7 @@ public final class Version {

private static void tryLoadVersionFromResource() throws IOException {
Enumeration<URL> configLoader =
Version.class.getClassLoader().getResources("META-INF/dubbo-versions/dubbo-common");
Version.class.getClassLoader().getResources(CommonConstants.DUBBO_VERSIONS_KEY + "/dubbo-common");
if (configLoader.hasMoreElements()) {
URL url = configLoader.nextElement();
try (BufferedReader reader =
Expand Down Expand Up @@ -313,7 +314,7 @@ private static void checkArtifacts(Set<String> artifactIds) throws IOException {

private static void checkArtifact(String artifactId) throws IOException {
Enumeration<URL> artifactEnumeration =
Version.class.getClassLoader().getResources("META-INF/dubbo-versions/" + artifactId);
Version.class.getClassLoader().getResources(CommonConstants.DUBBO_VERSIONS_KEY + artifactId);
while (artifactEnumeration.hasMoreElements()) {
URL url = artifactEnumeration.nextElement();
try (BufferedReader reader =
Expand Down Expand Up @@ -349,7 +350,7 @@ private static void checkVersion(String artifactId, URL url, String key, String

private static Set<String> loadArtifactIds() throws IOException {
Enumeration<URL> artifactsEnumeration =
Version.class.getClassLoader().getResources("META-INF/dubbo-versions/.artifacts");
Version.class.getClassLoader().getResources(CommonConstants.DUBBO_VERSIONS_KEY + "/.artifacts");
Set<String> artifactIds = new HashSet<>();
while (artifactsEnumeration.hasMoreElements()) {
URL url = artifactsEnumeration.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.regex.Pattern;

public interface CommonConstants {

String DUBBO = "dubbo";

String TRIPLE = "tri";
Expand Down Expand Up @@ -267,12 +268,14 @@ public interface CommonConstants {
String $INVOKE = "$invoke";

String $INVOKE_ASYNC = "$invokeAsync";

String GENERIC_PARAMETER_DESC = "Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;";

/**
* echo call
*/
String $ECHO = "$echo";

/**
* package version in the manifest
*/
Expand All @@ -283,12 +286,19 @@ public interface CommonConstants {
int MAX_PROXY_COUNT = 65535;

String MONITOR_KEY = "monitor";

String BACKGROUND_KEY = "background";

String CLUSTER_KEY = "cluster";

String USERNAME_KEY = "username";

String PASSWORD_KEY = "password";

String HOST_KEY = "host";

String PORT_KEY = "port";

String DUBBO_IP_TO_BIND = "DUBBO_IP_TO_BIND";

/**
Expand All @@ -308,21 +318,29 @@ public interface CommonConstants {
String SHUTDOWN_WAIT_SECONDS_KEY = "dubbo.service.shutdown.wait.seconds";

String SHUTDOWN_WAIT_KEY = "dubbo.service.shutdown.wait";

String DUBBO_PROTOCOL = "dubbo";

String DUBBO_LABELS = "dubbo.labels";

String DUBBO_ENV_KEYS = "dubbo.env.keys";

String CONFIG_CONFIGFILE_KEY = "config-file";

String CONFIG_ENABLE_KEY = "highest-priority";

String CONFIG_NAMESPACE_KEY = "namespace";

String CHECK_KEY = "check";

String BACKLOG_KEY = "backlog";

String HEARTBEAT_EVENT = null;

String MOCK_HEARTBEAT_EVENT = "H";

String READONLY_EVENT = "R";

String WRITEABLE_EVENT = "W";

String REFERENCE_FILTER_KEY = "reference.filter";
Expand Down Expand Up @@ -459,6 +477,7 @@ public interface CommonConstants {
String REGISTRY_DELAY_NOTIFICATION_KEY = "delay-notification";

String CACHE_CLEAR_TASK_INTERVAL = "dubbo.application.url.cache.task.interval";

String CACHE_CLEAR_WAITING_THRESHOLD = "dubbo.application.url.cache.clear.waiting";

String CLUSTER_INTERCEPTOR_COMPATIBLE_KEY = "dubbo.application.cluster.interceptor.compatible";
Expand Down Expand Up @@ -615,17 +634,18 @@ public interface CommonConstants {
String SERVICE_EXECUTOR = "service-executor";

String EXECUTOR_MANAGEMENT_MODE = "executor-management-mode";

String EXECUTOR_MANAGEMENT_MODE_DEFAULT = "default";

String EXECUTOR_MANAGEMENT_MODE_ISOLATION = "isolation";

/**
*
* used in JVMUtil.java ,Control stack print lines, default is 32 lines
*
*/
String DUBBO_JSTACK_MAXLINE = "dubbo.jstack-dump.max-line";

String ENCODE_IN_IO_THREAD_KEY = "encode.in.io";

boolean DEFAULT_ENCODE_IN_IO_THREAD = false;

/**
Expand All @@ -648,4 +668,7 @@ public interface CommonConstants {
String DUBBO2_COMPACT_ENABLE = "dubbo.compact.enable";

String ZOOKEEPER_ENSEMBLE_TRACKER_KEY = "zookeeper.ensemble.tracker";

String DUBBO_VERSIONS_KEY = "META-INF/dubbo-versions";

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.dubbo.common.version;

import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.constants.CommonConstants;

import java.io.FileInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -145,7 +146,7 @@ public byte[] loadClassData(String className) throws IOException {

@Override
public Enumeration<URL> getResources(String name) throws IOException {
if (name.equals("META-INF/dubbo-versions/dubbo-common")) {
if (name.equals(CommonConstants.DUBBO_VERSIONS_KEY + "/dubbo-common")) {
return super.getResources("META-INF/test-versions/dubbo-common");
}
return super.getResources(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.dubbo.dependency;

import org.apache.dubbo.common.constants.CommonConstants;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -133,7 +135,7 @@ void checkArtifacts() throws DocumentException, IOException {
List<String> artifactIdsInRoot = IOUtils.readLines(
this.getClass()
.getClassLoader()
.getResource("META-INF/dubbo-versions/.artifacts")
.getResource(CommonConstants.DUBBO_VERSIONS_KEY + "/.artifacts")
.openStream(),
StandardCharsets.UTF_8);
artifactIdsInRoot.removeIf(s -> s.startsWith("#"));
Expand Down

0 comments on commit 6d3ea85

Please sign in to comment.