You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2023/10/10 01:47:33 UTC
[servicecomb-java-chassis] 08/25: [SCB-2008]remove archaius dependency: apollo adapter
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 c8c6479228f37466e54a4e07975d46ffb56f4210
Author: liubao <bi...@qq.com>
AuthorDate: Mon Sep 25 17:32:59 2023 +0800
[SCB-2008]remove archaius dependency: apollo adapter
---
.../config/apollo/ApolloConfiguration.java | 28 ++++++++++++++++++++++
...rk.boot.autoconfigure.AutoConfiguration.imports | 18 ++++++++++++++
.../config/apollo/ApolloClientTest.java | 17 ++++++-------
3 files changed, 53 insertions(+), 10 deletions(-)
diff --git a/dynamic-config/config-apollo/src/main/java/org/apache/servicecomb/config/apollo/ApolloConfiguration.java b/dynamic-config/config-apollo/src/main/java/org/apache/servicecomb/config/apollo/ApolloConfiguration.java
new file mode 100644
index 000000000..26dd7a2ee
--- /dev/null
+++ b/dynamic-config/config-apollo/src/main/java/org/apache/servicecomb/config/apollo/ApolloConfiguration.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+package org.apache.servicecomb.config.apollo;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class ApolloConfiguration {
+ @Bean
+ public ApolloDynamicPropertiesSource apolloDynamicPropertiesSource() {
+ return new ApolloDynamicPropertiesSource();
+ }
+}
diff --git a/dynamic-config/config-apollo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/dynamic-config/config-apollo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 000000000..31e450534
--- /dev/null
+++ b/dynamic-config/config-apollo/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.apollo.ApolloConfiguration
diff --git a/dynamic-config/config-apollo/src/test/java/org/apache/servicecomb/config/apollo/ApolloClientTest.java b/dynamic-config/config-apollo/src/test/java/org/apache/servicecomb/config/apollo/ApolloClientTest.java
index a531a2ea3..c284a1fbf 100644
--- a/dynamic-config/config-apollo/src/test/java/org/apache/servicecomb/config/apollo/ApolloClientTest.java
+++ b/dynamic-config/config-apollo/src/test/java/org/apache/servicecomb/config/apollo/ApolloClientTest.java
@@ -21,11 +21,8 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.servicecomb.config.ConfigUtil;
-import org.apache.servicecomb.config.apollo.ApolloClient;
-import org.apache.servicecomb.config.apollo.ApolloConfig;
-import org.apache.servicecomb.config.archaius.sources.ApolloConfigurationSourceImpl;
-import org.apache.servicecomb.config.archaius.sources.ApolloConfigurationSourceImpl.UpdateHandler;
import org.apache.servicecomb.config.apollo.ApolloClient.ConfigRefresh;
+import org.apache.servicecomb.config.apollo.ApolloDynamicPropertiesSource.UpdateHandler;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -53,11 +50,11 @@ public class ApolloClientTest {
ResponseEntity<String> responseEntity = new ResponseEntity<>(
"{\"apollo\":\"mocked\", \"configurations\":{\"timeout\":1000}}", HttpStatus.OK);
Mockito.when(rest.exchange(
- ArgumentMatchers.anyString(),
- ArgumentMatchers.any(HttpMethod.class),
- ArgumentMatchers.<HttpEntity<String>>any(),
- ArgumentMatchers.<Class<String>>any())).thenReturn(responseEntity);
- ApolloConfigurationSourceImpl impl = new ApolloConfigurationSourceImpl();
+ ArgumentMatchers.anyString(),
+ ArgumentMatchers.any(HttpMethod.class),
+ ArgumentMatchers.<HttpEntity<String>>any(),
+ ArgumentMatchers.<Class<String>>any())).thenReturn(responseEntity);
+ ApolloDynamicPropertiesSource impl = new ApolloDynamicPropertiesSource();
UpdateHandler updateHandler = impl.new UpdateHandler();
ApolloClient apolloClient = new ApolloClient(updateHandler);
ConfigRefresh cr = apolloClient.new ConfigRefresh(apolloConfig.getServerUri());
@@ -72,7 +69,7 @@ public class ApolloClientTest {
Map<String, Object> before = new HashMap<>();
Map<String, Object> after = new HashMap<>();
- ApolloConfigurationSourceImpl impl = new ApolloConfigurationSourceImpl();
+ ApolloDynamicPropertiesSource impl = new ApolloDynamicPropertiesSource();
UpdateHandler updateHandler = impl.new UpdateHandler();
ApolloClient apolloClient = new ApolloClient(updateHandler);