diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index d8f071e045b..00000000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright 2022 Apollo Authors
-#
-# Licensed 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.
-#
-# This workflow will build a Java project with Maven
-# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
-
-name: publish sdks
-
-on:
- workflow_dispatch:
- inputs:
- repository:
- description: 'Maven Repository(snapshots or releases)'
- required: true
- default: 'snapshots'
-
-jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Set up Maven Central Repository
- uses: actions/setup-java@v1
- with:
- java-version: 8
- server-id: ${{ github.event.inputs.repository }}
- server-username: MAVEN_USERNAME
- server-password: MAVEN_CENTRAL_TOKEN
- gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
- gpg-passphrase: MAVEN_GPG_PASSPHRASE
- - name: Publish to Apache Maven Central
- run: mvn clean deploy -pl apollo-client,apollo-mockserver,apollo-openapi,apollo-client-config-data -am -DskipTests=true -Prelease "-Dreleases.repo=https://oss.sonatype.org/service/local/staging/deploy/maven2" "-Dsnapshots.repo=https://oss.sonatype.org/content/repositories/snapshots"
- env:
- MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
- MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }}
- MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
\ No newline at end of file
diff --git a/CHANGES.md b/CHANGES.md
index 34cc988ac48..c724a90626a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,10 +5,6 @@ Release Notes.
Apollo 2.1.0
------------------
-* [Add a config adjust the property source overriden behavior](https://github.com/apolloconfig/apollo/pull/4409)
-* [feat(apollo-client): the spi of config service load balancer client](https://github.com/apolloconfig/apollo/pull/4394)
-* [add cat-client as optional dependency](https://github.com/apolloconfig/apollo/pull/4414)
-* [refactor Functions class with lambda](https://github.com/apolloconfig/apollo/pull/4419)
* [fix:occur a 400 error request when openapi key's parameter contain "a[0]"](https://github.com/apolloconfig/apollo/pull/4424)
* [Upgrade mysql-connector-java version to fix possible transaction rollback failure issue](https://github.com/apolloconfig/apollo/pull/4425)
* [Remove database migration tool Flyway](https://github.com/apolloconfig/apollo/pull/4361)
@@ -21,7 +17,7 @@ Apollo 2.1.0
* [Optimize performance of '/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces' interface queries](https://github.com/apolloconfig/apollo/pull/4473)
* [Add a new API to load items with pagination](https://github.com/apolloconfig/apollo/pull/4468)
* [fix(#4474):'openjdk:8-jre-alpine' potentially causing wrong number of cpu cores](https://github.com/apolloconfig/apollo/pull/4475)
-* [Switching spring-session serialization mode to json for compatibility with spring-security version updates]()
+* [Switching spring-session serialization mode to json for compatibility with spring-security version updates](https://github.com/apolloconfig/apollo/pull/4484)
* [fix(#4483):Fixed overwrite JSON type configuration being empty](https://github.com/apolloconfig/apollo/pull/4486)
* [Allow users to delete AppNamespace](https://github.com/apolloconfig/apollo/pull/4499)
* [fix the deleted at timestamp issue](https://github.com/apolloconfig/apollo/pull/4493)
@@ -33,8 +29,8 @@ Apollo 2.1.0
* [fix openapi item with url illegalKey 400 error](https://github.com/apolloconfig/apollo/pull/4549)
* [fix the exception occurred when publish/rollback namespaces with grayrelease](https://github.com/apolloconfig/apollo/pull/4564)
* [fix create namespace with single dot 500 error](https://github.com/apolloconfig/apollo/pull/4568)
-* [Add overloaded shortcut method to register BeanDefinition](https://github.com/apolloconfig/apollo/pull/4574)
* [Add nodejs client sdk and fix doc](https://github.com/apolloconfig/apollo/pull/4590)
+* [Move apollo-core, apollo-client, apollo-mockserver, apollo-openapi and apollo-client-config-data to apollo-java repo](https://github.com/apolloconfig/apollo/pull/4594)
------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/11?closed=1)
\ No newline at end of file
diff --git a/apollo-client-config-data/pom.xml b/apollo-client-config-data/pom.xml
deleted file mode 100644
index c162ce28d5c..00000000000
--- a/apollo-client-config-data/pom.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
- com.ctrip.framework.apollo
- apollo
- ${revision}
- ../pom.xml
-
- 4.0.0
- apollo-client-config-data
- Apollo Client Config Data
-
- ${project.artifactId}
-
-
-
- com.ctrip.framework.apollo
- apollo-client
-
-
- org.springframework.boot
- spring-boot-autoconfigure
- provided
-
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
-
- org.springframework
- spring-webflux
- true
-
-
-
- org.springframework.boot
- spring-boot-starter-log4j2
- test
-
-
- com.github.stefanbirkner
- system-lambda
- test
-
-
- org.springframework.boot
- spring-boot-starter
- test
-
-
- org.springframework.boot
- spring-boot-starter-logging
-
-
-
-
-
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/ApolloClientConfigDataAutoConfiguration.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/ApolloClientConfigDataAutoConfiguration.java
deleted file mode 100644
index 15779366d9c..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/ApolloClientConfigDataAutoConfiguration.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data;
-
-import com.ctrip.framework.apollo.config.data.extension.initialize.ApolloClientPropertiesFactory;
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import com.ctrip.framework.apollo.spring.config.ConfigPropertySourcesProcessor;
-import com.ctrip.framework.apollo.spring.config.PropertySourcesProcessor;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author vdisk
- */
-@Configuration(proxyBeanMethods = false)
-public class ApolloClientConfigDataAutoConfiguration {
-
- @ConditionalOnMissingBean(ApolloClientProperties.class)
- @ConfigurationProperties(ApolloClientPropertiesFactory.PROPERTIES_PREFIX)
- @Bean
- public static ApolloClientProperties apolloWebClientSecurityProperties() {
- return new ApolloClientProperties();
- }
-
- @ConditionalOnMissingBean(PropertySourcesProcessor.class)
- @Bean
- public static ConfigPropertySourcesProcessor configPropertySourcesProcessor() {
- return new ConfigPropertySourcesProcessor();
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/enums/ApolloClientMessagingType.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/enums/ApolloClientMessagingType.java
deleted file mode 100644
index 4b77bc7433f..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/enums/ApolloClientMessagingType.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.enums;
-
-/**
- * @author vdisk
- */
-public enum ApolloClientMessagingType {
-
- /**
- * long polling
- */
- LONG_POLLING,
-
- /**
- * websocket
- */
- WEBSOCKET,
- ;
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientExtensionInitializeFactory.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientExtensionInitializeFactory.java
deleted file mode 100644
index f6f86a1c951..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientExtensionInitializeFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.initialize;
-
-import com.ctrip.framework.apollo.config.data.extension.enums.ApolloClientMessagingType;
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientExtensionProperties;
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import com.ctrip.framework.apollo.config.data.extension.webclient.ApolloClientLongPollingExtensionInitializer;
-import com.ctrip.framework.apollo.config.data.extension.websocket.ApolloClientWebsocketExtensionInitializer;
-import com.ctrip.framework.apollo.config.data.util.Slf4jLogMessageFormatter;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Binder;
-
-/**
- * @author vdisk
- */
-public class ApolloClientExtensionInitializeFactory {
-
- private final Log log;
-
- private final ApolloClientPropertiesFactory apolloClientPropertiesFactory;
-
- private final ApolloClientLongPollingExtensionInitializer apolloClientLongPollingExtensionInitializer;
-
- private final ApolloClientWebsocketExtensionInitializer apolloClientWebsocketExtensionInitializer;
-
- public ApolloClientExtensionInitializeFactory(Log log,
- ConfigurableBootstrapContext bootstrapContext) {
- this.log = log;
- this.apolloClientPropertiesFactory = new ApolloClientPropertiesFactory();
- this.apolloClientLongPollingExtensionInitializer = new ApolloClientLongPollingExtensionInitializer(log,
- bootstrapContext);
- this.apolloClientWebsocketExtensionInitializer = new ApolloClientWebsocketExtensionInitializer(log,
- bootstrapContext);
- }
-
- /**
- * initialize extension
- *
- * @param binder properties binder
- * @param bindHandler properties bind handler
- */
- public void initializeExtension(Binder binder, BindHandler bindHandler) {
- ApolloClientProperties apolloClientProperties = this.apolloClientPropertiesFactory
- .createApolloClientProperties(binder, bindHandler);
- if (apolloClientProperties == null || apolloClientProperties.getExtension() == null) {
- this.log.info("apollo client extension is not configured, default to disabled");
- return;
- }
- ApolloClientExtensionProperties extension = apolloClientProperties.getExtension();
- if (!extension.getEnabled()) {
- this.log.info("apollo client extension disabled");
- return;
- }
- ApolloClientMessagingType messagingType = extension.getMessagingType();
- log.debug(Slf4jLogMessageFormatter
- .format("apollo client extension messaging type: {}", messagingType));
- switch (messagingType) {
- case LONG_POLLING:
- this.apolloClientLongPollingExtensionInitializer
- .initialize(apolloClientProperties, binder, bindHandler);
- return;
- case WEBSOCKET:
- this.apolloClientWebsocketExtensionInitializer
- .initialize(apolloClientProperties, binder, bindHandler);
- return;
- default:
- throw new IllegalStateException("Unexpected value: " + messagingType);
- }
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientExtensionInitializer.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientExtensionInitializer.java
deleted file mode 100644
index cb9d0c6d013..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientExtensionInitializer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.initialize;
-
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Binder;
-
-/**
- * @author vdisk
- */
-public interface ApolloClientExtensionInitializer {
-
- /**
- * initialize extension
- *
- * @param apolloClientProperties apollo client extension properties
- * @param binder properties binder
- * @param bindHandler properties bind handler
- */
- void initialize(ApolloClientProperties apolloClientProperties, Binder binder,
- BindHandler bindHandler);
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactory.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactory.java
deleted file mode 100644
index cb008ae7d47..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.initialize;
-
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Bindable;
-import org.springframework.boot.context.properties.bind.Binder;
-
-/**
- * @author vdisk
- */
-public class ApolloClientPropertiesFactory {
-
- public static final String PROPERTIES_PREFIX = "apollo.client";
-
- public ApolloClientProperties createApolloClientProperties(
- Binder binder,
- BindHandler bindHandler) {
- return binder.bind(PROPERTIES_PREFIX,
- Bindable.of(ApolloClientProperties.class), bindHandler).orElse(null);
- }
-
- public OAuth2ClientProperties createOauth2ClientProperties(Binder binder,
- BindHandler bindHandler) {
- return binder.bind("spring.security.oauth2.client", Bindable.of(OAuth2ClientProperties.class),
- bindHandler).orElse(null);
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/properties/ApolloClientExtensionProperties.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/properties/ApolloClientExtensionProperties.java
deleted file mode 100644
index f8732a29432..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/properties/ApolloClientExtensionProperties.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.properties;
-
-import com.ctrip.framework.apollo.config.data.extension.enums.ApolloClientMessagingType;
-
-/**
- * @author vdisk
- */
-public class ApolloClientExtensionProperties {
-
- /**
- * enable apollo client extension(webclient/websocket and authentication)
- */
- private Boolean enabled = false;
-
- /**
- * apollo client listening type
- */
- private ApolloClientMessagingType messagingType = ApolloClientMessagingType.LONG_POLLING;
-
- public Boolean getEnabled() {
- return enabled;
- }
-
- public void setEnabled(Boolean enabled) {
- this.enabled = enabled;
- }
-
- public ApolloClientMessagingType getMessagingType() {
- return messagingType;
- }
-
- public void setMessagingType(
- ApolloClientMessagingType messagingType) {
- this.messagingType = messagingType;
- }
-
- @Override
- public String toString() {
- return "ApolloClientExtensionProperties{" +
- "enabled=" + enabled +
- ", messagingType=" + messagingType +
- '}';
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/properties/ApolloClientProperties.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/properties/ApolloClientProperties.java
deleted file mode 100644
index 2b085f07aad..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/properties/ApolloClientProperties.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.properties;
-
-import org.springframework.boot.context.properties.NestedConfigurationProperty;
-
-/**
- * @author vdisk
- */
-public class ApolloClientProperties {
-
- /**
- * extension configuration
- */
- @NestedConfigurationProperty
- private ApolloClientExtensionProperties extension;
-
- public ApolloClientExtensionProperties getExtension() {
- return extension;
- }
-
- public void setExtension(
- ApolloClientExtensionProperties extension) {
- this.extension = extension;
- }
-
- @Override
- public String toString() {
- return "ApolloClientProperties{" +
- "extension=" + extension +
- '}';
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/ApolloClientLongPollingExtensionInitializer.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/ApolloClientLongPollingExtensionInitializer.java
deleted file mode 100644
index 07fc8eefcdb..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/ApolloClientLongPollingExtensionInitializer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.webclient;
-
-import com.ctrip.framework.apollo.config.data.extension.initialize.ApolloClientExtensionInitializer;
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import com.ctrip.framework.apollo.config.data.extension.webclient.customizer.spi.ApolloClientWebClientCustomizerFactory;
-import com.ctrip.framework.apollo.config.data.injector.ApolloConfigDataInjectorCustomizer;
-import com.ctrip.framework.apollo.util.http.HttpClient;
-import com.ctrip.framework.foundation.internals.ServiceBootstrap;
-import java.util.List;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.reactive.function.client.WebClient;
-
-/**
- * @author vdisk
- */
-public class ApolloClientLongPollingExtensionInitializer implements
- ApolloClientExtensionInitializer {
-
- private final Log log;
-
- private final ConfigurableBootstrapContext bootstrapContext;
-
- public ApolloClientLongPollingExtensionInitializer(Log log,
- ConfigurableBootstrapContext bootstrapContext) {
- this.log = log;
- this.bootstrapContext = bootstrapContext;
- }
-
- @Override
- public void initialize(ApolloClientProperties apolloClientProperties, Binder binder,
- BindHandler bindHandler) {
- WebClient.Builder webClientBuilder = WebClient.builder();
- List factories = ServiceBootstrap
- .loadAllOrdered(ApolloClientWebClientCustomizerFactory.class);
- if (!CollectionUtils.isEmpty(factories)) {
- for (ApolloClientWebClientCustomizerFactory factory : factories) {
- WebClientCustomizer webClientCustomizer = factory
- .createWebClientCustomizer(apolloClientProperties, binder, bindHandler, this.log,
- this.bootstrapContext);
- if (webClientCustomizer != null) {
- webClientCustomizer.customize(webClientBuilder);
- }
- }
- }
- HttpClient httpClient = new ApolloWebClientHttpClient(webClientBuilder.build());
- ApolloConfigDataInjectorCustomizer.registerIfAbsent(HttpClient.class, () -> httpClient);
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/ApolloWebClientHttpClient.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/ApolloWebClientHttpClient.java
deleted file mode 100644
index f36bcca4c59..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/ApolloWebClientHttpClient.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.webclient;
-
-import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
-import com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException;
-import com.ctrip.framework.apollo.util.http.HttpClient;
-import com.ctrip.framework.apollo.util.http.HttpRequest;
-import com.ctrip.framework.apollo.util.http.HttpResponse;
-import com.google.gson.Gson;
-import java.lang.reflect.Type;
-import java.net.URI;
-import java.util.Map;
-import org.springframework.http.HttpStatus;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.reactive.function.client.WebClient;
-import reactor.core.publisher.Mono;
-
-/**
- * @author vdisk
- */
-public class ApolloWebClientHttpClient implements HttpClient {
-
- private final WebClient webClient;
-
- private final Gson gson;
-
- public ApolloWebClientHttpClient(WebClient webClient) {
- this(webClient, new Gson());
- }
-
- public ApolloWebClientHttpClient(WebClient webClient, Gson gson) {
- this.webClient = webClient;
- this.gson = gson;
- }
-
- @Override
- public HttpResponse doGet(HttpRequest httpRequest, Class responseType)
- throws ApolloConfigException {
- return this.doGetInternal(httpRequest, responseType);
- }
-
- private HttpResponse doGetInternal(HttpRequest httpRequest, Type responseType)
- throws ApolloConfigException {
- WebClient.RequestHeadersSpec> requestHeadersSpec = this.webClient.get()
- .uri(URI.create(httpRequest.getUrl()));
- if (!CollectionUtils.isEmpty(httpRequest.getHeaders())) {
- for (Map.Entry entry : httpRequest.getHeaders().entrySet()) {
- requestHeadersSpec.header(entry.getKey(), entry.getValue());
- }
- }
- return requestHeadersSpec.exchangeToMono(clientResponse -> {
- if (HttpStatus.OK.equals(clientResponse.statusCode())) {
- return clientResponse.bodyToMono(String.class)
- .map(body -> new HttpResponse(HttpStatus.OK.value(),
- gson.fromJson(body, responseType)));
- }
- if (HttpStatus.NOT_MODIFIED.equals(clientResponse.statusCode())) {
- return Mono.just(new HttpResponse(HttpStatus.NOT_MODIFIED.value(), null));
- }
- return Mono.error(new ApolloConfigStatusCodeException(clientResponse.rawStatusCode(),
- String.format("Get operation failed for %s", httpRequest.getUrl())));
- }).block();
- }
-
- @Override
- public HttpResponse doGet(HttpRequest httpRequest, Type responseType)
- throws ApolloConfigException {
- return this.doGetInternal(httpRequest, responseType);
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/customizer/spi/ApolloClientWebClientCustomizerFactory.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/customizer/spi/ApolloClientWebClientCustomizerFactory.java
deleted file mode 100644
index 8e3448ede6a..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/webclient/customizer/spi/ApolloClientWebClientCustomizerFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.webclient.customizer.spi;
-
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import com.ctrip.framework.apollo.core.spi.Ordered;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
-import org.springframework.lang.Nullable;
-
-/**
- * @author vdisk
- */
-public interface ApolloClientWebClientCustomizerFactory extends Ordered {
-
- /**
- * create a WebClientCustomizer instance
- *
- * @param apolloClientProperties apollo client binded properties
- * @param binder properties binder
- * @param bindHandler properties binder Handler
- * @param log deferred log
- * @param bootstrapContext bootstrapContext
- * @return WebClientCustomizer instance or null
- */
- @Nullable
- WebClientCustomizer createWebClientCustomizer(ApolloClientProperties apolloClientProperties,
- Binder binder, BindHandler bindHandler, Log log,
- ConfigurableBootstrapContext bootstrapContext);
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/websocket/ApolloClientWebsocketExtensionInitializer.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/websocket/ApolloClientWebsocketExtensionInitializer.java
deleted file mode 100644
index 88342fdcde9..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/extension/websocket/ApolloClientWebsocketExtensionInitializer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.websocket;
-
-import com.ctrip.framework.apollo.config.data.extension.initialize.ApolloClientExtensionInitializer;
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Binder;
-
-/**
- * @author vdisk
- */
-public class ApolloClientWebsocketExtensionInitializer implements ApolloClientExtensionInitializer {
-
- private final Log log;
-
- private final ConfigurableBootstrapContext bootstrapContext;
-
- public ApolloClientWebsocketExtensionInitializer(Log log,
- ConfigurableBootstrapContext bootstrapContext) {
- this.log = log;
- this.bootstrapContext = bootstrapContext;
- }
-
- @Override
- public void initialize(ApolloClientProperties apolloClientProperties, Binder binder,
- BindHandler bindHandler) {
- throw new UnsupportedOperationException("apollo client websocket support is not complete yet.");
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoader.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoader.java
deleted file mode 100644
index 2cb09a6540e..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoader.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.importer;
-
-import com.ctrip.framework.apollo.Config;
-import com.ctrip.framework.apollo.ConfigService;
-import com.ctrip.framework.apollo.config.data.util.Slf4jLogMessageFormatter;
-import com.ctrip.framework.apollo.spring.config.ConfigPropertySource;
-import com.ctrip.framework.apollo.spring.config.ConfigPropertySourceFactory;
-import com.ctrip.framework.apollo.spring.util.SpringInjector;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.BootstrapRegistry.InstanceSupplier;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.context.config.ConfigData;
-import org.springframework.boot.context.config.ConfigDataLoader;
-import org.springframework.boot.context.config.ConfigDataLoaderContext;
-import org.springframework.boot.context.config.ConfigDataResourceNotFoundException;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.core.Ordered;
-import org.springframework.core.env.PropertySource;
-
-/**
- * @author vdisk
- */
-public class ApolloConfigDataLoader implements ConfigDataLoader, Ordered {
-
- private final Log log;
-
- public ApolloConfigDataLoader(Log log) {
- this.log = log;
- }
-
- @Override
- public ConfigData load(ConfigDataLoaderContext context, ApolloConfigDataResource resource)
- throws IOException, ConfigDataResourceNotFoundException {
- ConfigurableBootstrapContext bootstrapContext = context.getBootstrapContext();
- Binder binder = bootstrapContext.get(Binder.class);
- BindHandler bindHandler = this.getBindHandler(context);
- bootstrapContext.registerIfAbsent(ApolloConfigDataLoaderInitializer.class, InstanceSupplier
- .from(() -> new ApolloConfigDataLoaderInitializer(this.log, binder, bindHandler,
- bootstrapContext)));
- ApolloConfigDataLoaderInitializer apolloConfigDataLoaderInitializer = bootstrapContext
- .get(ApolloConfigDataLoaderInitializer.class);
- // init apollo client
- List> initialPropertySourceList = apolloConfigDataLoaderInitializer
- .initApolloClient();
- // load config
- bootstrapContext.registerIfAbsent(ConfigPropertySourceFactory.class,
- InstanceSupplier.from(() -> SpringInjector.getInstance(ConfigPropertySourceFactory.class)));
- ConfigPropertySourceFactory configPropertySourceFactory = bootstrapContext
- .get(ConfigPropertySourceFactory.class);
- String namespace = resource.getNamespace();
- Config config = ConfigService.getConfig(namespace);
- ConfigPropertySource configPropertySource = configPropertySourceFactory
- .getConfigPropertySource(namespace, config);
- List> propertySourceList = new ArrayList<>();
- propertySourceList.add(configPropertySource);
- propertySourceList.addAll(initialPropertySourceList);
- log.debug(Slf4jLogMessageFormatter.format("apollo client loaded namespace [{}]", namespace));
- return new ConfigData(propertySourceList);
- }
-
- private BindHandler getBindHandler(ConfigDataLoaderContext context) {
- return context.getBootstrapContext().getOrElse(BindHandler.class, null);
- }
-
- @Override
- public int getOrder() {
- return Ordered.HIGHEST_PRECEDENCE + 100;
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoaderInitializer.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoaderInitializer.java
deleted file mode 100644
index ef36192492f..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLoaderInitializer.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.importer;
-
-import com.ctrip.framework.apollo.config.data.extension.initialize.ApolloClientExtensionInitializeFactory;
-import com.ctrip.framework.apollo.config.data.injector.ApolloConfigDataInjectorCustomizer;
-import com.ctrip.framework.apollo.config.data.internals.PureApolloConfigFactory;
-import com.ctrip.framework.apollo.config.data.system.ApolloClientSystemPropertyInitializer;
-import com.ctrip.framework.apollo.config.data.util.Slf4jLogMessageFormatter;
-import com.ctrip.framework.apollo.core.utils.DeferredLogger;
-import com.ctrip.framework.apollo.spi.ConfigFactory;
-import com.ctrip.framework.apollo.spring.config.PropertySourcesConstants;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Bindable;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.core.env.PropertySource;
-
-/**
- * @author vdisk
- */
-class ApolloConfigDataLoaderInitializer {
-
- private static volatile boolean INITIALIZED = false;
-
- private final Log log;
-
- private final Binder binder;
-
- private final BindHandler bindHandler;
-
- private final ConfigurableBootstrapContext bootstrapContext;
-
- public ApolloConfigDataLoaderInitializer(Log log,
- Binder binder, BindHandler bindHandler,
- ConfigurableBootstrapContext bootstrapContext) {
- this.log = log;
- this.binder = binder;
- this.bindHandler = bindHandler;
- this.bootstrapContext = bootstrapContext;
- }
-
- /**
- * init apollo client (only once)
- *
- * @return initial sources as placeholders or empty list if already initialized
- */
- public List> initApolloClient() {
- if (INITIALIZED) {
- return Collections.emptyList();
- }
- synchronized (ApolloConfigDataLoaderInitializer.class) {
- if (INITIALIZED) {
- return Collections.emptyList();
- }
- this.initApolloClientInternal();
- INITIALIZED = true;
- if (this.forceDisableApolloBootstrap()) {
- // force disable apollo bootstrap to avoid conflict
- Map map = new HashMap<>();
- map.put(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED, "false");
- map.put(PropertySourcesConstants.APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED, "false");
- // provide initial sources as placeholders to avoid duplicate loading
- return Arrays.asList(
- new ApolloConfigEmptyPropertySource(
- PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME),
- new MapPropertySource(PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME,
- Collections.unmodifiableMap(map)));
- }
- // provide initial sources as placeholders to avoid duplicate loading
- return Arrays.asList(
- new ApolloConfigEmptyPropertySource(PropertySourcesConstants.APOLLO_PROPERTY_SOURCE_NAME),
- new ApolloConfigEmptyPropertySource(
- PropertySourcesConstants.APOLLO_BOOTSTRAP_PROPERTY_SOURCE_NAME));
- }
- }
-
- private void initApolloClientInternal() {
- new ApolloClientSystemPropertyInitializer(this.log)
- .initializeSystemProperty(this.binder, this.bindHandler);
- new ApolloClientExtensionInitializeFactory(this.log,
- this.bootstrapContext).initializeExtension(this.binder, this.bindHandler);
- DeferredLogger.enable();
- ApolloConfigDataInjectorCustomizer.register(ConfigFactory.class,
- PureApolloConfigFactory::new);
- }
-
- private boolean forceDisableApolloBootstrap() {
- boolean bootstrapEnabled = this.binder
- .bind(this.camelCasedToKebabCase(PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED),
- Bindable.of(Boolean.class),
- this.bindHandler)
- .orElse(false);
- if (bootstrapEnabled) {
- this.log.warn(Slf4jLogMessageFormatter.format(
- "apollo bootstrap is force disabled. please don't configure the property [{}=true] and [spring.config.import=apollo://...] at the same time",
- PropertySourcesConstants.APOLLO_BOOTSTRAP_ENABLED));
- return true;
- }
- boolean bootstrapEagerLoadEnabled = this.binder
- .bind(this.camelCasedToKebabCase(
- PropertySourcesConstants.APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED),
- Bindable.of(Boolean.class),
- this.bindHandler)
- .orElse(false);
- if (bootstrapEagerLoadEnabled) {
- this.log.warn(Slf4jLogMessageFormatter.format(
- "apollo bootstrap eager load is force disabled. please don't configure the property [{}=true] and [spring.config.import=apollo://...] at the same time",
- PropertySourcesConstants.APOLLO_BOOTSTRAP_EAGER_LOAD_ENABLED));
- return true;
- }
- return false;
- }
-
- /**
- * {@link ConfigurationPropertyName#isValid(java.lang.CharSequence)}
- *
- * @param source origin propertyName
- * @return valid propertyName
- */
- private String camelCasedToKebabCase(String source) {
- if (ConfigurationPropertyName.isValid(source)) {
- return source;
- }
- StringBuilder stringBuilder = new StringBuilder(source.length() * 2);
- for (char ch : source.toCharArray()) {
- if (Character.isUpperCase(ch)) {
- stringBuilder.append("-").append(Character.toLowerCase(ch));
- continue;
- }
- stringBuilder.append(ch);
- }
- return stringBuilder.toString();
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLocationResolver.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLocationResolver.java
deleted file mode 100644
index cf1c088b5a2..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataLocationResolver.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.importer;
-
-import com.ctrip.framework.apollo.config.data.util.Slf4jLogMessageFormatter;
-import com.ctrip.framework.apollo.core.ConfigConsts;
-import java.util.Collections;
-import java.util.List;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.context.config.ConfigDataLocation;
-import org.springframework.boot.context.config.ConfigDataLocationNotFoundException;
-import org.springframework.boot.context.config.ConfigDataLocationResolver;
-import org.springframework.boot.context.config.ConfigDataLocationResolverContext;
-import org.springframework.boot.context.config.ConfigDataResourceNotFoundException;
-import org.springframework.boot.context.config.Profiles;
-import org.springframework.core.Ordered;
-import org.springframework.util.StringUtils;
-
-/**
- * @author vdisk
- */
-public class ApolloConfigDataLocationResolver implements
- ConfigDataLocationResolver, Ordered {
-
- private static final String PREFIX = "apollo://";
-
- private final Log log;
-
- public ApolloConfigDataLocationResolver(Log log) {
- this.log = log;
- }
-
- @Override
- public boolean isResolvable(ConfigDataLocationResolverContext context,
- ConfigDataLocation location) {
- return location.hasPrefix(PREFIX);
- }
-
- @Override
- public List resolve(ConfigDataLocationResolverContext context,
- ConfigDataLocation location)
- throws ConfigDataLocationNotFoundException, ConfigDataResourceNotFoundException {
- return Collections.emptyList();
- }
-
- @Override
- public List resolveProfileSpecific(
- ConfigDataLocationResolverContext context, ConfigDataLocation location, Profiles profiles)
- throws ConfigDataLocationNotFoundException {
- String namespace = location.getNonPrefixedValue(PREFIX);
- if (StringUtils.hasText(namespace)) {
- log.debug(Slf4jLogMessageFormatter.format("apollo config namespace [{}]", namespace));
- return Collections.singletonList(new ApolloConfigDataResource(namespace));
- }
- log.debug(Slf4jLogMessageFormatter.format("apollo config namespace is empty, default to [{}]",
- ConfigConsts.NAMESPACE_APPLICATION));
- return Collections.singletonList(ApolloConfigDataResource.DEFAULT);
- }
-
- @Override
- public int getOrder() {
- return Ordered.HIGHEST_PRECEDENCE + 100;
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataResource.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataResource.java
deleted file mode 100644
index 7339b6fb35a..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigDataResource.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.importer;
-
-import com.ctrip.framework.apollo.core.ConfigConsts;
-import java.util.Objects;
-import org.springframework.boot.context.config.ConfigDataResource;
-
-/**
- * @author vdisk
- */
-public class ApolloConfigDataResource extends ConfigDataResource {
-
- /**
- * default resource instance
- */
- public static final ApolloConfigDataResource DEFAULT = new ApolloConfigDataResource(
- ConfigConsts.NAMESPACE_APPLICATION);
-
- /**
- * apollo config namespace
- */
- private final String namespace;
-
- public ApolloConfigDataResource(String namespace) {
- this.namespace = namespace;
- }
-
- public String getNamespace() {
- return namespace;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- ApolloConfigDataResource that = (ApolloConfigDataResource) o;
- return Objects.equals(namespace, that.namespace);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(namespace);
- }
-
- @Override
- public String toString() {
- return "ApolloConfigDataResource{" +
- "namespace='" + namespace + '\'' +
- '}';
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigEmptyPropertySource.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigEmptyPropertySource.java
deleted file mode 100644
index 2d68d076bd9..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/importer/ApolloConfigEmptyPropertySource.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.importer;
-
-import java.util.Collections;
-import org.springframework.core.env.MapPropertySource;
-
-/**
- * @author vdisk
- */
-public class ApolloConfigEmptyPropertySource extends MapPropertySource {
-
- /**
- * Create a new {@code EmptyPropertySource} with the given name.
- *
- * @param name the associated name
- */
- public ApolloConfigEmptyPropertySource(String name) {
- super(name, Collections.emptyMap());
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/injector/ApolloConfigDataInjectorCustomizer.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/injector/ApolloConfigDataInjectorCustomizer.java
deleted file mode 100644
index 59e1eb4c604..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/injector/ApolloConfigDataInjectorCustomizer.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.injector;
-
-import com.ctrip.framework.apollo.core.spi.Ordered;
-import com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Supplier;
-
-/**
- * @author vdisk
- */
-public class ApolloConfigDataInjectorCustomizer implements ApolloInjectorCustomizer {
-
- /**
- * the order of the injector customizer
- */
- public static final int ORDER = Ordered.LOWEST_PRECEDENCE - 200;
-
- private static final Map, Supplier>> INSTANCE_SUPPLIERS = new ConcurrentHashMap<>();
-
- private static final Map, Object> INSTANCES = new ConcurrentHashMap<>();
-
- /**
- * Register a specific type with the registry. If the specified type has already been registered,
- * it will be replaced.
- *
- * @param the instance type
- * @param type the instance type
- * @param instanceSupplier the instance supplier
- */
- public static void register(Class type, Supplier instanceSupplier) {
- INSTANCE_SUPPLIERS.put(type, instanceSupplier);
- }
-
- /**
- * Register a specific type with the registry if one is not already present.
- *
- * @param the instance type
- * @param type the instance type
- * @param instanceSupplier the instance supplier
- */
- public static void registerIfAbsent(Class type, Supplier instanceSupplier) {
- INSTANCE_SUPPLIERS.putIfAbsent(type, instanceSupplier);
- }
-
- /**
- * Return if a registration exists for the given type.
- *
- * @param the instance type
- * @param type the instance type
- * @return {@code true} if the type has already been registered
- */
- public static boolean isRegistered(Class type) {
- return INSTANCE_SUPPLIERS.containsKey(type);
- }
-
- @Override
- public T getInstance(Class clazz) {
- @SuppressWarnings("unchecked")
- Supplier instanceSupplier = (Supplier) INSTANCE_SUPPLIERS.get(clazz);
- if (instanceSupplier == null) {
- return null;
- }
- return this.getInstance(clazz, instanceSupplier);
- }
-
- @SuppressWarnings("unchecked")
- private T getInstance(Class type, Supplier instanceSupplier) {
- T instance = (T) INSTANCES.get(type);
- if (instance != null) {
- return instance;
- }
- // prebuild an newInstance to prevent dead lock when recursive call computeIfAbsent
- // https://bugs.openjdk.java.net/browse/JDK-8062841
- T newInstance = instanceSupplier.get();
- return (T) INSTANCES.computeIfAbsent(type, key -> newInstance);
- }
-
- @Override
- public T getInstance(Class clazz, String name) {
- return null;
- }
-
- @Override
- public int getOrder() {
- return ORDER;
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
deleted file mode 100644
index c3bece952f1..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfig.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.internals;
-
-import com.ctrip.framework.apollo.internals.ConfigRepository;
-import com.ctrip.framework.apollo.internals.DefaultConfig;
-import com.ctrip.framework.apollo.internals.RepositoryChangeListener;
-import com.google.common.collect.Sets;
-import java.util.Set;
-import org.springframework.util.CollectionUtils;
-
-/**
- * @author vdisk
- */
-public class PureApolloConfig extends DefaultConfig implements RepositoryChangeListener {
-
- /**
- * Constructor.
- *
- * @param namespace the namespace of this config instance
- * @param configRepository the config repository for this config instance
- */
- public PureApolloConfig(String namespace,
- ConfigRepository configRepository) {
- super(namespace, configRepository);
- }
-
- @Override
- public String getProperty(String key, String defaultValue) {
- // step 1: check local cached properties file
- String value = this.getPropertyFromRepository(key);
-
- // step 2: check properties file from classpath
- if (value == null) {
- value = this.getPropertyFromAdditional(key);
- }
-
- this.tryWarnLog(value);
-
- return value == null ? defaultValue : value;
- }
-
- @Override
- public Set getPropertyNames() {
- // pure apollo config only contains the property from repository and the property from additional
- Set fromRepository = this.getPropertyNamesFromRepository();
- Set fromAdditional = this.getPropertyNamesFromAdditional();
- if (CollectionUtils.isEmpty(fromRepository)) {
- return fromAdditional;
- }
- if (CollectionUtils.isEmpty(fromAdditional)) {
- return fromRepository;
- }
- Set propertyNames = Sets
- .newLinkedHashSetWithExpectedSize(fromRepository.size() + fromAdditional.size());
- propertyNames.addAll(fromRepository);
- propertyNames.addAll(fromAdditional);
- return propertyNames;
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java
deleted file mode 100644
index c731c7f79bd..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/internals/PureApolloConfigFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.internals;
-
-import com.ctrip.framework.apollo.Config;
-import com.ctrip.framework.apollo.internals.ConfigRepository;
-import com.ctrip.framework.apollo.spi.ConfigFactory;
-import com.ctrip.framework.apollo.spi.DefaultConfigFactory;
-
-/**
- * @author vdisk
- */
-public class PureApolloConfigFactory extends DefaultConfigFactory implements ConfigFactory {
-
- @Override
- protected Config createRepositoryConfig(String namespace, ConfigRepository configRepository) {
- return new PureApolloConfig(namespace, configRepository);
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/listener/ApolloDeferredLoggerApplicationListener.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/listener/ApolloDeferredLoggerApplicationListener.java
deleted file mode 100644
index 4cbe2b83eba..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/listener/ApolloDeferredLoggerApplicationListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.listener;
-
-import com.ctrip.framework.apollo.core.utils.DeferredLogger;
-import org.springframework.boot.context.event.ApplicationContextInitializedEvent;
-import org.springframework.boot.context.event.ApplicationFailedEvent;
-import org.springframework.boot.context.event.SpringApplicationEvent;
-import org.springframework.context.ApplicationListener;
-
-/**
- * @author vdisk
- */
-public class ApolloDeferredLoggerApplicationListener implements
- ApplicationListener {
-
- @Override
- public void onApplicationEvent(SpringApplicationEvent event) {
- if (event instanceof ApplicationContextInitializedEvent) {
- DeferredLogger.replayTo();
- }
- if (event instanceof ApplicationFailedEvent) {
- DeferredLogger.replayTo();
- }
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/listener/ApolloSpringApplicationRegisterListener.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/listener/ApolloSpringApplicationRegisterListener.java
deleted file mode 100644
index 69ec5770460..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/listener/ApolloSpringApplicationRegisterListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.listener;
-
-import org.springframework.boot.BootstrapRegistry.InstanceSupplier;
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.context.event.ApplicationStartingEvent;
-import org.springframework.context.ApplicationListener;
-
-/**
- * @author vdisk
- */
-public class ApolloSpringApplicationRegisterListener implements
- ApplicationListener {
-
- @Override
- public void onApplicationEvent(ApplicationStartingEvent event) {
- ConfigurableBootstrapContext bootstrapContext = event.getBootstrapContext();
- bootstrapContext.registerIfAbsent(SpringApplication.class,
- InstanceSupplier.of(event.getSpringApplication()));
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertyInitializer.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertyInitializer.java
deleted file mode 100644
index 86c290dbde8..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertyInitializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.system;
-
-import com.ctrip.framework.apollo.config.data.util.Slf4jLogMessageFormatter;
-import com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer;
-import org.apache.commons.logging.Log;
-import org.springframework.boot.context.properties.bind.BindHandler;
-import org.springframework.boot.context.properties.bind.Bindable;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.util.StringUtils;
-
-/**
- * @author vdisk
- */
-public class ApolloClientSystemPropertyInitializer {
-
- private final Log log;
-
- public ApolloClientSystemPropertyInitializer(Log log) {
- this.log = log;
- }
-
- public void initializeSystemProperty(Binder binder, BindHandler bindHandler) {
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- this.fillSystemPropertyFromBinder(propertyName, propertyName, binder, bindHandler);
- }
- }
-
- private void fillSystemPropertyFromBinder(String propertyName, String bindName, Binder binder,
- BindHandler bindHandler) {
- if (System.getProperty(propertyName) != null) {
- return;
- }
- String propertyValue = binder.bind(bindName, Bindable.of(String.class), bindHandler)
- .orElse(null);
- if (!StringUtils.hasText(propertyValue)) {
- return;
- }
- log.debug(Slf4jLogMessageFormatter
- .format("apollo client set system property key=[{}] value=[{}]", propertyName,
- propertyValue));
- System.setProperty(propertyName, propertyValue);
- }
-}
diff --git a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/util/Slf4jLogMessageFormatter.java b/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/util/Slf4jLogMessageFormatter.java
deleted file mode 100644
index 80d5337e7eb..00000000000
--- a/apollo-client-config-data/src/main/java/com/ctrip/framework/apollo/config/data/util/Slf4jLogMessageFormatter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.util;
-
-import org.slf4j.helpers.MessageFormatter;
-import org.springframework.core.log.LogMessage;
-
-/**
- * @author vdisk
- */
-public class Slf4jLogMessageFormatter {
-
- /**
- * format log message
- *
- * @param pattern slf4j log message patten
- * @param args log message args
- * @return string
- */
- public static LogMessage format(String pattern, Object... args) {
- return LogMessage.of(() -> MessageFormatter.arrayFormat(pattern, args, null).getMessage());
- }
-}
diff --git a/apollo-client-config-data/src/main/resources/META-INF/services/com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer b/apollo-client-config-data/src/main/resources/META-INF/services/com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer
deleted file mode 100644
index 6978b155739..00000000000
--- a/apollo-client-config-data/src/main/resources/META-INF/services/com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer
+++ /dev/null
@@ -1 +0,0 @@
-com.ctrip.framework.apollo.config.data.injector.ApolloConfigDataInjectorCustomizer
\ No newline at end of file
diff --git a/apollo-client-config-data/src/main/resources/META-INF/spring.factories b/apollo-client-config-data/src/main/resources/META-INF/spring.factories
deleted file mode 100644
index 54404cdd65a..00000000000
--- a/apollo-client-config-data/src/main/resources/META-INF/spring.factories
+++ /dev/null
@@ -1,16 +0,0 @@
-# Auto Configure
-org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-com.ctrip.framework.apollo.config.data.ApolloClientConfigDataAutoConfiguration
-
-# ConfigData Location Resolvers
-org.springframework.boot.context.config.ConfigDataLocationResolver=\
-com.ctrip.framework.apollo.config.data.importer.ApolloConfigDataLocationResolver
-
-# ConfigData Loaders
-org.springframework.boot.context.config.ConfigDataLoader=\
-com.ctrip.framework.apollo.config.data.importer.ApolloConfigDataLoader
-
-# Listener
-org.springframework.context.ApplicationListener=\
-com.ctrip.framework.apollo.config.data.listener.ApolloDeferredLoggerApplicationListener,\
-com.ctrip.framework.apollo.config.data.listener.ApolloSpringApplicationRegisterListener
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactoryTest.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactoryTest.java
deleted file mode 100644
index 61fb59d5fda..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/extension/initialize/ApolloClientPropertiesFactoryTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.extension.initialize;
-
-import com.ctrip.framework.apollo.config.data.extension.enums.ApolloClientMessagingType;
-import com.ctrip.framework.apollo.config.data.extension.properties.ApolloClientProperties;
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
-
-/**
- * @author vdisk
- */
-public class ApolloClientPropertiesFactoryTest {
-
- @Test
- public void testCreateApolloClientProperties() throws IOException {
- Map map = new LinkedHashMap<>();
- map.put("apollo.client.extension.enabled", "true");
- map.put("apollo.client.extension.messaging-type", "long_polling");
- MapConfigurationPropertySource propertySource = new MapConfigurationPropertySource(map);
- Binder binder = new Binder(propertySource);
- ApolloClientPropertiesFactory factory = new ApolloClientPropertiesFactory();
- ApolloClientProperties apolloClientProperties = factory
- .createApolloClientProperties(binder, null);
-
- Assert.assertEquals(apolloClientProperties.getExtension().getEnabled(), true);
- Assert.assertEquals(apolloClientProperties.getExtension().getMessagingType(),
- ApolloClientMessagingType.LONG_POLLING);
- }
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/importer/PureApolloConfigTest.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/importer/PureApolloConfigTest.java
deleted file mode 100644
index a3ea4442b97..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/importer/PureApolloConfigTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.importer;
-
-import com.ctrip.framework.apollo.Config;
-import com.ctrip.framework.apollo.build.ApolloInjector;
-import com.ctrip.framework.apollo.config.data.injector.ApolloMockInjectorCustomizer;
-import com.ctrip.framework.apollo.config.data.internals.PureApolloConfigFactory;
-import com.ctrip.framework.apollo.spi.ConfigFactory;
-import com.ctrip.framework.apollo.spi.DefaultConfigFactory;
-import com.github.stefanbirkner.systemlambda.SystemLambda;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author vdisk
- */
-public class PureApolloConfigTest {
-
- @Before
- public void before() {
- System.setProperty("env", "local");
- }
-
- @After
- public void after() {
- System.clearProperty("spring.profiles.active");
- System.clearProperty("env");
- ApolloMockInjectorCustomizer.clear();
- }
-
- @Test
- public void testDefaultConfigWithSystemProperties() {
- System.setProperty("spring.profiles.active", "test");
- ApolloMockInjectorCustomizer.register(ConfigFactory.class,
- DefaultConfigFactory::new);
- ConfigFactory configFactory = ApolloInjector.getInstance(ConfigFactory.class);
- Config config = configFactory.create("application");
- Assert.assertEquals("test", config.getProperty("spring.profiles.active", null));
- }
-
- @Test
- public void testPureApolloConfigWithSystemProperties() {
- System.setProperty("spring.profiles.active", "test");
- ApolloMockInjectorCustomizer.register(ConfigFactory.class,
- PureApolloConfigFactory::new);
- ConfigFactory configFactory = ApolloInjector.getInstance(ConfigFactory.class);
- Config config = configFactory.create("application");
- Assert.assertNull(config.getProperty("spring.profiles.active", null));
- }
-
- @Test
- public void testDefaultConfigWithEnvironmentVariables() throws Exception {
- SystemLambda.withEnvironmentVariable(
- "SPRING_PROFILES_ACTIVE",
- "test-env")
- .execute(() -> {
- ApolloMockInjectorCustomizer.register(ConfigFactory.class,
- DefaultConfigFactory::new);
- ConfigFactory configFactory = ApolloInjector.getInstance(ConfigFactory.class);
- Config config = configFactory.create("application");
- Assert.assertEquals("test-env", config.getProperty("SPRING_PROFILES_ACTIVE", null));
- });
- }
-
- @Test
- public void testPureApolloConfigWithEnvironmentVariables() throws Exception {
- SystemLambda.withEnvironmentVariable(
- "SPRING_PROFILES_ACTIVE",
- "test-env")
- .execute(() -> {
- ApolloMockInjectorCustomizer.register(ConfigFactory.class,
- PureApolloConfigFactory::new);
- ConfigFactory configFactory = ApolloInjector.getInstance(ConfigFactory.class);
- Config config = configFactory.create("application");
- Assert.assertNull(config.getProperty("SPRING_PROFILES_ACTIVE", null));
- });
- }
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/injector/ApolloMockInjectorCustomizer.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/injector/ApolloMockInjectorCustomizer.java
deleted file mode 100644
index 58e18b469ac..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/injector/ApolloMockInjectorCustomizer.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.injector;
-
-import com.ctrip.framework.apollo.core.spi.Ordered;
-import com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Supplier;
-
-/**
- * @author vdisk
- */
-public class ApolloMockInjectorCustomizer implements ApolloInjectorCustomizer {
-
- private static final Map, Supplier>> INSTANCE_SUPPLIERS = new ConcurrentHashMap<>();
-
- private static final Map, Object> INSTANCES = new ConcurrentHashMap<>();
-
- /**
- * Register a specific type with the registry. If the specified type has already been registered,
- * it will be replaced.
- *
- * @param the instance type
- * @param type the instance type
- * @param instanceSupplier the instance supplier
- */
- public static void register(Class type, Supplier instanceSupplier) {
- INSTANCE_SUPPLIERS.put(type, instanceSupplier);
- }
-
- /**
- * Register a specific type with the registry if one is not already present.
- *
- * @param the instance type
- * @param type the instance type
- * @param instanceSupplier the instance supplier
- */
- public static void registerIfAbsent(Class type, Supplier instanceSupplier) {
- INSTANCE_SUPPLIERS.putIfAbsent(type, instanceSupplier);
- }
-
- /**
- * Return if a registration exists for the given type.
- *
- * @param the instance type
- * @param type the instance type
- * @return {@code true} if the type has already been registered
- */
- public static boolean isRegistered(Class type) {
- return INSTANCE_SUPPLIERS.containsKey(type);
- }
-
- /**
- * clear the instance cache and instance suppliers
- */
- public static void clear() {
- INSTANCE_SUPPLIERS.clear();
- INSTANCES.clear();
- }
-
- @Override
- public T getInstance(Class clazz) {
- @SuppressWarnings("unchecked")
- Supplier instanceSupplier = (Supplier) INSTANCE_SUPPLIERS.get(clazz);
- if (instanceSupplier == null) {
- return null;
- }
- return this.getInstance(clazz, instanceSupplier);
- }
-
- @SuppressWarnings("unchecked")
- private T getInstance(Class type, Supplier instanceSupplier) {
- T instance = (T) INSTANCES.get(type);
- if (instance != null) {
- return instance;
- }
- // prebuild an newInstance to prevent dead lock when recursive call computeIfAbsent
- // https://bugs.openjdk.java.net/browse/JDK-8062841
- T newInstance = instanceSupplier.get();
- return (T) INSTANCES.computeIfAbsent(type, key -> newInstance);
- }
-
- @Override
- public T getInstance(Class clazz, String name) {
- return null;
- }
-
- @Override
- public int getOrder() {
- return Ordered.HIGHEST_PRECEDENCE;
- }
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientApplicationPropertiesCompatibleTest.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientApplicationPropertiesCompatibleTest.java
deleted file mode 100644
index 8f27d77100d..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientApplicationPropertiesCompatibleTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.system;
-
-import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
-import com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * @author vdisk
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = ApolloClientPropertyCompatibleTestConfiguration.class,
- webEnvironment = SpringBootTest.WebEnvironment.NONE)
-@ActiveProfiles("test-compatible")
-public class ApolloClientApplicationPropertiesCompatibleTest {
-
- @Autowired
- private ConfigurableEnvironment environment;
-
- @Test
- public void testApplicationPropertiesCompatible() {
- Assert.assertEquals("test-1/cacheDir",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR));
- Assert.assertEquals("test-1-secret",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_ACCESS_KEY_SECRET));
- Assert.assertEquals("https://test-1-config-service",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE));
- }
-
- @After
- public void clearProperty() {
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- System.clearProperty(propertyName);
- }
- }
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientEnvironmentVariablesCompatibleTest.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientEnvironmentVariablesCompatibleTest.java
deleted file mode 100644
index 81a4f14d4f7..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientEnvironmentVariablesCompatibleTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.system;
-
-import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
-import com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer;
-import com.github.stefanbirkner.systemlambda.SystemLambda;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * @author vdisk
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = ApolloClientPropertyCompatibleTestConfiguration.class,
- webEnvironment = SpringBootTest.WebEnvironment.NONE)
-public class ApolloClientEnvironmentVariablesCompatibleTest {
-
- @Autowired
- private ConfigurableEnvironment environment;
-
- @Test
- public void testEnvironmentVariablesCompatible() throws Exception {
- SystemLambda.withEnvironmentVariable(
- ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR_ENVIRONMENT_VARIABLES,
- "test-2/cacheDir")
- .and(ApolloClientSystemConsts.DEPRECATED_APOLLO_ACCESS_KEY_SECRET_ENVIRONMENT_VARIABLES,
- "test-2-secret")
- .and(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES,
- "https://test-2-config-service")
- .execute(() -> {
- Assert.assertEquals("test-2/cacheDir",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR));
- Assert.assertEquals("test-2-secret",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_ACCESS_KEY_SECRET));
- Assert.assertEquals("https://test-2-config-service",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE));
- });
- }
-
- @After
- public void clearProperty() {
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- System.clearProperty(propertyName);
- }
- }
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientPropertyCompatibleTestConfiguration.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientPropertyCompatibleTestConfiguration.java
deleted file mode 100644
index e9ab5e6c8f6..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientPropertyCompatibleTestConfiguration.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.system;
-
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @author vdisk
- */
-@Configuration
-@EnableAutoConfiguration
-public class ApolloClientPropertyCompatibleTestConfiguration {
-
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertiesCompatibleTest.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertiesCompatibleTest.java
deleted file mode 100644
index b619b7a1546..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertiesCompatibleTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.system;
-
-import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
-import com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- * @author vdisk
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = ApolloClientPropertyCompatibleTestConfiguration.class,
- webEnvironment = SpringBootTest.WebEnvironment.NONE)
-public class ApolloClientSystemPropertiesCompatibleTest {
-
- @Autowired
- private ConfigurableEnvironment environment;
-
- @Test
- public void testSystemPropertiesCompatible() {
- System.setProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR, "test-3/cacheDir");
- System
- .setProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_ACCESS_KEY_SECRET, "test-3-secret");
- System.setProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE,
- "https://test-3-config-service");
-
- Assert.assertEquals("test-3/cacheDir",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_CACHE_DIR));
- Assert.assertEquals("test-3-secret",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_ACCESS_KEY_SECRET));
- Assert.assertEquals("https://test-3-config-service",
- this.environment.getProperty(ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE));
-
- System.clearProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CACHE_DIR);
- System.clearProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_ACCESS_KEY_SECRET);
- System.clearProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE);
- }
-
- @After
- public void clearProperty() {
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- System.clearProperty(propertyName);
- }
- }
-}
diff --git a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertyInitializerTest.java b/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertyInitializerTest.java
deleted file mode 100644
index 41a39729983..00000000000
--- a/apollo-client-config-data/src/test/java/com/ctrip/framework/apollo/config/data/system/ApolloClientSystemPropertyInitializerTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.config.data.system;
-
-import com.ctrip.framework.apollo.spring.boot.ApolloApplicationContextInitializer;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
-import org.springframework.boot.context.properties.bind.Binder;
-import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
-import org.springframework.boot.context.properties.source.MapConfigurationPropertySource;
-
-/**
- * @author vdisk
- */
-public class ApolloClientSystemPropertyInitializerTest {
-
- @Test
- public void testSystemPropertyNames() {
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- Assert.assertTrue(ConfigurationPropertyName.isValid(propertyName));
- }
- }
-
- @Test
- public void testInitializeSystemProperty() {
- Map map = new LinkedHashMap<>();
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- System.clearProperty(propertyName);
- map.put(propertyName, String.valueOf(ThreadLocalRandom.current().nextLong()));
- }
- MapConfigurationPropertySource propertySource = new MapConfigurationPropertySource(map);
- Binder binder = new Binder(propertySource);
- ApolloClientSystemPropertyInitializer initializer = new ApolloClientSystemPropertyInitializer(
- LogFactory.getLog(ApolloClientSystemPropertyInitializerTest.class));
- initializer.initializeSystemProperty(binder, null);
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- Assert.assertEquals(map.get(propertyName), System.getProperty(propertyName));
- }
- }
-
- @After
- public void clearProperty() {
- for (String propertyName : ApolloApplicationContextInitializer.APOLLO_SYSTEM_PROPERTIES) {
- System.clearProperty(propertyName);
- }
- }
-}
diff --git a/apollo-client-config-data/src/test/resources/META-INF/services/com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer b/apollo-client-config-data/src/test/resources/META-INF/services/com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer
deleted file mode 100644
index 86ef1645b48..00000000000
--- a/apollo-client-config-data/src/test/resources/META-INF/services/com.ctrip.framework.apollo.spi.ApolloInjectorCustomizer
+++ /dev/null
@@ -1 +0,0 @@
-com.ctrip.framework.apollo.config.data.injector.ApolloMockInjectorCustomizer
\ No newline at end of file
diff --git a/apollo-client-config-data/src/test/resources/application-test-compatible.properties b/apollo-client-config-data/src/test/resources/application-test-compatible.properties
deleted file mode 100644
index fbab7cbea63..00000000000
--- a/apollo-client-config-data/src/test/resources/application-test-compatible.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright 2022 Apollo Authors
-#
-# Licensed 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.
-#
-apollo.cacheDir=test-1/cacheDir
-apollo.accesskey.secret=test-1-secret
-apollo.configService=https://test-1-config-service
diff --git a/apollo-client-config-data/src/test/resources/log4j2.xml b/apollo-client-config-data/src/test/resources/log4j2.xml
deleted file mode 100644
index eb2cbbc5fa2..00000000000
--- a/apollo-client-config-data/src/test/resources/log4j2.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/apollo-client/pom.xml b/apollo-client/pom.xml
deleted file mode 100644
index 816b45b992c..00000000000
--- a/apollo-client/pom.xml
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
- com.ctrip.framework.apollo
- apollo
- ${revision}
- ../pom.xml
-
- 4.0.0
- apollo-client
- Apollo Client
-
- ${project.artifactId}
-
-
-
-
- com.ctrip.framework.apollo
- apollo-core
-
-
-
-
- com.google.inject
- guice
-
-
-
-
- org.slf4j
- slf4j-api
-
-
-
- org.yaml
- snakeyaml
-
-
-
-
- org.springframework
- spring-context
- true
-
-
-
- org.springframework.boot
- spring-boot-autoconfigure
- true
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
-
- org.eclipse.jetty
- jetty-server
- test
-
-
-
- org.slf4j
- jcl-over-slf4j
- test
-
-
- org.apache.logging.log4j
- log4j-slf4j-impl
- test
-
-
- org.apache.logging.log4j
- log4j-core
- test
-
-
-
-
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/Config.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/Config.java
deleted file mode 100644
index 26e507d6b2d..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/Config.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.enums.ConfigSourceType;
-import com.google.common.base.Function;
-
-import java.util.Date;
-import java.util.Locale;
-import java.util.Set;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public interface Config {
- /**
- * Return the property value with the given key, or {@code defaultValue} if the key doesn't exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value
- */
- String getProperty(String key, String defaultValue);
-
- /**
- * Return the integer property value with the given key, or {@code defaultValue} if the key
- * doesn't exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as integer
- */
- Integer getIntProperty(String key, Integer defaultValue);
-
- /**
- * Return the long property value with the given key, or {@code defaultValue} if the key doesn't
- * exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as long
- */
- Long getLongProperty(String key, Long defaultValue);
-
- /**
- * Return the short property value with the given key, or {@code defaultValue} if the key doesn't
- * exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as short
- */
- Short getShortProperty(String key, Short defaultValue);
-
- /**
- * Return the float property value with the given key, or {@code defaultValue} if the key doesn't
- * exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as float
- */
- Float getFloatProperty(String key, Float defaultValue);
-
- /**
- * Return the double property value with the given key, or {@code defaultValue} if the key doesn't
- * exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as double
- */
- Double getDoubleProperty(String key, Double defaultValue);
-
- /**
- * Return the byte property value with the given key, or {@code defaultValue} if the key doesn't
- * exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as byte
- */
- Byte getByteProperty(String key, Byte defaultValue);
-
- /**
- * Return the boolean property value with the given key, or {@code defaultValue} if the key
- * doesn't exist.
- *
- * @param key the property name
- * @param defaultValue the default value when key is not found or any error occurred
- * @return the property value as boolean
- */
- Boolean getBooleanProperty(String key, Boolean defaultValue);
-
- /**
- * Return the array property value with the given key, or {@code defaultValue} if the key doesn't exist.
- *
- * @param key the property name
- * @param delimiter the delimiter regex
- * @param defaultValue the default value when key is not found or any error occurred
- */
- String[] getArrayProperty(String key, String delimiter, String[] defaultValue);
-
- /**
- * Return the Date property value with the given name, or {@code defaultValue} if the name doesn't exist.
- * Will try to parse the date with Locale.US and formats as follows: yyyy-MM-dd HH:mm:ss.SSS,
- * yyyy-MM-dd HH:mm:ss and yyyy-MM-dd
- *
- * @param key the property name
- * @param defaultValue the default value when name is not found or any error occurred
- * @return the property value
- */
- Date getDateProperty(String key, Date defaultValue);
-
- /**
- * Return the Date property value with the given name, or {@code defaultValue} if the name doesn't exist.
- * Will parse the date with the format specified and Locale.US
- *
- * @param key the property name
- * @param format the date format, see {@link java.text.SimpleDateFormat} for more
- * information
- * @param defaultValue the default value when name is not found or any error occurred
- * @return the property value
- */
- Date getDateProperty(String key, String format, Date defaultValue);
-
- /**
- * Return the Date property value with the given name, or {@code defaultValue} if the name doesn't exist.
- *
- * @param key the property name
- * @param format the date format, see {@link java.text.SimpleDateFormat} for more
- * information
- * @param locale the locale to use
- * @param defaultValue the default value when name is not found or any error occurred
- * @return the property value
- */
- Date getDateProperty(String key, String format, Locale locale, Date defaultValue);
-
- /**
- * Return the Enum property value with the given key, or {@code defaultValue} if the key doesn't exist.
- *
- * @param key the property name
- * @param enumType the enum class
- * @param defaultValue the default value when key is not found or any error occurred
- * @param the enum
- * @return the property value
- */
- > T getEnumProperty(String key, Class enumType, T defaultValue);
-
- /**
- * Return the duration property value(in milliseconds) with the given name, or {@code
- * defaultValue} if the name doesn't exist. Please note the format should comply with the follow
- * example (case insensitive). Examples:
- *
- * "123MS" -- parses as "123 milliseconds"
- * "20S" -- parses as "20 seconds"
- * "15M" -- parses as "15 minutes" (where a minute is 60 seconds)
- * "10H" -- parses as "10 hours" (where an hour is 3600 seconds)
- * "2D" -- parses as "2 days" (where a day is 24 hours or 86400 seconds)
- * "2D3H4M5S123MS" -- parses as "2 days, 3 hours, 4 minutes, 5 seconds and 123 milliseconds"
- *
- *
- * @param key the property name
- * @param defaultValue the default value when name is not found or any error occurred
- * @return the parsed property value(in milliseconds)
- */
- long getDurationProperty(String key, long defaultValue);
-
- /**
- * Add change listener to this config instance, will be notified when any key is changed in this namespace.
- *
- * @param listener the config change listener
- */
- void addChangeListener(ConfigChangeListener listener);
-
- /**
- * Add change listener to this config instance, will only be notified when any of the interested keys is changed in this namespace.
- *
- * @param listener the config change listener
- * @param interestedKeys the keys interested by the listener
- *
- * @since 1.0.0
- */
- void addChangeListener(ConfigChangeListener listener, Set interestedKeys);
-
- /**
- * Add change listener to this config instance, will only be notified when any of the interested keys is changed in this namespace.
- *
- * @param listener the config change listener
- * @param interestedKeys the keys that the listener is interested in
- * @param interestedKeyPrefixes the key prefixes that the listener is interested in,
- * e.g. "spring." means that {@code listener} is interested in keys that starts with "spring.", such as "spring.banner", "spring.jpa", etc.
- * and "application" means that {@code listener} is interested in keys that starts with "application", such as "applicationName", "application.port", etc.
- * For more details, see {@link com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener#interestedKeyPrefixes()}
- * and {@link java.lang.String#startsWith(String)}
- *
- * @since 1.3.0
- */
- void addChangeListener(ConfigChangeListener listener, Set interestedKeys,
- Set interestedKeyPrefixes);
-
- /**
- * Remove the change listener
- *
- * @param listener the specific config change listener to remove
- * @return true if the specific config change listener is found and removed
- *
- * @since 1.1.0
- */
- boolean removeChangeListener(ConfigChangeListener listener);
-
- /**
- * Return a set of the property names
- *
- * @return the property names
- */
- Set getPropertyNames();
-
- /**
- * Return the user-defined property value with the given key, or {@code defaultValue} if the key doesn't exist.
- *
- * @param key the property name
- * @param function the transform {@link Function}. from String to user-defined type
- * @param defaultValue the default value when key is not found or any error occurred
- * @param user-defined type
- * @return the property value
- *
- * @since 1.1.0
- */
- T getProperty(String key, Function function, T defaultValue);
-
- /**
- * Return the config's source type, i.e. where is the config loaded from
- *
- * @return the config's source type
- *
- * @since 1.1.0
- */
- ConfigSourceType getSourceType();
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigChangeListener.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigChangeListener.java
deleted file mode 100644
index c303af9c712..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigChangeListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.model.ConfigChangeEvent;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public interface ConfigChangeListener {
- /**
- * Invoked when there is any config change for the namespace.
- * @param changeEvent the event for this change
- */
- void onChange(ConfigChangeEvent changeEvent);
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java
deleted file mode 100644
index 50b84a38d8e..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFile.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
-import com.ctrip.framework.apollo.enums.ConfigSourceType;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public interface ConfigFile {
- /**
- * Get file content of the namespace
- * @return file content, {@code null} if there is no content
- */
- String getContent();
-
- /**
- * Whether the config file has any content
- * @return true if it has content, false otherwise.
- */
- boolean hasContent();
-
- /**
- * Get the namespace of this config file instance
- * @return the namespace
- */
- String getNamespace();
-
- /**
- * Get the file format of this config file instance
- * @return the config file format enum
- */
- ConfigFileFormat getConfigFileFormat();
-
- /**
- * Add change listener to this config file instance.
- *
- * @param listener the config file change listener
- */
- void addChangeListener(ConfigFileChangeListener listener);
-
- /**
- * Remove the change listener
- *
- * @param listener the specific config change listener to remove
- * @return true if the specific config change listener is found and removed
- */
- boolean removeChangeListener(ConfigFileChangeListener listener);
-
- /**
- * Return the config's source type, i.e. where is the config loaded from
- *
- * @return the config's source type
- */
- ConfigSourceType getSourceType();
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFileChangeListener.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFileChangeListener.java
deleted file mode 100644
index 141386567e7..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigFileChangeListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.model.ConfigFileChangeEvent;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public interface ConfigFileChangeListener {
- /**
- * Invoked when there is any config change for the namespace.
- * @param changeEvent the event for this change
- */
- void onChange(ConfigFileChangeEvent changeEvent);
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
deleted file mode 100644
index 184c5ee356d..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/ConfigService.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo;
-
-import com.ctrip.framework.apollo.build.ApolloInjector;
-import com.ctrip.framework.apollo.core.ConfigConsts;
-import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
-import com.ctrip.framework.apollo.internals.ConfigManager;
-import com.ctrip.framework.apollo.spi.ConfigFactory;
-import com.ctrip.framework.apollo.spi.ConfigRegistry;
-
-/**
- * Entry point for client config use
- *
- * @author Jason Song(song_s@ctrip.com)
- */
-public class ConfigService {
- private static final ConfigService s_instance = new ConfigService();
-
- private volatile ConfigManager m_configManager;
- private volatile ConfigRegistry m_configRegistry;
-
- private ConfigManager getManager() {
- if (m_configManager == null) {
- synchronized (this) {
- if (m_configManager == null) {
- m_configManager = ApolloInjector.getInstance(ConfigManager.class);
- }
- }
- }
-
- return m_configManager;
- }
-
- private ConfigRegistry getRegistry() {
- if (m_configRegistry == null) {
- synchronized (this) {
- if (m_configRegistry == null) {
- m_configRegistry = ApolloInjector.getInstance(ConfigRegistry.class);
- }
- }
- }
-
- return m_configRegistry;
- }
-
- /**
- * Get Application's config instance.
- *
- * @return config instance
- */
- public static Config getAppConfig() {
- return getConfig(ConfigConsts.NAMESPACE_APPLICATION);
- }
-
- /**
- * Get the config instance for the namespace.
- *
- * @param namespace the namespace of the config
- * @return config instance
- */
- public static Config getConfig(String namespace) {
- return s_instance.getManager().getConfig(namespace);
- }
-
- public static ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat) {
- return s_instance.getManager().getConfigFile(namespace, configFileFormat);
- }
-
- static void setConfig(Config config) {
- setConfig(ConfigConsts.NAMESPACE_APPLICATION, config);
- }
-
- /**
- * Manually set the config for the namespace specified, use with caution.
- *
- * @param namespace the namespace
- * @param config the config instance
- */
- static void setConfig(String namespace, final Config config) {
- s_instance.getRegistry().register(namespace, new ConfigFactory() {
- @Override
- public Config create(String namespace) {
- return config;
- }
-
- @Override
- public ConfigFile createConfigFile(String namespace, ConfigFileFormat configFileFormat) {
- return null;
- }
-
- });
- }
-
- static void setConfigFactory(ConfigFactory factory) {
- setConfigFactory(ConfigConsts.NAMESPACE_APPLICATION, factory);
- }
-
- /**
- * Manually set the config factory for the namespace specified, use with caution.
- *
- * @param namespace the namespace
- * @param factory the factory instance
- */
- static void setConfigFactory(String namespace, ConfigFactory factory) {
- s_instance.getRegistry().register(namespace, factory);
- }
-
- // for test only
- static void reset() {
- synchronized (s_instance) {
- s_instance.m_configManager = null;
- s_instance.m_configRegistry = null;
- }
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/PropertiesCompatibleConfigFile.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/PropertiesCompatibleConfigFile.java
deleted file mode 100644
index 7e428ef6d4c..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/PropertiesCompatibleConfigFile.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo;
-
-import java.util.Properties;
-
-/**
- * Config files that are properties compatible, e.g. yaml
- *
- * @since 1.3.0
- */
-public interface PropertiesCompatibleConfigFile extends ConfigFile {
-
- /**
- * @return the properties form of the config file
- *
- * @throws RuntimeException if the content could not be transformed to properties
- */
- Properties asProperties();
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ApolloInjector.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ApolloInjector.java
deleted file mode 100644
index 2871cc96494..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/build/ApolloInjector.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.build;
-
-import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
-import com.ctrip.framework.apollo.internals.Injector;
-import com.ctrip.framework.apollo.tracer.Tracer;
-import com.ctrip.framework.foundation.internals.ServiceBootstrap;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public class ApolloInjector {
- private static volatile Injector s_injector;
- private static final Object lock = new Object();
-
- private static Injector getInjector() {
- if (s_injector == null) {
- synchronized (lock) {
- if (s_injector == null) {
- try {
- s_injector = ServiceBootstrap.loadFirst(Injector.class);
- } catch (Throwable ex) {
- ApolloConfigException exception = new ApolloConfigException("Unable to initialize Apollo Injector!", ex);
- Tracer.logError(exception);
- throw exception;
- }
- }
- }
- }
-
- return s_injector;
- }
-
- public static T getInstance(Class clazz) {
- try {
- return getInjector().getInstance(clazz);
- } catch (Throwable ex) {
- Tracer.logError(ex);
- throw new ApolloConfigException(String.format("Unable to load instance for type %s!", clazz.getName()), ex);
- }
- }
-
- public static T getInstance(Class clazz, String name) {
- try {
- return getInjector().getInstance(clazz, name);
- } catch (Throwable ex) {
- Tracer.logError(ex);
- throw new ApolloConfigException(
- String.format("Unable to load instance for type %s and name %s !", clazz.getName(), name), ex);
- }
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/enums/ConfigSourceType.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/enums/ConfigSourceType.java
deleted file mode 100644
index b8249472fb8..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/enums/ConfigSourceType.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.enums;
-
-/**
- * To indicate the config's source type, i.e. where is the config loaded from
- *
- * @since 1.1.0
- */
-public enum ConfigSourceType {
- REMOTE("Loaded from remote config service"), LOCAL("Loaded from local cache"), NONE("Load failed");
-
- private final String description;
-
- ConfigSourceType(String description) {
- this.description = description;
- }
-
- public String getDescription() {
- return description;
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/enums/PropertyChangeType.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/enums/PropertyChangeType.java
deleted file mode 100644
index ec72282e113..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/enums/PropertyChangeType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.enums;
-
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public enum PropertyChangeType {
- ADDED, MODIFIED, DELETED
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigException.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigException.java
deleted file mode 100644
index 3a7483cb0c9..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.exceptions;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public class ApolloConfigException extends RuntimeException {
- public ApolloConfigException(String message) {
- super(message);
- }
-
- public ApolloConfigException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigStatusCodeException.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigStatusCodeException.java
deleted file mode 100644
index ea2e0fe856e..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/exceptions/ApolloConfigStatusCodeException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.exceptions;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public class ApolloConfigStatusCodeException extends RuntimeException{
- private final int m_statusCode;
-
- public ApolloConfigStatusCodeException(int statusCode, String message) {
- super(String.format("[status code: %d] %s", statusCode, message));
- this.m_statusCode = statusCode;
- }
-
- public ApolloConfigStatusCodeException(int statusCode, Throwable cause) {
- super(cause);
- this.m_statusCode = statusCode;
- }
-
- public int getStatusCode() {
- return m_statusCode;
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
deleted file mode 100644
index 7ce41dcaf9a..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfig.java
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.Config;
-import com.ctrip.framework.apollo.ConfigChangeListener;
-import com.ctrip.framework.apollo.build.ApolloInjector;
-import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
-import com.ctrip.framework.apollo.enums.PropertyChangeType;
-import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
-import com.ctrip.framework.apollo.model.ConfigChange;
-import com.ctrip.framework.apollo.model.ConfigChangeEvent;
-import com.ctrip.framework.apollo.tracer.Tracer;
-import com.ctrip.framework.apollo.tracer.spi.Transaction;
-import com.ctrip.framework.apollo.util.ConfigUtil;
-import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
-import com.ctrip.framework.apollo.util.function.Functions;
-import com.ctrip.framework.apollo.util.parser.Parsers;
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-import java.util.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public abstract class AbstractConfig implements Config {
- private static final Logger logger = LoggerFactory.getLogger(AbstractConfig.class);
-
- private static final ExecutorService m_executorService;
-
- private final List m_listeners = Lists.newCopyOnWriteArrayList();
- private final Map> m_interestedKeys = Maps.newConcurrentMap();
- private final Map> m_interestedKeyPrefixes = Maps.newConcurrentMap();
- private final ConfigUtil m_configUtil;
- private volatile Cache m_integerCache;
- private volatile Cache m_longCache;
- private volatile Cache m_shortCache;
- private volatile Cache m_floatCache;
- private volatile Cache m_doubleCache;
- private volatile Cache m_byteCache;
- private volatile Cache m_booleanCache;
- private volatile Cache m_dateCache;
- private volatile Cache m_durationCache;
- private final Map> m_arrayCache;
- private final List allCaches;
- private final AtomicLong m_configVersion; //indicate config version
-
- protected PropertiesFactory propertiesFactory;
-
- static {
- m_executorService = Executors.newCachedThreadPool(ApolloThreadFactory
- .create("Config", true));
- }
-
- public AbstractConfig() {
- m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
- m_configVersion = new AtomicLong();
- m_arrayCache = Maps.newConcurrentMap();
- allCaches = Lists.newArrayList();
- propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
- }
-
- @Override
- public void addChangeListener(ConfigChangeListener listener) {
- addChangeListener(listener, null);
- }
-
- @Override
- public void addChangeListener(ConfigChangeListener listener, Set interestedKeys) {
- addChangeListener(listener, interestedKeys, null);
- }
-
- @Override
- public void addChangeListener(ConfigChangeListener listener, Set interestedKeys, Set interestedKeyPrefixes) {
- if (!m_listeners.contains(listener)) {
- m_listeners.add(listener);
- if (interestedKeys != null && !interestedKeys.isEmpty()) {
- m_interestedKeys.put(listener, Sets.newHashSet(interestedKeys));
- }
- if (interestedKeyPrefixes != null && !interestedKeyPrefixes.isEmpty()) {
- m_interestedKeyPrefixes.put(listener, Sets.newHashSet(interestedKeyPrefixes));
- }
- }
- }
-
- @Override
- public boolean removeChangeListener(ConfigChangeListener listener) {
- m_interestedKeys.remove(listener);
- m_interestedKeyPrefixes.remove(listener);
- return m_listeners.remove(listener);
- }
-
- @Override
- public Integer getIntProperty(String key, Integer defaultValue) {
- try {
- if (m_integerCache == null) {
- synchronized (this) {
- if (m_integerCache == null) {
- m_integerCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_INT_FUNCTION, m_integerCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getIntProperty for %s failed, return default value %d", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public Long getLongProperty(String key, Long defaultValue) {
- try {
- if (m_longCache == null) {
- synchronized (this) {
- if (m_longCache == null) {
- m_longCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_LONG_FUNCTION, m_longCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getLongProperty for %s failed, return default value %d", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public Short getShortProperty(String key, Short defaultValue) {
- try {
- if (m_shortCache == null) {
- synchronized (this) {
- if (m_shortCache == null) {
- m_shortCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_SHORT_FUNCTION, m_shortCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getShortProperty for %s failed, return default value %d", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public Float getFloatProperty(String key, Float defaultValue) {
- try {
- if (m_floatCache == null) {
- synchronized (this) {
- if (m_floatCache == null) {
- m_floatCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_FLOAT_FUNCTION, m_floatCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getFloatProperty for %s failed, return default value %f", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public Double getDoubleProperty(String key, Double defaultValue) {
- try {
- if (m_doubleCache == null) {
- synchronized (this) {
- if (m_doubleCache == null) {
- m_doubleCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_DOUBLE_FUNCTION, m_doubleCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getDoubleProperty for %s failed, return default value %f", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public Byte getByteProperty(String key, Byte defaultValue) {
- try {
- if (m_byteCache == null) {
- synchronized (this) {
- if (m_byteCache == null) {
- m_byteCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_BYTE_FUNCTION, m_byteCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getByteProperty for %s failed, return default value %d", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public Boolean getBooleanProperty(String key, Boolean defaultValue) {
- try {
- if (m_booleanCache == null) {
- synchronized (this) {
- if (m_booleanCache == null) {
- m_booleanCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_BOOLEAN_FUNCTION, m_booleanCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getBooleanProperty for %s failed, return default value %b", key,
- defaultValue), ex));
- }
- return defaultValue;
- }
-
- @Override
- public String[] getArrayProperty(String key, final String delimiter, String[] defaultValue) {
- try {
- if (!m_arrayCache.containsKey(delimiter)) {
- synchronized (this) {
- if (!m_arrayCache.containsKey(delimiter)) {
- m_arrayCache.put(delimiter, this.newCache());
- }
- }
- }
-
- Cache cache = m_arrayCache.get(delimiter);
- String[] result = cache.getIfPresent(key);
-
- if (result != null) {
- return result;
- }
-
- return getValueAndStoreToCache(key, new Function() {
- @Override
- public String[] apply(String input) {
- return input.split(delimiter);
- }
- }, cache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getArrayProperty for %s failed, return default value", key), ex));
- }
- return defaultValue;
- }
-
- @Override
- public > T getEnumProperty(String key, Class enumType, T defaultValue) {
- try {
- String value = getProperty(key, null);
-
- if (value != null) {
- return Enum.valueOf(enumType, value);
- }
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getEnumProperty for %s failed, return default value %s", key,
- defaultValue), ex));
- }
-
- return defaultValue;
- }
-
- @Override
- public Date getDateProperty(String key, Date defaultValue) {
- try {
- if (m_dateCache == null) {
- synchronized (this) {
- if (m_dateCache == null) {
- m_dateCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_DATE_FUNCTION, m_dateCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getDateProperty for %s failed, return default value %s", key,
- defaultValue), ex));
- }
-
- return defaultValue;
- }
-
- @Override
- public Date getDateProperty(String key, String format, Date defaultValue) {
- try {
- String value = getProperty(key, null);
-
- if (value != null) {
- return Parsers.forDate().parse(value, format);
- }
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getDateProperty for %s failed, return default value %s", key,
- defaultValue), ex));
- }
-
- return defaultValue;
- }
-
- @Override
- public Date getDateProperty(String key, String format, Locale locale, Date defaultValue) {
- try {
- String value = getProperty(key, null);
-
- if (value != null) {
- return Parsers.forDate().parse(value, format, locale);
- }
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getDateProperty for %s failed, return default value %s", key,
- defaultValue), ex));
- }
-
- return defaultValue;
- }
-
- @Override
- public long getDurationProperty(String key, long defaultValue) {
- try {
- if (m_durationCache == null) {
- synchronized (this) {
- if (m_durationCache == null) {
- m_durationCache = newCache();
- }
- }
- }
-
- return getValueFromCache(key, Functions.TO_DURATION_FUNCTION, m_durationCache, defaultValue);
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getDurationProperty for %s failed, return default value %d", key,
- defaultValue), ex));
- }
-
- return defaultValue;
- }
-
- @Override
- public T getProperty(String key, Function function, T defaultValue) {
- try {
- String value = getProperty(key, null);
-
- if (value != null) {
- return function.apply(value);
- }
- } catch (Throwable ex) {
- Tracer.logError(new ApolloConfigException(
- String.format("getProperty for %s failed, return default value %s", key,
- defaultValue), ex));
- }
-
- return defaultValue;
- }
-
- private T getValueFromCache(String key, Function parser, Cache cache, T defaultValue) {
- T result = cache.getIfPresent(key);
-
- if (result != null) {
- return result;
- }
-
- return getValueAndStoreToCache(key, parser, cache, defaultValue);
- }
-
- private T getValueAndStoreToCache(String key, Function parser, Cache cache, T defaultValue) {
- long currentConfigVersion = m_configVersion.get();
- String value = getProperty(key, null);
-
- if (value != null) {
- T result = parser.apply(value);
-
- if (result != null) {
- synchronized (this) {
- if (m_configVersion.get() == currentConfigVersion) {
- cache.put(key, result);
- }
- }
- return result;
- }
- }
-
- return defaultValue;
- }
-
- private Cache newCache() {
- Cache cache = CacheBuilder.newBuilder()
- .maximumSize(m_configUtil.getMaxConfigCacheSize())
- .expireAfterAccess(m_configUtil.getConfigCacheExpireTime(), m_configUtil.getConfigCacheExpireTimeUnit())
- .build();
- allCaches.add(cache);
- return cache;
- }
-
- /**
- * Clear config cache
- */
- protected void clearConfigCache() {
- synchronized (this) {
- for (Cache c : allCaches) {
- if (c != null) {
- c.invalidateAll();
- }
- }
- m_configVersion.incrementAndGet();
- }
- }
-
- /**
- * @param changes map's key is config property's key
- */
- protected void fireConfigChange(String namespace, Map changes) {
- final Set changedKeys = changes.keySet();
- final List listeners = this.findMatchedConfigChangeListeners(changedKeys);
-
- // notify those listeners
- for (ConfigChangeListener listener : listeners) {
- Set interestedChangedKeys = resolveInterestedChangedKeys(listener, changedKeys);
- InterestedConfigChangeEvent interestedConfigChangeEvent = new InterestedConfigChangeEvent(
- namespace, changes, interestedChangedKeys);
- this.notifyAsync(listener, interestedConfigChangeEvent);
- }
- }
-
- /**
- * Fire the listeners by event.
- */
- protected void fireConfigChange(final ConfigChangeEvent changeEvent) {
- final List listeners = this
- .findMatchedConfigChangeListeners(changeEvent.changedKeys());
-
- // notify those listeners
- for (ConfigChangeListener listener : listeners) {
- this.notifyAsync(listener, changeEvent);
- }
- }
-
- private List findMatchedConfigChangeListeners(Set changedKeys) {
- final List configChangeListeners = new ArrayList<>();
- for (ConfigChangeListener configChangeListener : this.m_listeners) {
- // check whether the listener is interested in this change event
- if (this.isConfigChangeListenerInterested(configChangeListener, changedKeys)) {
- configChangeListeners.add(configChangeListener);
- }
- }
- return configChangeListeners;
- }
-
- private void notifyAsync(final ConfigChangeListener listener, final ConfigChangeEvent changeEvent) {
- m_executorService.submit(new Runnable() {
- @Override
- public void run() {
- String listenerName = listener.getClass().getName();
- Transaction transaction = Tracer.newTransaction("Apollo.ConfigChangeListener", listenerName);
- try {
- listener.onChange(changeEvent);
- transaction.setStatus(Transaction.SUCCESS);
- } catch (Throwable ex) {
- transaction.setStatus(ex);
- Tracer.logError(ex);
- logger.error("Failed to invoke config change listener {}", listenerName, ex);
- } finally {
- transaction.complete();
- }
- }
- });
- }
-
- private boolean isConfigChangeListenerInterested(ConfigChangeListener configChangeListener, Set changedKeys) {
- Set interestedKeys = m_interestedKeys.get(configChangeListener);
- Set interestedKeyPrefixes = m_interestedKeyPrefixes.get(configChangeListener);
-
- if ((interestedKeys == null || interestedKeys.isEmpty())
- && (interestedKeyPrefixes == null || interestedKeyPrefixes.isEmpty())) {
- return true; // no interested keys means interested in all keys
- }
-
- if (interestedKeys != null) {
- for (String interestedKey : interestedKeys) {
- if (changedKeys.contains(interestedKey)) {
- return true;
- }
- }
- }
-
- if (interestedKeyPrefixes != null) {
- for (String prefix : interestedKeyPrefixes) {
- for (final String changedKey : changedKeys) {
- if (changedKey.startsWith(prefix)) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- private Set resolveInterestedChangedKeys(ConfigChangeListener configChangeListener, Set changedKeys) {
- Set interestedChangedKeys = new HashSet<>();
-
- if (this.m_interestedKeys.containsKey(configChangeListener)) {
- Set interestedKeys = this.m_interestedKeys.get(configChangeListener);
- for (String interestedKey : interestedKeys) {
- if (changedKeys.contains(interestedKey)) {
- interestedChangedKeys.add(interestedKey);
- }
- }
- }
-
- if (this.m_interestedKeyPrefixes.containsKey(configChangeListener)) {
- Set interestedKeyPrefixes = this.m_interestedKeyPrefixes.get(configChangeListener);
- for (String interestedKeyPrefix : interestedKeyPrefixes) {
- for (String changedKey : changedKeys) {
- if (changedKey.startsWith(interestedKeyPrefix)) {
- interestedChangedKeys.add(changedKey);
- }
- }
- }
- }
-
- return Collections.unmodifiableSet(interestedChangedKeys);
- }
-
- List calcPropertyChanges(String namespace, Properties previous,
- Properties current) {
- if (previous == null) {
- previous = propertiesFactory.getPropertiesInstance();
- }
-
- if (current == null) {
- current = propertiesFactory.getPropertiesInstance();
- }
-
- Set previousKeys = previous.stringPropertyNames();
- Set currentKeys = current.stringPropertyNames();
-
- Set commonKeys = Sets.intersection(previousKeys, currentKeys);
- Set newKeys = Sets.difference(currentKeys, commonKeys);
- Set removedKeys = Sets.difference(previousKeys, commonKeys);
-
- List changes = Lists.newArrayList();
-
- for (String newKey : newKeys) {
- changes.add(new ConfigChange(namespace, newKey, null, current.getProperty(newKey),
- PropertyChangeType.ADDED));
- }
-
- for (String removedKey : removedKeys) {
- changes.add(new ConfigChange(namespace, removedKey, previous.getProperty(removedKey), null,
- PropertyChangeType.DELETED));
- }
-
- for (String commonKey : commonKeys) {
- String previousValue = previous.getProperty(commonKey);
- String currentValue = current.getProperty(commonKey);
- if (Objects.equal(previousValue, currentValue)) {
- continue;
- }
- changes.add(new ConfigChange(namespace, commonKey, previousValue, currentValue,
- PropertyChangeType.MODIFIED));
- }
-
- return changes;
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
deleted file mode 100644
index 3a1c0df077c..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigFile.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.build.ApolloInjector;
-import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory;
-import com.ctrip.framework.apollo.enums.ConfigSourceType;
-import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.slf4j.Logger;
-
-import com.ctrip.framework.apollo.ConfigFile;
-import com.ctrip.framework.apollo.ConfigFileChangeListener;
-import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
-import com.ctrip.framework.apollo.enums.PropertyChangeType;
-import com.ctrip.framework.apollo.model.ConfigFileChangeEvent;
-import com.ctrip.framework.apollo.tracer.Tracer;
-import com.ctrip.framework.apollo.tracer.spi.Transaction;
-import com.ctrip.framework.apollo.util.ExceptionUtil;
-import com.google.common.collect.Lists;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public abstract class AbstractConfigFile implements ConfigFile, RepositoryChangeListener {
- private static final Logger logger = DeferredLoggerFactory.getLogger(AbstractConfigFile.class);
- private static ExecutorService m_executorService;
- protected final ConfigRepository m_configRepository;
- protected final String m_namespace;
- protected final AtomicReference m_configProperties;
- private final List m_listeners = Lists.newCopyOnWriteArrayList();
- protected final PropertiesFactory propertiesFactory;
-
- private volatile ConfigSourceType m_sourceType = ConfigSourceType.NONE;
-
- static {
- m_executorService = Executors.newCachedThreadPool(ApolloThreadFactory
- .create("ConfigFile", true));
- }
-
- public AbstractConfigFile(String namespace, ConfigRepository configRepository) {
- m_configRepository = configRepository;
- m_namespace = namespace;
- m_configProperties = new AtomicReference<>();
- propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
- initialize();
- }
-
- private void initialize() {
- try {
- m_configProperties.set(m_configRepository.getConfig());
- m_sourceType = m_configRepository.getSourceType();
- } catch (Throwable ex) {
- Tracer.logError(ex);
- logger.warn("Init Apollo Config File failed - namespace: {}, reason: {}.",
- m_namespace, ExceptionUtil.getDetailMessage(ex));
- } finally {
- //register the change listener no matter config repository is working or not
- //so that whenever config repository is recovered, config could get changed
- m_configRepository.addChangeListener(this);
- }
- }
-
- @Override
- public String getNamespace() {
- return m_namespace;
- }
-
- protected abstract void update(Properties newProperties);
-
- @Override
- public synchronized void onRepositoryChange(String namespace, Properties newProperties) {
- if (newProperties.equals(m_configProperties.get())) {
- return;
- }
- Properties newConfigProperties = propertiesFactory.getPropertiesInstance();
- newConfigProperties.putAll(newProperties);
-
- String oldValue = getContent();
-
- update(newProperties);
- m_sourceType = m_configRepository.getSourceType();
-
- String newValue = getContent();
-
- PropertyChangeType changeType = PropertyChangeType.MODIFIED;
-
- if (oldValue == null) {
- changeType = PropertyChangeType.ADDED;
- } else if (newValue == null) {
- changeType = PropertyChangeType.DELETED;
- }
-
- this.fireConfigChange(new ConfigFileChangeEvent(m_namespace, oldValue, newValue, changeType));
-
- Tracer.logEvent("Apollo.Client.ConfigChanges", m_namespace);
- }
-
- @Override
- public void addChangeListener(ConfigFileChangeListener listener) {
- if (!m_listeners.contains(listener)) {
- m_listeners.add(listener);
- }
- }
-
- @Override
- public boolean removeChangeListener(ConfigFileChangeListener listener) {
- return m_listeners.remove(listener);
- }
-
- @Override
- public ConfigSourceType getSourceType() {
- return m_sourceType;
- }
-
- private void fireConfigChange(final ConfigFileChangeEvent changeEvent) {
- for (final ConfigFileChangeListener listener : m_listeners) {
- m_executorService.submit(new Runnable() {
- @Override
- public void run() {
- String listenerName = listener.getClass().getName();
- Transaction transaction = Tracer.newTransaction("Apollo.ConfigFileChangeListener", listenerName);
- try {
- listener.onChange(changeEvent);
- transaction.setStatus(Transaction.SUCCESS);
- } catch (Throwable ex) {
- transaction.setStatus(ex);
- Tracer.logError(ex);
- logger.error("Failed to invoke config file change listener {}", listenerName, ex);
- } finally {
- transaction.complete();
- }
- }
- });
- }
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java
deleted file mode 100644
index 35ff55616c6..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.build.ApolloInjector;
-import com.ctrip.framework.apollo.util.factory.PropertiesFactory;
-import java.util.List;
-import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.ctrip.framework.apollo.tracer.Tracer;
-import com.ctrip.framework.apollo.util.ExceptionUtil;
-import com.google.common.collect.Lists;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public abstract class AbstractConfigRepository implements ConfigRepository {
- private static final Logger logger = LoggerFactory.getLogger(AbstractConfigRepository.class);
- private List m_listeners = Lists.newCopyOnWriteArrayList();
- protected PropertiesFactory propertiesFactory = ApolloInjector.getInstance(PropertiesFactory.class);
-
- protected boolean trySync() {
- try {
- sync();
- return true;
- } catch (Throwable ex) {
- Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
- logger
- .warn("Sync config failed, will retry. Repository {}, reason: {}", this.getClass(), ExceptionUtil
- .getDetailMessage(ex));
- }
- return false;
- }
-
- protected abstract void sync();
-
- @Override
- public void addChangeListener(RepositoryChangeListener listener) {
- if (!m_listeners.contains(listener)) {
- m_listeners.add(listener);
- }
- }
-
- @Override
- public void removeChangeListener(RepositoryChangeListener listener) {
- m_listeners.remove(listener);
- }
-
- protected void fireRepositoryChange(String namespace, Properties newProperties) {
- for (RepositoryChangeListener listener : m_listeners) {
- try {
- listener.onRepositoryChange(namespace, newProperties);
- } catch (Throwable ex) {
- Tracer.logError(ex);
- logger.error("Failed to invoke repository change listener {}", listener.getClass(), ex);
- }
- }
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java
deleted file mode 100644
index 0fedcbea8ce..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigManager.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.Config;
-import com.ctrip.framework.apollo.ConfigFile;
-import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public interface ConfigManager {
- /**
- * Get the config instance for the namespace specified.
- * @param namespace the namespace
- * @return the config instance for the namespace
- */
- Config getConfig(String namespace);
-
- /**
- * Get the config file instance for the namespace specified.
- * @param namespace the namespace
- * @param configFileFormat the config file format
- * @return the config file instance for the namespace
- */
- ConfigFile getConfigFile(String namespace, ConfigFileFormat configFileFormat);
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigRepository.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigRepository.java
deleted file mode 100644
index faf4b6103ec..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigRepository.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.enums.ConfigSourceType;
-import java.util.Properties;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public interface ConfigRepository {
- /**
- * Get the config from this repository.
- * @return config
- */
- Properties getConfig();
-
- /**
- * Set the fallback repo for this repository.
- * @param upstreamConfigRepository the upstream repo
- */
- void setUpstreamRepository(ConfigRepository upstreamConfigRepository);
-
- /**
- * Add change listener.
- * @param listener the listener to observe the changes
- */
- void addChangeListener(RepositoryChangeListener listener);
-
- /**
- * Remove change listener.
- * @param listener the listener to remove
- */
- void removeChangeListener(RepositoryChangeListener listener);
-
- /**
- * Return the config's source type, i.e. where is the config loaded from
- *
- * @return the config's source type
- */
- ConfigSourceType getSourceType();
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java
deleted file mode 100644
index e7cba404beb..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigServiceLocator.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.core.ApolloClientSystemConsts;
-import com.ctrip.framework.apollo.core.ServiceNameConsts;
-import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory;
-import com.ctrip.framework.apollo.core.utils.DeprecatedPropertyNotifyUtil;
-import com.ctrip.framework.foundation.Foundation;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.ctrip.framework.apollo.build.ApolloInjector;
-import com.ctrip.framework.apollo.core.dto.ServiceDTO;
-import com.ctrip.framework.apollo.core.utils.ApolloThreadFactory;
-import com.ctrip.framework.apollo.exceptions.ApolloConfigException;
-import com.ctrip.framework.apollo.tracer.Tracer;
-import com.ctrip.framework.apollo.tracer.spi.Transaction;
-import com.ctrip.framework.apollo.util.ConfigUtil;
-import com.ctrip.framework.apollo.util.ExceptionUtil;
-import com.ctrip.framework.apollo.util.http.HttpRequest;
-import com.ctrip.framework.apollo.util.http.HttpResponse;
-import com.ctrip.framework.apollo.util.http.HttpClient;
-import com.google.common.base.Joiner;
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.escape.Escaper;
-import com.google.common.net.UrlEscapers;
-import com.google.gson.reflect.TypeToken;
-
-public class ConfigServiceLocator {
- private static final Logger logger = DeferredLoggerFactory.getLogger(ConfigServiceLocator.class);
- private HttpClient m_httpClient;
- private ConfigUtil m_configUtil;
- private AtomicReference> m_configServices;
- private Type m_responseType;
- private ScheduledExecutorService m_executorService;
- private static final Joiner.MapJoiner MAP_JOINER = Joiner.on("&").withKeyValueSeparator("=");
- private static final Escaper queryParamEscaper = UrlEscapers.urlFormParameterEscaper();
-
- /**
- * Create a config service locator.
- */
- public ConfigServiceLocator() {
- List initial = Lists.newArrayList();
- m_configServices = new AtomicReference<>(initial);
- m_responseType = new TypeToken>() {
- }.getType();
- m_httpClient = ApolloInjector.getInstance(HttpClient.class);
- m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
- this.m_executorService = Executors.newScheduledThreadPool(1,
- ApolloThreadFactory.create("ConfigServiceLocator", true));
- initConfigServices();
- }
-
- private void initConfigServices() {
- // get from run time configurations
- List customizedConfigServices = getCustomizedConfigService();
-
- if (customizedConfigServices != null) {
- setConfigServices(customizedConfigServices);
- return;
- }
-
- // update from meta service
- this.tryUpdateConfigServices();
- this.schedulePeriodicRefresh();
- }
-
- private List getCustomizedConfigService() {
- // 1. Get from System Property
- String configServices = System.getProperty(ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE);
- if (Strings.isNullOrEmpty(configServices)) {
- // 2. Get from OS environment variable
- configServices = System.getenv(ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES);
- }
- if (Strings.isNullOrEmpty(configServices)) {
- // 3. Get from server.properties
- configServices = Foundation.server().getProperty(ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE, null);
- }
- if (Strings.isNullOrEmpty(configServices)) {
- // 4. Get from deprecated config
- configServices = getDeprecatedCustomizedConfigService();
- }
-
- if (Strings.isNullOrEmpty(configServices)) {
- return null;
- }
-
- logger.info("Located config services from apollo.config-service configuration: {}, will not refresh config services from remote meta service!", configServices);
-
- // mock service dto list
- String[] configServiceUrls = configServices.split(",");
- List serviceDTOS = Lists.newArrayList();
-
- for (String configServiceUrl : configServiceUrls) {
- configServiceUrl = configServiceUrl.trim();
- ServiceDTO serviceDTO = new ServiceDTO();
- serviceDTO.setHomepageUrl(configServiceUrl);
- serviceDTO.setAppName(ServiceNameConsts.APOLLO_CONFIGSERVICE);
- serviceDTO.setInstanceId(configServiceUrl);
- serviceDTOS.add(serviceDTO);
- }
-
- return serviceDTOS;
- }
-
- @SuppressWarnings("deprecation")
- private String getDeprecatedCustomizedConfigService() {
- // 1. Get from System Property
- String configServices = System.getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE);
- if (!Strings.isNullOrEmpty(configServices)) {
- DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE,
- ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE);
- }
- if (Strings.isNullOrEmpty(configServices)) {
- // 2. Get from OS environment variable
- configServices = System.getenv(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES);
- if (!Strings.isNullOrEmpty(configServices)) {
- DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES,
- ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE_ENVIRONMENT_VARIABLES);
- }
- }
- if (Strings.isNullOrEmpty(configServices)) {
- // 3. Get from server.properties
- configServices = Foundation.server().getProperty(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE, null);
- if (!Strings.isNullOrEmpty(configServices)) {
- DeprecatedPropertyNotifyUtil.warn(ApolloClientSystemConsts.DEPRECATED_APOLLO_CONFIG_SERVICE,
- ApolloClientSystemConsts.APOLLO_CONFIG_SERVICE);
- }
- }
- return configServices;
- }
-
- /**
- * Get the config service info from remote meta server.
- *
- * @return the services dto
- */
- public List getConfigServices() {
- if (m_configServices.get().isEmpty()) {
- updateConfigServices();
- }
-
- return m_configServices.get();
- }
-
- private boolean tryUpdateConfigServices() {
- try {
- updateConfigServices();
- return true;
- } catch (Throwable ex) {
- //ignore
- }
- return false;
- }
-
- private void schedulePeriodicRefresh() {
- this.m_executorService.scheduleAtFixedRate(
- new Runnable() {
- @Override
- public void run() {
- logger.debug("refresh config services");
- Tracer.logEvent("Apollo.MetaService", "periodicRefresh");
- tryUpdateConfigServices();
- }
- }, m_configUtil.getRefreshInterval(), m_configUtil.getRefreshInterval(),
- m_configUtil.getRefreshIntervalTimeUnit());
- }
-
- private synchronized void updateConfigServices() {
- String url = assembleMetaServiceUrl();
-
- HttpRequest request = new HttpRequest(url);
- int maxRetries = 2;
- Throwable exception = null;
-
- for (int i = 0; i < maxRetries; i++) {
- Transaction transaction = Tracer.newTransaction("Apollo.MetaService", "getConfigService");
- transaction.addData("Url", url);
- try {
- HttpResponse> response = m_httpClient.doGet(request, m_responseType);
- transaction.setStatus(Transaction.SUCCESS);
- List services = response.getBody();
- if (services == null || services.isEmpty()) {
- logConfigService("Empty response!");
- continue;
- }
- setConfigServices(services);
- return;
- } catch (Throwable ex) {
- Tracer.logEvent("ApolloConfigException", ExceptionUtil.getDetailMessage(ex));
- transaction.setStatus(ex);
- exception = ex;
- } finally {
- transaction.complete();
- }
-
- try {
- m_configUtil.getOnErrorRetryIntervalTimeUnit().sleep(m_configUtil.getOnErrorRetryInterval());
- } catch (InterruptedException ex) {
- //ignore
- }
- }
-
- throw new ApolloConfigException(
- String.format("Get config services failed from %s", url), exception);
- }
-
- private void setConfigServices(List services) {
- m_configServices.set(services);
- logConfigServices(services);
- }
-
- private String assembleMetaServiceUrl() {
- String domainName = m_configUtil.getMetaServerDomainName();
- String appId = m_configUtil.getAppId();
- String localIp = m_configUtil.getLocalIp();
-
- Map queryParams = Maps.newHashMap();
- queryParams.put("appId", queryParamEscaper.escape(appId));
- if (!Strings.isNullOrEmpty(localIp)) {
- queryParams.put("ip", queryParamEscaper.escape(localIp));
- }
-
- return domainName + "/services/config?" + MAP_JOINER.join(queryParams);
- }
-
- private void logConfigServices(List serviceDtos) {
- for (ServiceDTO serviceDto : serviceDtos) {
- logConfigService(serviceDto.getHomepageUrl());
- }
- }
-
- private void logConfigService(String serviceUrl) {
- Tracer.logEvent("Apollo.Config.Services", serviceUrl);
- }
-}
diff --git a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java b/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
deleted file mode 100644
index 7b17d75f0b2..00000000000
--- a/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright 2022 Apollo Authors
- *
- * Licensed 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 com.ctrip.framework.apollo.internals;
-
-import com.ctrip.framework.apollo.core.utils.DeferredLoggerFactory;
-import com.ctrip.framework.apollo.enums.ConfigSourceType;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.slf4j.Logger;
-
-import com.ctrip.framework.apollo.core.utils.ClassLoaderUtil;
-import com.ctrip.framework.apollo.enums.PropertyChangeType;
-import com.ctrip.framework.apollo.model.ConfigChange;
-import com.ctrip.framework.apollo.tracer.Tracer;
-import com.ctrip.framework.apollo.util.ExceptionUtil;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.RateLimiter;
-
-/**
- * @author Jason Song(song_s@ctrip.com)
- */
-public class DefaultConfig extends AbstractConfig implements RepositoryChangeListener {
-
- private static final Logger logger = DeferredLoggerFactory.getLogger(DefaultConfig.class);
- private final String m_namespace;
- private final Properties m_resourceProperties;
- private final AtomicReference m_configProperties;
- private final ConfigRepository m_configRepository;
- private final RateLimiter m_warnLogRateLimiter;
-
- private volatile ConfigSourceType m_sourceType = ConfigSourceType.NONE;
-
- /**
- * Constructor.
- *
- * @param namespace the namespace of this config instance
- * @param configRepository the config repository for this config instance
- */
- public DefaultConfig(String namespace, ConfigRepository configRepository) {
- m_namespace = namespace;
- m_resourceProperties = loadFromResource(m_namespace);
- m_configRepository = configRepository;
- m_configProperties = new AtomicReference<>();
- m_warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute
- initialize();
- }
-
- private void initialize() {
- try {
- updateConfig(m_configRepository.getConfig(), m_configRepository.getSourceType());
- } catch (Throwable ex) {
- Tracer.logError(ex);
- logger.warn("Init Apollo Local Config failed - namespace: {}, reason: {}.",
- m_namespace, ExceptionUtil.getDetailMessage(ex));
- } finally {
- //register the change listener no matter config repository is working or not
- //so that whenever config repository is recovered, config could get changed
- m_configRepository.addChangeListener(this);
- }
- }
-
- /**
- * get property from cached repository properties file
- *
- * @param key property key
- * @return value
- */
- protected String getPropertyFromRepository(String key) {
- Properties properties = m_configProperties.get();
- if (properties != null) {
- return properties.getProperty(key);
- }
- return null;
- }
-
- /**
- * get property from additional properties file on classpath
- *
- * @param key property key
- * @return value
- */
- protected String getPropertyFromAdditional(String key) {
- Properties properties = this.m_resourceProperties;
- if (properties != null) {
- return properties.getProperty(key);
- }
- return null;
- }
-
- /**
- * try to print a warn log when can not find a property
- *
- * @param value value
- */
- protected void tryWarnLog(String value) {
- if (value == null && m_configProperties.get() == null && m_warnLogRateLimiter.tryAcquire()) {
- logger.warn(
- "Could not load config for namespace {} from Apollo, please check whether the configs are released in Apollo! Return default value now!",
- m_namespace);
- }
- }
-
- /**
- * get property names from cached repository properties file
- *
- * @return property names
- */
- protected Set getPropertyNamesFromRepository() {
- Properties properties = m_configProperties.get();
- if (properties == null) {
- return Collections.emptySet();
- }
- return this.stringPropertyNames(properties);
- }
-
- /**
- * get property names from additional properties file on classpath
- *
- * @return property names
- */
- protected Set getPropertyNamesFromAdditional() {
- Properties properties = m_resourceProperties;
- if (properties == null) {
- return Collections.emptySet();
- }
- return this.stringPropertyNames(properties);
- }
-
- @Override
- public String getProperty(String key, String defaultValue) {
- // step 1: check system properties, i.e. -Dkey=value
- String value = System.getProperty(key);
-
- // step 2: check local cached properties file
- if (value == null) {
- value = this.getPropertyFromRepository(key);
- }
-
- /*
- * step 3: check env variable, i.e. PATH=...
- * normally system environment variables are in UPPERCASE, however there might be exceptions.
- * so the caller should provide the key in the right case
- */
- if (value == null) {
- value = System.getenv(key);
- }
-
- // step 4: check properties file from classpath
- if (value == null) {
- value = this.getPropertyFromAdditional(key);
- }
-
- this.tryWarnLog(value);
-
- return value == null ? defaultValue : value;
- }
-
- @Override
- public Set getPropertyNames() {
- // propertyNames include system property and system env might cause some compatibility issues, though that looks like the correct implementation.
- Set fromRepository = this.getPropertyNamesFromRepository();
- Set fromAdditional = this.getPropertyNamesFromAdditional();
- if (fromRepository == null || fromRepository.isEmpty()) {
- return fromAdditional;
- }
- if (fromAdditional == null || fromAdditional.isEmpty()) {
- return fromRepository;
- }
- Set propertyNames = Sets
- .newLinkedHashSetWithExpectedSize(fromRepository.size() + fromAdditional.size());
- propertyNames.addAll(fromRepository);
- propertyNames.addAll(fromAdditional);
- return propertyNames;
- }
-
- @Override
- public ConfigSourceType getSourceType() {
- return m_sourceType;
- }
-
- private Set stringPropertyNames(Properties properties) {
- //jdk9以下版本Properties#enumerateStringProperties方法存在性能问题,keys() + get(k) 重复迭代, jdk9之后改为entrySet遍历.
- Map h = Maps.newLinkedHashMapWithExpectedSize(properties.size());
- for (Map.Entry