This is an automated email from the ASF dual-hosted git repository. liubao pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
commit 8d2d91a1f11ed664acb452662b7906da79517909 Author: liubao <bi...@qq.com> AuthorDate: Tue Sep 26 17:01:00 2023 +0800 [SCB-2008]remove archaius dependency: kie adapter --- .../apache/servicecomb/config/kie/KieConfig.java | 83 +++-------- .../config/kie/KieConfigConfiguration.java | 11 ++ ...ceImpl.java => KieDynamicPropertiesSource.java} | 155 ++++++++------------- .../servicecomb/config/kie/TransportUtils.java | 52 +++---- ...comb.config.spi.ConfigCenterConfigurationSource | 18 --- ...comb.config.spi.ConfigCenterConfigurationSource | 18 --- 6 files changed, 120 insertions(+), 217 deletions(-) diff --git a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfig.java b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfig.java index 872165f51..564b5c8ad 100644 --- a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfig.java +++ b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfig.java @@ -17,22 +17,13 @@ package org.apache.servicecomb.config.kie; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.apache.servicecomb.config.BootStrapProperties; import org.apache.servicecomb.foundation.vertx.VertxConst; - -import com.netflix.config.ConcurrentCompositeConfiguration; +import org.springframework.core.env.Environment; public class KieConfig { - - public static final KieConfig INSTANCE = new KieConfig(); - - private static ConcurrentCompositeConfiguration finalConfig; - public static final String SSL_TAG = "kie.consumer"; private static final String SERVER_URL_KEY = "servicecomb.kie.serverUri"; @@ -75,114 +66,86 @@ public class KieConfig { private static final String CUSTOM_LABEL_VALUE_DEFAULT = ""; - private KieConfig() { - } - - public static ConcurrentCompositeConfiguration getFinalConfig() { - return finalConfig; - } + private final Environment environment; - public static void setFinalConfig(ConcurrentCompositeConfiguration finalConfig) { - KieConfig.finalConfig = finalConfig; + public KieConfig(Environment environment) { + this.environment = environment; } @SuppressWarnings("unchecked") public List<String> getFileSources() { - Object property = finalConfig.getProperty(FILE_SOURCE); - if (property instanceof String) { - return new ArrayList<>(Arrays.asList(((String) property).split(","))); - } - if (property instanceof List) { - return (List<String>) property; - } - return Collections.EMPTY_LIST; - } - - public String getVersion() { - return BootStrapProperties.readServiceVersion(finalConfig); - } - - public String getServiceName() { - return BootStrapProperties.readServiceName(finalConfig); - } - - public String getEnvironment() { - return BootStrapProperties.readServiceEnvironment(finalConfig); - } - - public String getAppName() { - return BootStrapProperties.readApplication(finalConfig); + return environment.getProperty(FILE_SOURCE, List.class, Collections.emptyList()); } public String getDomainName() { - return finalConfig.getString(DOMAIN_NAME, "default"); + return environment.getProperty(DOMAIN_NAME, "default"); } public String getServerUri() { - return finalConfig.getString(SERVER_URL_KEY); + return environment.getProperty(SERVER_URL_KEY); } public int getRefreshInterval() { - return finalConfig.getInt(REFRESH_INTERVAL, DEFAULT_REFRESH_INTERVAL); + return environment.getProperty(REFRESH_INTERVAL, int.class, DEFAULT_REFRESH_INTERVAL); } public int getFirstRefreshInterval() { - return finalConfig.getInt(FIRST_REFRESH_INTERVAL, DEFAULT_FIRST_REFRESH_INTERVAL); + return environment.getProperty(FIRST_REFRESH_INTERVAL, int.class, DEFAULT_FIRST_REFRESH_INTERVAL); } public boolean enableAppConfig() { - return finalConfig.getBoolean(ENABLE_APP_CONFIG, true); + return environment.getProperty(ENABLE_APP_CONFIG, boolean.class, true); } public boolean enableServiceConfig() { - return finalConfig.getBoolean(ENABLE_SERVICE_CONFIG, true); + return environment.getProperty(ENABLE_SERVICE_CONFIG, boolean.class, true); } public boolean enableVersionConfig() { - return finalConfig.getBoolean(ENABLE_VERSION_CONFIG, true); + return environment.getProperty(ENABLE_VERSION_CONFIG, boolean.class, true); } public boolean enableCustomConfig() { - return finalConfig.getBoolean(ENABLE_CUSTOM_CONFIG, true); + return environment.getProperty(ENABLE_CUSTOM_CONFIG, boolean.class, true); } public boolean enableLongPolling() { - return finalConfig.getBoolean(ENABLE_LONG_POLLING, DEFAULT_ENABLE_LONG_POLLING); + return environment.getProperty(ENABLE_LONG_POLLING, boolean.class, DEFAULT_ENABLE_LONG_POLLING); } public int getPollingWaitTime() { - return finalConfig.getInt(POLLING_WAIT_TIME, DEFAULT_POLLING_WAIT_TIME); + return environment.getProperty(POLLING_WAIT_TIME, int.class, DEFAULT_POLLING_WAIT_TIME); } public boolean firstPullRequired() { - return finalConfig.getBoolean(FIRST_PULL_REQUIRED, false); + return environment.getProperty(FIRST_PULL_REQUIRED, boolean.class, false); } public String getCustomLabel() { - return finalConfig.getString(CUSTOM_LABEL, CUSTOM_LABEL_DEFAULT); + return environment.getProperty(CUSTOM_LABEL, CUSTOM_LABEL_DEFAULT); } public String getCustomLabelValue() { - return finalConfig.getString(CUSTOM_LABEL_VALUE, CUSTOM_LABEL_VALUE_DEFAULT); + return environment.getProperty(CUSTOM_LABEL_VALUE, CUSTOM_LABEL_VALUE_DEFAULT); } public Boolean isProxyEnable() { - return finalConfig.getBoolean(VertxConst.PROXY_ENABLE, false); + return environment.getProperty(VertxConst.PROXY_ENABLE, boolean.class, false); } public String getProxyHost() { - return finalConfig.getString(VertxConst.PROXY_HOST, "127.0.0.1"); + return environment.getProperty(VertxConst.PROXY_HOST, "127.0.0.1"); } public int getProxyPort() { - return finalConfig.getInt(VertxConst.PROXY_PORT, 8080); + return environment.getProperty(VertxConst.PROXY_PORT, int.class, 8080); } public String getProxyUsername() { - return finalConfig.getString(VertxConst.PROXY_USERNAME, null); + return environment.getProperty(VertxConst.PROXY_USERNAME); } public String getProxyPasswd() { - return finalConfig.getString(VertxConst.PROXY_PASSWD, null); + return environment.getProperty(VertxConst.PROXY_PASSWD); } } diff --git a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigConfiguration.java b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigConfiguration.java index 7b8e35bd6..50a362379 100644 --- a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigConfiguration.java +++ b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigConfiguration.java @@ -18,10 +18,21 @@ package org.apache.servicecomb.config.kie; import org.apache.servicecomb.config.kie.collect.KieClientInformationCollector; import org.springframework.context.annotation.Bean; +import org.springframework.core.env.Environment; public class KieConfigConfiguration { @Bean public KieClientInformationCollector kieClientInformationCollector() { return new KieClientInformationCollector(); } + + @Bean + public KieConfig kieConfig(Environment environment) { + return new KieConfig(environment); + } + + @Bean + public KieDynamicPropertiesSource kieDynamicPropertiesSource() { + return new KieDynamicPropertiesSource(); + } } diff --git a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigurationSourceImpl.java b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieDynamicPropertiesSource.java similarity index 50% rename from dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigurationSourceImpl.java rename to dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieDynamicPropertiesSource.java index fbf700e82..d18fca89d 100644 --- a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieConfigurationSourceImpl.java +++ b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/KieDynamicPropertiesSource.java @@ -14,18 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.servicecomb.config.kie; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; @@ -33,126 +28,124 @@ import org.apache.http.client.CredentialsProvider; import org.apache.http.client.config.RequestConfig; import org.apache.http.impl.client.BasicCredentialsProvider; import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.servicecomb.config.DynamicPropertiesSource; +import org.apache.servicecomb.config.MicroserviceProperties; import org.apache.servicecomb.config.common.ConfigConverter; import org.apache.servicecomb.config.common.ConfigurationChangedEvent; import org.apache.servicecomb.config.kie.client.KieClient; import org.apache.servicecomb.config.kie.client.KieConfigManager; import org.apache.servicecomb.config.kie.client.model.KieAddressManager; import org.apache.servicecomb.config.kie.client.model.KieConfiguration; -import org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource; import org.apache.servicecomb.foundation.auth.AuthHeaderProvider; +import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx; import org.apache.servicecomb.foundation.common.event.EventManager; import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils; import org.apache.servicecomb.http.client.auth.RequestAuthHeaderProvider; import org.apache.servicecomb.http.client.common.HttpTransport; import org.apache.servicecomb.http.client.common.HttpTransportFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.EnumerablePropertySource; +import org.springframework.core.env.Environment; +import org.springframework.core.env.MapPropertySource; import com.google.common.eventbus.Subscribe; -import com.netflix.config.ConcurrentCompositeConfiguration; -import com.netflix.config.WatchedUpdateListener; -import com.netflix.config.WatchedUpdateResult; - -public class KieConfigurationSourceImpl implements ConfigCenterConfigurationSource { - private static final Logger LOGGER = LoggerFactory.getLogger(KieConfigurationSourceImpl.class); +public class KieDynamicPropertiesSource implements DynamicPropertiesSource<Map<String, Object>> { + public static final String SOURCE_NAME = "kie"; - private final List<WatchedUpdateListener> listeners = new CopyOnWriteArrayList<>(); + private final Map<String, Object> data = new ConcurrentHashMapEx<>(); private KieConfigManager kieConfigManager; private ConfigConverter configConverter; - @Override - public int getOrder() { - return ORDER_BASE * 2; - } + private KieConfig kieConfig; - @Override - public boolean isValidSource(Configuration localConfiguration) { - KieConfig.setFinalConfig((ConcurrentCompositeConfiguration) localConfiguration); + private MicroserviceProperties microserviceProperties; - if (StringUtils.isEmpty(KieConfig.INSTANCE.getServerUri())) { - LOGGER.info("Kie server is not configured."); - return false; - } - return true; + @Autowired + public void setKieConfig(KieConfig kieConfig) { + this.kieConfig = kieConfig; } - @Override - public void init(Configuration localConfiguration) { - configConverter = new ConfigConverter(KieConfig.INSTANCE.getFileSources()); + @Autowired + public void setMicroserviceProperties(MicroserviceProperties microserviceProperties) { + this.microserviceProperties = microserviceProperties; + } + + private void init(Environment environment) { + configConverter = new ConfigConverter(kieConfig.getFileSources()); KieAddressManager kieAddressManager = configKieAddressManager(); RequestConfig.Builder requestBuilder = HttpTransportFactory.defaultRequestConfig(); - if (KieConfig.INSTANCE.enableLongPolling() - && KieConfig.INSTANCE.getPollingWaitTime() >= 0) { - requestBuilder.setConnectionRequestTimeout(KieConfig.INSTANCE.getPollingWaitTime() * 2 * 1000); - requestBuilder.setSocketTimeout(KieConfig.INSTANCE.getPollingWaitTime() * 2 * 1000); + if (kieConfig.enableLongPolling() + && kieConfig.getPollingWaitTime() >= 0) { + requestBuilder.setConnectionRequestTimeout(kieConfig.getPollingWaitTime() * 2 * 1000); + requestBuilder.setSocketTimeout(kieConfig.getPollingWaitTime() * 2 * 1000); } HttpTransport httpTransport = createHttpTransport(kieAddressManager, requestBuilder.build(), - localConfiguration); + environment); KieConfiguration kieConfiguration = createKieConfiguration(); KieClient kieClient = new KieClient(kieAddressManager, httpTransport, kieConfiguration); EventManager.register(this); kieConfigManager = new KieConfigManager(kieClient, EventManager.getEventBus(), kieConfiguration, configConverter); kieConfigManager.firstPull(); kieConfigManager.startConfigKieManager(); - updateConfiguration(WatchedUpdateResult.createIncremental(configConverter.getCurrentData(), null, null)); + data.putAll(configConverter.getCurrentData()); } @Subscribe public void onConfigurationChangedEvent(ConfigurationChangedEvent event) { - updateConfiguration( - WatchedUpdateResult.createIncremental(event.getAdded(), event.getUpdated(), event.getDeleted())); + data.putAll(event.getAdded()); + data.putAll(event.getUpdated()); + event.getDeleted().forEach((k, v) -> data.remove(k)); } private KieConfiguration createKieConfiguration() { - return new KieConfiguration().setAppName(KieConfig.INSTANCE.getAppName()) - .setFirstPullRequired(KieConfig.INSTANCE.firstPullRequired()) - .setCustomLabel(KieConfig.INSTANCE.getCustomLabel()) - .setCustomLabelValue(KieConfig.INSTANCE.getCustomLabelValue()) - .setEnableAppConfig(KieConfig.INSTANCE.enableAppConfig()) - .setEnableCustomConfig(KieConfig.INSTANCE.enableCustomConfig()) - .setEnableLongPolling(KieConfig.INSTANCE.enableLongPolling()) - .setEnableServiceConfig(KieConfig.INSTANCE.enableServiceConfig()) - .setEnableVersionConfig(KieConfig.INSTANCE.enableVersionConfig()) - .setEnvironment(KieConfig.INSTANCE.getEnvironment()) - .setVersion(KieConfig.INSTANCE.getVersion()) - .setPollingWaitInSeconds(KieConfig.INSTANCE.getPollingWaitTime()) - .setProject(KieConfig.INSTANCE.getDomainName()) - .setRefreshIntervalInMillis(KieConfig.INSTANCE.getRefreshInterval()) - .setServiceName(KieConfig.INSTANCE.getServiceName()); + return new KieConfiguration().setAppName(microserviceProperties.getApplication()) + .setFirstPullRequired(kieConfig.firstPullRequired()) + .setCustomLabel(kieConfig.getCustomLabel()) + .setCustomLabelValue(kieConfig.getCustomLabelValue()) + .setEnableAppConfig(kieConfig.enableAppConfig()) + .setEnableCustomConfig(kieConfig.enableCustomConfig()) + .setEnableLongPolling(kieConfig.enableLongPolling()) + .setEnableServiceConfig(kieConfig.enableServiceConfig()) + .setEnableVersionConfig(kieConfig.enableVersionConfig()) + .setEnvironment(microserviceProperties.getEnvironment()) + .setVersion(microserviceProperties.getVersion()) + .setPollingWaitInSeconds(kieConfig.getPollingWaitTime()) + .setProject(kieConfig.getDomainName()) + .setRefreshIntervalInMillis(kieConfig.getRefreshInterval()) + .setServiceName(microserviceProperties.getName()); } private HttpTransport createHttpTransport(KieAddressManager kieAddressManager, RequestConfig requestConfig, - Configuration localConfiguration) { + Environment environment) { List<AuthHeaderProvider> authHeaderProviders = SPIServiceUtils.getOrLoadSortedService(AuthHeaderProvider.class); - if (KieConfig.INSTANCE.isProxyEnable()) { + if (kieConfig.isProxyEnable()) { HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(). setDefaultRequestConfig(requestConfig); - HttpHost proxy = new HttpHost(KieConfig.INSTANCE.getProxyHost(), - KieConfig.INSTANCE.getProxyPort(), "http"); // now only support http proxy + HttpHost proxy = new HttpHost(kieConfig.getProxyHost(), + kieConfig.getProxyPort(), "http"); // now only support http proxy httpClientBuilder.setProxy(proxy); CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); credentialsProvider.setCredentials(new AuthScope(proxy), - new UsernamePasswordCredentials(KieConfig.INSTANCE.getProxyUsername(), - KieConfig.INSTANCE.getProxyPasswd())); + new UsernamePasswordCredentials(kieConfig.getProxyUsername(), + kieConfig.getProxyPasswd())); httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); return HttpTransportFactory .createHttpTransport( TransportUtils - .createSSLProperties(kieAddressManager.sslEnabled(), localConfiguration, KieConfig.SSL_TAG), + .createSSLProperties(kieAddressManager.sslEnabled(), environment, KieConfig.SSL_TAG), getRequestAuthHeaderProvider(authHeaderProviders), httpClientBuilder); } return HttpTransportFactory .createHttpTransport( TransportUtils - .createSSLProperties(kieAddressManager.sslEnabled(), localConfiguration, KieConfig.SSL_TAG), + .createSSLProperties(kieAddressManager.sslEnabled(), environment, KieConfig.SSL_TAG), getRequestAuthHeaderProvider(authHeaderProviders), requestConfig); } @@ -166,45 +159,17 @@ public class KieConfigurationSourceImpl implements ConfigCenterConfigurationSour private KieAddressManager configKieAddressManager() { return new KieAddressManager( - Arrays.asList(KieConfig.INSTANCE.getServerUri().split(",")), EventManager.getEventBus()); - } - - private void updateConfiguration(WatchedUpdateResult result) { - LOGGER.info("configuration changed keys, added=[{}], updated=[{}], deleted=[{}]", - result.getAdded() == null ? "" : result.getAdded().keySet(), - result.getChanged() == null ? "" : result.getChanged().keySet(), - result.getDeleted() == null ? "" : result.getDeleted().keySet()); - - for (WatchedUpdateListener l : listeners) { - try { - l.updateConfiguration(result); - } catch (Throwable ex) { - LOGGER.error("Error in invoking WatchedUpdateListener", ex); - } - } - } - - @Override - public void destroy() { - if (kieConfigManager == null) { - return; - } - kieConfigManager.stop(); + Arrays.asList(kieConfig.getServerUri().split(",")), EventManager.getEventBus()); } @Override - public void addUpdateListener(WatchedUpdateListener watchedUpdateListener) { - listeners.add(watchedUpdateListener); + public EnumerablePropertySource<Map<String, Object>> create(Environment environment) { + init(environment); + return new MapPropertySource(SOURCE_NAME, data); } @Override - public void removeUpdateListener(WatchedUpdateListener watchedUpdateListener) { - listeners.remove(watchedUpdateListener); - } - - @Override - public Map<String, Object> getCurrentData() throws Exception { - // data will updated by first pull, set empty to DynamicWatchedConfiguration first. - return Collections.emptyMap(); + public int getOrder() { + return 0; } } diff --git a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/TransportUtils.java b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/TransportUtils.java index 56afa18ed..8cabafec6 100644 --- a/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/TransportUtils.java +++ b/dynamic-config/config-kie/src/main/java/org/apache/servicecomb/config/kie/TransportUtils.java @@ -19,13 +19,13 @@ package org.apache.servicecomb.config.kie; import static org.apache.servicecomb.foundation.ssl.SSLOption.DEFAULT_OPTION; -import org.apache.commons.configuration.Configuration; import org.apache.servicecomb.foundation.ssl.SSLCustom; import org.apache.servicecomb.foundation.ssl.SSLOption; import org.apache.servicecomb.http.client.common.HttpConfiguration.SSLProperties; +import org.springframework.core.env.Environment; public class TransportUtils { - public static SSLProperties createSSLProperties(boolean sslEnabled, Configuration configuration, String tag) { + public static SSLProperties createSSLProperties(boolean sslEnabled, Environment environment, String tag) { SSLProperties sslProperties = new SSLProperties(); sslProperties.setEnabled(sslEnabled); @@ -34,93 +34,93 @@ public class TransportUtils { } SSLOption option = new SSLOption(); - option.setEngine(getStringProperty(configuration, + option.setEngine(getStringProperty(environment, DEFAULT_OPTION.getEngine(), "ssl." + tag + ".engine", "ssl.engine")); option.setProtocols( - getStringProperty(configuration, + getStringProperty(environment, DEFAULT_OPTION.getProtocols(), "ssl." + tag + ".protocols", "ssl.protocols")); option.setCiphers( - getStringProperty(configuration, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".ciphers", "ssl.ciphers")); + getStringProperty(environment, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".ciphers", "ssl.ciphers")); option.setAuthPeer( - getBooleanProperty(configuration, DEFAULT_OPTION.isAuthPeer(), "ssl." + tag + ".authPeer", "ssl.authPeer")); + getBooleanProperty(environment, DEFAULT_OPTION.isAuthPeer(), "ssl." + tag + ".authPeer", "ssl.authPeer")); option.setCheckCNHost( - getBooleanProperty(configuration, + getBooleanProperty(environment, DEFAULT_OPTION.isCheckCNHost(), "ssl." + tag + ".checkCN.host", "ssl.checkCN.host")); option.setCheckCNWhite( - getBooleanProperty(configuration, + getBooleanProperty(environment, DEFAULT_OPTION.isCheckCNWhite(), "ssl." + tag + ".checkCN.white", "ssl.checkCN.white")); - option.setCheckCNWhiteFile(getStringProperty(configuration, + option.setCheckCNWhiteFile(getStringProperty(environment, DEFAULT_OPTION.getCiphers(), "ssl." + tag + ".checkCN.white.file", "ssl.checkCN.white.file")); - option.setAllowRenegociate(getBooleanProperty(configuration, + option.setAllowRenegociate(getBooleanProperty(environment, DEFAULT_OPTION.isAllowRenegociate(), "ssl." + tag + ".allowRenegociate", "ssl.allowRenegociate")); option.setStorePath( - getStringProperty(configuration, + getStringProperty(environment, DEFAULT_OPTION.getStorePath(), "ssl." + tag + ".storePath", "ssl.storePath")); option.setClientAuth( - getStringProperty(configuration, + getStringProperty(environment, DEFAULT_OPTION.getClientAuth(), "ssl." + tag + ".clientAuth", "ssl.clientAuth")); option.setTrustStore( - getStringProperty(configuration, + getStringProperty(environment, DEFAULT_OPTION.getTrustStore(), "ssl." + tag + ".trustStore", "ssl.trustStore")); - option.setTrustStoreType(getStringProperty(configuration, + option.setTrustStoreType(getStringProperty(environment, DEFAULT_OPTION.getTrustStoreType(), "ssl." + tag + ".trustStoreType", "ssl.trustStoreType")); - option.setTrustStoreValue(getStringProperty(configuration, + option.setTrustStoreValue(getStringProperty(environment, DEFAULT_OPTION.getTrustStoreValue(), "ssl." + tag + ".trustStoreValue", "ssl.trustStoreValue")); option.setKeyStore( - getStringProperty(configuration, DEFAULT_OPTION.getKeyStore(), "ssl." + tag + ".keyStore", "ssl.keyStore")); + getStringProperty(environment, DEFAULT_OPTION.getKeyStore(), "ssl." + tag + ".keyStore", "ssl.keyStore")); option.setKeyStoreType( - getStringProperty(configuration, + getStringProperty(environment, DEFAULT_OPTION.getKeyStoreType(), "ssl." + tag + ".keyStoreType", "ssl.keyStoreType")); - option.setKeyStoreValue(getStringProperty(configuration, + option.setKeyStoreValue(getStringProperty(environment, DEFAULT_OPTION.getKeyStoreValue(), "ssl." + tag + ".keyStoreValue", "ssl.keyStoreValue")); - option.setCrl(getStringProperty(configuration, DEFAULT_OPTION.getCrl(), "ssl." + tag + ".crl", "ssl.crl")); + option.setCrl(getStringProperty(environment, DEFAULT_OPTION.getCrl(), "ssl." + tag + ".crl", "ssl.crl")); option.setSslCustomClass( - getStringProperty(configuration, null, "ssl." + tag + ".sslCustomClass", "ssl.sslCustomClass")); + getStringProperty(environment, null, "ssl." + tag + ".sslCustomClass", "ssl.sslCustomClass")); sslProperties.setSslOption(option); sslProperties.setSslCustom(SSLCustom.createSSLCustom(option.getSslCustomClass())); return sslProperties; } - private static String getStringProperty(Configuration configuration, String defaultValue, String... keys) { + private static String getStringProperty(Environment environment, String defaultValue, String... keys) { for (String key : keys) { - if (configuration.containsKey(key)) { - return configuration.getString(key); + if (environment.getProperty(key) != null) { + return environment.getProperty(key); } } return defaultValue; } - private static boolean getBooleanProperty(Configuration configuration, boolean defaultValue, String... keys) { + private static boolean getBooleanProperty(Environment environment, boolean defaultValue, String... keys) { for (String key : keys) { - if (configuration.containsKey(key)) { - return configuration.getBoolean(key); + if (environment.getProperty(key) != null) { + return environment.getProperty(key, boolean.class, false); } } return defaultValue; diff --git a/dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource b/dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource deleted file mode 100644 index 67520d4dc..000000000 --- a/dynamic-config/config-kie/src/main/resources/META-INF/services/org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.apache.servicecomb.config.kie.KieConfigurationSourceImpl \ No newline at end of file diff --git a/dynamic-config/config-nacos/src/main/resources/META-INF/services/org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource b/dynamic-config/config-nacos/src/main/resources/META-INF/services/org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource deleted file mode 100644 index 94965f147..000000000 --- a/dynamic-config/config-nacos/src/main/resources/META-INF/services/org.apache.servicecomb.config.spi.ConfigCenterConfigurationSource +++ /dev/null @@ -1,18 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -org.apache.servicecomb.config.nacos.archaius.sources.NacosConfigurationSourceImpl