This is an automated email from the ASF dual-hosted git repository.
hefengen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 5681017336 [type:refactor] refactor admin-listener. (#5294)
5681017336 is described below
commit 568101733626cc916b9af0f86ef27357920e6c69
Author: yunlongn <[email protected]>
AuthorDate: Mon Nov 13 20:39:42 2023 +0800
[type:refactor] refactor admin-listener. (#5294)
* [type:refactor] refactor admin-listener.
* [type:refactor] refactor admin-listener.
* [type:refactor] refactor admin-listener.
* [type:refactor] refactor admin-listener.
---------
Co-authored-by: yunlongn <[email protected]>
---
pom.xml | 1 +
shenyu-admin-listener/pom.xml | 41 ++
.../shenyu-admin-listener-api/pom.xml | 43 ++
.../admin/listener/AbstractDataChangedInit.java | 0
.../listener/AbstractNodeDataChangedListener.java | 0
.../listener/AbstractPathDataChangedListener.java | 0
.../shenyu/admin/listener/DataChangedInit.java | 0
.../shenyu/admin/listener/DataChangedListener.java | 0
.../shenyu/admin/service/SyncDataService.java | 0
.../shenyu-admin-listener-apollo/pom.xml | 49 +++
.../admin/config/ApolloSyncConfiguration.java | 76 ++++
.../admin/config/properties/ApolloProperties.java | 0
.../shenyu/admin/listener/apollo/ApolloClient.java | 4 +-
.../listener/apollo/ApolloDataChangedInit.java | 0
.../listener/apollo/ApolloDataChangedListener.java | 0
.../src/main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
.../shenyu-admin-listener-consul/pom.xml | 50 +++
.../admin/config/ConsulSyncConfiguration.java | 88 ++++
.../admin/config/properties/ConsulProperties.java | 0
.../listener/consul/ConsulDataChangedInit.java | 0
.../listener/consul/ConsulDataChangedListener.java | 0
.../src/main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
.../shenyu-admin-listener-etcd/pom.xml | 57 +++
.../shenyu/admin/config/EtcdSyncConfiguration.java | 78 ++++
.../admin/config/properties/EtcdProperties.java | 0
.../shenyu/admin/listener/etcd/EtcdClient.java | 0
.../admin/listener/etcd/EtcdDataChangedInit.java | 0
.../listener/etcd/EtcdDataDataChangedListener.java | 0
.../src/main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
.../shenyu-admin-listener-nacos/pom.xml | 51 +++
.../admin/config/NacosSyncConfiguration.java | 102 +++++
.../admin/config/properties/NacosProperties.java | 0
.../admin/listener/nacos/NacosDataChangedInit.java | 0
.../listener/nacos/NacosDataChangedListener.java | 0
.../src/main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
.../shenyu-admin-listener-polaris/pom.xml | 55 +++
.../admin/config/PolarisSyncConfiguration.java | 101 +++++
.../admin/config/properties/PolarisProperties.java | 0
.../listener/polaris/PolarisDataChangedInit.java | 0
.../polaris/PolarisDataChangedListener.java | 0
.../src/main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
.../shenyu-admin-listener-zookeeper/pom.xml | 52 +++
.../admin/config/ZookeeperSyncConfiguration.java | 85 ++++
.../config/properties/ZookeeperProperties.java | 0
.../zookeeper/ZookeeperDataChangedInit.java | 0
.../zookeeper/ZookeeperDataChangedListener.java | 0
.../src/main/resources/META-INF/spring.factories | 19 +
.../src/main/resources/META-INF/spring.provides | 18 +
shenyu-admin/pom.xml | 67 +--
.../shenyu/admin/config/DataSyncConfiguration.java | 468 ---------------------
.../config/HttpLongPollingSyncConfiguration.java | 60 +++
.../admin/config/WebSocketSyncConfiguration.java | 71 ++++
.../http/HttpLongPollingDataChangedListener.java | 8 +-
.../listener/zookeeper/HttpServiceDiscovery.java | 182 --------
.../admin/config/DataSyncConfigurationTest.java | 36 +-
60 files changed, 1347 insertions(+), 700 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1ab1375aa4..cc35610651 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,6 +29,7 @@
<name>shenyu</name>
<modules>
<module>shenyu-admin</module>
+ <module>shenyu-admin-listener</module>
<module>shenyu-common</module>
<module>shenyu-web</module>
<module>shenyu-spring-boot-starter</module>
diff --git a/shenyu-admin-listener/pom.xml b/shenyu-admin-listener/pom.xml
new file mode 100644
index 0000000000..ad74b24458
--- /dev/null
+++ b/shenyu-admin-listener/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>shenyu-admin-listener-api</module>
+ <module>shenyu-admin-listener-apollo</module>
+ <module>shenyu-admin-listener-consul</module>
+ <module>shenyu-admin-listener-etcd</module>
+ <module>shenyu-admin-listener-nacos</module>
+ <module>shenyu-admin-listener-polaris</module>
+ <module>shenyu-admin-listener-zookeeper</module>
+ </modules>
+</project>
\ No newline at end of file
diff --git a/shenyu-admin-listener/shenyu-admin-listener-api/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-api/pom.xml
new file mode 100644
index 0000000000..5408b11b99
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-api/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-api</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractNodeDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractNodeDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractNodeDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractNodeDataChangedListener.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractPathDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractPathDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/AbstractPathDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/AbstractPathDataChangedListener.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/DataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/DataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/DataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/DataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/DataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/DataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/DataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/listener/DataChangedListener.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SyncDataService.java
b/shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/service/SyncDataService.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/service/SyncDataService.java
rename to
shenyu-admin-listener/shenyu-admin-listener-api/src/main/java/org/apache/shenyu/admin/service/SyncDataService.java
diff --git a/shenyu-admin-listener/shenyu-admin-listener-apollo/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-apollo/pom.xml
new file mode 100644
index 0000000000..1c5e2dc10a
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-apollo/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-apollo</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.ctrip.framework.apollo</groupId>
+ <artifactId>apollo-openapi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/config/ApolloSyncConfiguration.java
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/config/ApolloSyncConfiguration.java
new file mode 100644
index 0000000000..755c794394
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/config/ApolloSyncConfiguration.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import org.apache.shenyu.admin.config.properties.ApolloProperties;
+import org.apache.shenyu.admin.listener.DataChangedInit;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.apollo.ApolloClient;
+import org.apache.shenyu.admin.listener.apollo.ApolloDataChangedInit;
+import org.apache.shenyu.admin.listener.apollo.ApolloDataChangedListener;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * the type apollo listener.
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "shenyu.sync.apollo", name = "meta")
+@EnableConfigurationProperties(ApolloProperties.class)
+public class ApolloSyncConfiguration {
+
+
+ /**
+ * init Consul client.
+ *
+ * @param apolloProperties the apollo properties
+ * @return apollo client
+ */
+ @Bean
+ public ApolloClient apolloClient(final ApolloProperties apolloProperties) {
+ return new ApolloClient(apolloProperties);
+ }
+
+ /**
+ * Config event listener data changed listener.
+ *
+ * @param apolloClient the apollo client
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(ApolloDataChangedListener.class)
+ public DataChangedListener apolloDataChangeListener(final ApolloClient
apolloClient) {
+ return new ApolloDataChangedListener(apolloClient);
+ }
+
+ /**
+ * apollo data init.
+ *
+ * @param apolloClient the apollo client
+ * @return the apollo data init
+ */
+ @Bean
+ @ConditionalOnMissingBean(ApolloDataChangedInit.class)
+ public DataChangedInit apolloDataChangeInit(final ApolloClient
apolloClient) {
+ return new ApolloDataChangedInit(apolloClient);
+ }
+
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/ApolloProperties.java
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/config/properties/ApolloProperties.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/ApolloProperties.java
rename to
shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/config/properties/ApolloProperties.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloClient.java
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloClient.java
similarity index 97%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloClient.java
rename to
shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloClient.java
index 44c21e005d..8c907f1c43 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloClient.java
+++
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloClient.java
@@ -21,7 +21,7 @@ import
com.ctrip.framework.apollo.openapi.client.ApolloOpenApiClient;
import com.ctrip.framework.apollo.openapi.dto.NamespaceReleaseDTO;
import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
import org.apache.shenyu.admin.config.properties.ApolloProperties;
-import org.apache.shenyu.admin.exception.ShenyuAdminException;
+import org.apache.shenyu.common.exception.ShenyuException;
import org.apache.shenyu.common.utils.GsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,7 +70,7 @@ public class ApolloClient {
}
if (openItemDTO.getKey().equals("timeout")) {
LOG.error("apollo client getItemValue time out");
- throw new ShenyuAdminException("apollo client getItemValue time
out");
+ throw new ShenyuException("apollo client getItemValue time out");
}
return openItemDTO.getValue();
}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/java/org/apache/shenyu/admin/listener/apollo/ApolloDataChangedListener.java
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/resources/META-INF/spring.factories
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000..f210012816
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.admin.config.ApolloSyncConfiguration
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/resources/META-INF/spring.provides
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..9893ff1dba
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-apollo/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: shenyu-admin-listener-apollo
diff --git a/shenyu-admin-listener/shenyu-admin-listener-consul/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-consul/pom.xml
new file mode 100644
index 0000000000..58fe3fb8f1
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-consul/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-consul</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.ecwid.consul</groupId>
+ <artifactId>consul-api</artifactId>
+ <version>${consul.api.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/ConsulSyncConfiguration.java
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/ConsulSyncConfiguration.java
new file mode 100644
index 0000000000..4b2b7237c9
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/ConsulSyncConfiguration.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import com.ecwid.consul.v1.ConsulClient;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.config.properties.ConsulProperties;
+import org.apache.shenyu.admin.listener.DataChangedInit;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.consul.ConsulDataChangedInit;
+import org.apache.shenyu.admin.listener.consul.ConsulDataChangedListener;
+import org.apache.shenyu.common.exception.ShenyuException;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * The type Consul listener.
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "shenyu.sync.consul", name = "url")
+@EnableConfigurationProperties(ConsulProperties.class)
+public class ConsulSyncConfiguration {
+
+ /**
+ * init Consul client.
+ *
+ * @param consulProperties the consul properties
+ * @return Consul client
+ */
+ @Bean
+ public ConsulClient consulClient(final ConsulProperties consulProperties) {
+ String url = consulProperties.getUrl();
+ if (StringUtils.isBlank(url)) {
+ throw new ShenyuException("sync.consul.url can not be null.");
+ }
+ try {
+ URL consulUrl = new URL(url);
+ return consulUrl.getPort() < 0 ? new
ConsulClient(consulUrl.getHost()) : new ConsulClient(consulUrl.getHost(),
consulUrl.getPort());
+ } catch (MalformedURLException e) {
+ throw new ShenyuException("sync.consul.url formatter is not
incorrect.");
+ }
+ }
+
+ /**
+ * Config event listener data changed listener.
+ *
+ * @param consulClient the consul client
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(ConsulDataChangedListener.class)
+ public DataChangedListener consulDataChangedListener(final ConsulClient
consulClient) {
+ return new ConsulDataChangedListener(consulClient);
+ }
+
+ /**
+ * Consul data init.
+ *
+ * @param consulClient the consul client
+ * @return the consul data init
+ */
+ @Bean
+ @ConditionalOnMissingBean(ConsulDataChangedInit.class)
+ public DataChangedInit consulDataChangedInit(final ConsulClient
consulClient) {
+ return new ConsulDataChangedInit(consulClient);
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/ConsulProperties.java
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/properties/ConsulProperties.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/ConsulProperties.java
rename to
shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/config/properties/ConsulProperties.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-consul/src/main/java/org/apache/shenyu/admin/listener/consul/ConsulDataChangedListener.java
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/resources/META-INF/spring.factories
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000..6469adb33d
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.admin.config.ConsulSyncConfiguration
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/resources/META-INF/spring.provides
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..c8415086a9
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-consul/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: shenyu-admin-listener-consul
diff --git a/shenyu-admin-listener/shenyu-admin-listener-etcd/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-etcd/pom.xml
new file mode 100644
index 0000000000..4b492366f7
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-etcd/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-etcd</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>io.etcd</groupId>
+ <artifactId>jetcd-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/config/EtcdSyncConfiguration.java
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/config/EtcdSyncConfiguration.java
new file mode 100644
index 0000000000..81b10f0727
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/config/EtcdSyncConfiguration.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import io.etcd.jetcd.Client;
+import org.apache.shenyu.admin.config.properties.EtcdProperties;
+import org.apache.shenyu.admin.listener.DataChangedInit;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.etcd.EtcdClient;
+import org.apache.shenyu.admin.listener.etcd.EtcdDataChangedInit;
+import org.apache.shenyu.admin.listener.etcd.EtcdDataDataChangedListener;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * The type Etcd listener.
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "shenyu.sync.etcd", name = "url")
+@EnableConfigurationProperties(EtcdProperties.class)
+public class EtcdSyncConfiguration {
+
+ /**
+ * Init etcd client.
+ *
+ * @param etcdProperties etcd properties
+ * @return Etcd Client
+ */
+ @Bean
+ public EtcdClient etcdClient(final EtcdProperties etcdProperties) {
+ Client client = Client.builder()
+ .endpoints(etcdProperties.getUrl().split(","))
+ .build();
+ return new EtcdClient(client);
+ }
+
+ /**
+ * Config event listener data changed listener.
+ *
+ * @param etcdClient the etcd client
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(EtcdDataDataChangedListener.class)
+ public DataChangedListener etcdDataChangedListener(final EtcdClient
etcdClient) {
+ return new EtcdDataDataChangedListener(etcdClient);
+ }
+
+ /**
+ * data init.
+ *
+ * @param etcdClient the etcd client
+ * @return the etcd data init
+ */
+ @Bean
+ @ConditionalOnMissingBean(EtcdDataChangedInit.class)
+ public DataChangedInit etcdDataChangedInit(final EtcdClient etcdClient) {
+ return new EtcdDataChangedInit(etcdClient);
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/EtcdProperties.java
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/config/properties/EtcdProperties.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/EtcdProperties.java
rename to
shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/config/properties/EtcdProperties.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdClient.java
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdClient.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdClient.java
rename to
shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdClient.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/java/org/apache/shenyu/admin/listener/etcd/EtcdDataDataChangedListener.java
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/resources/META-INF/spring.factories
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000..8b477f3691
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.admin.config.EtcdSyncConfiguration
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/resources/META-INF/spring.provides
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..55e4b72de7
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-etcd/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: shenyu-admin-listener-nacos
diff --git a/shenyu-admin-listener/shenyu-admin-listener-nacos/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-nacos/pom.xml
new file mode 100644
index 0000000000..7d3e0523b7
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-nacos/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-nacos</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-discovery-nacos</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/config/NacosSyncConfiguration.java
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/config/NacosSyncConfiguration.java
new file mode 100644
index 0000000000..d4ccbd970b
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/config/NacosSyncConfiguration.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import com.alibaba.nacos.api.NacosFactory;
+import com.alibaba.nacos.api.PropertyKeyConst;
+import com.alibaba.nacos.api.config.ConfigService;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.shenyu.admin.config.properties.NacosProperties;
+import org.apache.shenyu.admin.listener.DataChangedInit;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.nacos.NacosDataChangedInit;
+import org.apache.shenyu.admin.listener.nacos.NacosDataChangedListener;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Objects;
+import java.util.Properties;
+
+/**
+ * The type Nacos listener.
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "shenyu.sync.nacos", name = "url")
+@EnableConfigurationProperties(NacosProperties.class)
+public class NacosSyncConfiguration {
+
+ /**
+ * register configService in spring ioc.
+ *
+ * @param nacosProp the nacos configuration
+ * @return ConfigService {@linkplain ConfigService}
+ * @throws Exception the exception
+ */
+ @Bean
+ @ConditionalOnMissingBean(ConfigService.class)
+ public ConfigService nacosConfigService(final NacosProperties nacosProp)
throws Exception {
+ Properties properties = new Properties();
+ if (Objects.nonNull(nacosProp.getAcm()) &&
nacosProp.getAcm().isEnabled()) {
+ // Use aliyun ACM service
+ properties.put(PropertyKeyConst.ENDPOINT,
nacosProp.getAcm().getEndpoint());
+ properties.put(PropertyKeyConst.NAMESPACE,
nacosProp.getAcm().getNamespace());
+ // Use subaccount ACM administrative authority
+ properties.put(PropertyKeyConst.ACCESS_KEY,
nacosProp.getAcm().getAccessKey());
+ properties.put(PropertyKeyConst.SECRET_KEY,
nacosProp.getAcm().getSecretKey());
+ } else {
+ properties.put(PropertyKeyConst.SERVER_ADDR, nacosProp.getUrl());
+ if (StringUtils.isNotBlank(nacosProp.getNamespace())) {
+ properties.put(PropertyKeyConst.NAMESPACE,
nacosProp.getNamespace());
+ }
+ if (StringUtils.isNotBlank(nacosProp.getUsername())) {
+ properties.put(PropertyKeyConst.USERNAME,
nacosProp.getUsername());
+ }
+ if (StringUtils.isNotBlank(nacosProp.getPassword())) {
+ properties.put(PropertyKeyConst.PASSWORD,
nacosProp.getPassword());
+ }
+ }
+ return NacosFactory.createConfigService(properties);
+ }
+
+ /**
+ * Data changed listener data changed listener.
+ *
+ * @param configService the config service
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(NacosDataChangedListener.class)
+ public DataChangedListener nacosDataChangedListener(final ConfigService
configService) {
+ return new NacosDataChangedListener(configService);
+ }
+
+ /**
+ * Nacos data init nacos data init.
+ *
+ * @param configService the config service
+ * @return the nacos data init
+ */
+ @Bean
+ @ConditionalOnMissingBean(NacosDataChangedInit.class)
+ public DataChangedInit nacosDataChangedInit(final ConfigService
configService) {
+ return new NacosDataChangedInit(configService);
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/NacosProperties.java
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/config/properties/NacosProperties.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/NacosProperties.java
rename to
shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/config/properties/NacosProperties.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/java/org/apache/shenyu/admin/listener/nacos/NacosDataChangedListener.java
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/resources/META-INF/spring.factories
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000..45d39b552e
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.admin.config.NacosSyncConfiguration
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/resources/META-INF/spring.provides
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..55e4b72de7
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-nacos/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: shenyu-admin-listener-nacos
diff --git a/shenyu-admin-listener/shenyu-admin-listener-polaris/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-polaris/pom.xml
new file mode 100644
index 0000000000..1d2e2be6bf
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-polaris/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-polaris</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.tencent.polaris</groupId>
+ <artifactId>polaris-all</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-discovery-nacos</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/config/PolarisSyncConfiguration.java
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/config/PolarisSyncConfiguration.java
new file mode 100644
index 0000000000..4d97d024ef
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/config/PolarisSyncConfiguration.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import com.tencent.polaris.configuration.api.core.ConfigFilePublishService;
+import com.tencent.polaris.configuration.api.core.ConfigFileService;
+import com.tencent.polaris.configuration.factory.ConfigFileServiceFactory;
+import
com.tencent.polaris.configuration.factory.ConfigFileServicePublishFactory;
+import com.tencent.polaris.factory.ConfigAPIFactory;
+import org.apache.shenyu.admin.config.properties.PolarisProperties;
+import org.apache.shenyu.admin.listener.DataChangedInit;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.polaris.PolarisDataChangedInit;
+import org.apache.shenyu.admin.listener.polaris.PolarisDataChangedListener;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Collections;
+
+/**
+ * The type Polaris listener.
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "shenyu.sync.polaris", name = "url")
+@EnableConfigurationProperties(PolarisProperties.class)
+public class PolarisSyncConfiguration {
+
+ /**
+ * register configFileService in spring ioc.
+ *
+ * @param polarisProperties polarisProperties
+ * @return ConfigFileService {@linkplain ConfigFileService}
+ */
+ @Bean
+ @ConditionalOnMissingBean(ConfigFileService.class)
+ public ConfigFileService polarisConfigFileService(final PolarisProperties
polarisProperties) {
+ com.tencent.polaris.api.config.Configuration configuration =
ConfigAPIFactory.defaultConfig();
+
configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl()));
+ return ConfigFileServiceFactory.createConfigFileService(configuration);
+ }
+
+ /**
+ * register configFilePublishService in spring ioc.
+ *
+ * @param polarisProperties polarisProperties
+ * @return ConfigFilePublishService {@linkplain ConfigFilePublishService}
+ */
+ @Bean
+ @ConditionalOnMissingBean(ConfigFilePublishService.class)
+ public ConfigFilePublishService polarisConfigFilePublishService(final
PolarisProperties polarisProperties) {
+ com.tencent.polaris.api.config.Configuration configuration =
ConfigAPIFactory.defaultConfig();
+
configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl()));
+ return
ConfigFileServicePublishFactory.createConfigFilePublishService(configuration);
+ }
+
+ /**
+ * Data changed listener data changed listener.
+ *
+ * @param polarisProperties polarisProperties
+ * @param configFilePublishService configFilePublishService
+ * @param configFileService the config service
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(PolarisDataChangedListener.class)
+ public DataChangedListener polarisDataChangedListener(final
PolarisProperties polarisProperties, final ConfigFileService configFileService,
+ final
ConfigFilePublishService configFilePublishService) {
+ return new PolarisDataChangedListener(polarisProperties,
configFileService, configFilePublishService);
+ }
+
+ /**
+ * Polaris data init polaris data init.
+ *
+ * @param polarisProperties polarisProperties
+ * @param configFileService the config service
+ * @return the polaris data init
+ */
+ @Bean
+ @ConditionalOnMissingBean(PolarisDataChangedInit.class)
+ public DataChangedInit polarisDataChangedInit(final PolarisProperties
polarisProperties, final ConfigFileService configFileService) {
+ return new PolarisDataChangedInit(polarisProperties,
configFileService);
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/PolarisProperties.java
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/config/properties/PolarisProperties.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/PolarisProperties.java
rename to
shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/config/properties/PolarisProperties.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/java/org/apache/shenyu/admin/listener/polaris/PolarisDataChangedListener.java
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/resources/META-INF/spring.factories
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000..2e71695169
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.admin.config.PolarisSyncConfiguration
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/resources/META-INF/spring.provides
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..9893ff1dba
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-polaris/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: shenyu-admin-listener-apollo
diff --git a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/pom.xml
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/pom.xml
new file mode 100644
index 0000000000..3aafdcb924
--- /dev/null
+++ b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener</artifactId>
+ <version>2.6.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>shenyu-admin-listener-zookeeper</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-register-client-server-zookeeper</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/config/ZookeeperSyncConfiguration.java
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/config/ZookeeperSyncConfiguration.java
new file mode 100644
index 0000000000..739b7da371
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/config/ZookeeperSyncConfiguration.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import org.apache.shenyu.admin.config.properties.ZookeeperProperties;
+import org.apache.shenyu.admin.listener.DataChangedInit;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.zookeeper.ZookeeperDataChangedInit;
+import org.apache.shenyu.admin.listener.zookeeper.ZookeeperDataChangedListener;
+import org.apache.shenyu.register.client.server.zookeeper.ZookeeperClient;
+import org.apache.shenyu.register.client.server.zookeeper.ZookeeperConfig;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Objects;
+
+/**
+ * The type Zookeeper listener.
+ */
+@Configuration
+@ConditionalOnProperty(prefix = "shenyu.sync.zookeeper", name = "url")
+@EnableConfigurationProperties(ZookeeperProperties.class)
+public class ZookeeperSyncConfiguration {
+
+ /**
+ * register ZookeeperClient in spring ioc.
+ *
+ * @param zookeeperProp the zookeeper configuration
+ * @return ZookeeperClient {@linkplain ZookeeperClient}
+ */
+ @Bean
+ @ConditionalOnMissingBean(ZookeeperClient.class)
+ public ZookeeperClient zookeeperClient(final ZookeeperProperties
zookeeperProp) {
+ int sessionTimeout = Objects.isNull(zookeeperProp.getSessionTimeout())
? 3000 : zookeeperProp.getSessionTimeout();
+ int connectionTimeout =
Objects.isNull(zookeeperProp.getConnectionTimeout()) ? 3000 :
zookeeperProp.getConnectionTimeout();
+ ZookeeperConfig zkConfig = new ZookeeperConfig(zookeeperProp.getUrl());
+ zkConfig.setSessionTimeoutMilliseconds(sessionTimeout)
+ .setConnectionTimeoutMilliseconds(connectionTimeout);
+ ZookeeperClient client = new ZookeeperClient(zkConfig);
+ client.start();
+ return client;
+ }
+
+ /**
+ * Config event listener data changed listener.
+ *
+ * @param zkClient the zk client
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(ZookeeperDataChangedListener.class)
+ public DataChangedListener zookeeperDataChangedListener(final
ZookeeperClient zkClient) {
+ return new ZookeeperDataChangedListener(zkClient);
+ }
+
+ /**
+ * Zookeeper data init zookeeper data init.
+ *
+ * @param zkClient the zk client
+ * @return the zookeeper data init
+ */
+ @Bean
+ @ConditionalOnMissingBean(ZookeeperDataChangedInit.class)
+ public DataChangedInit zookeeperDataChangedInit(final ZookeeperClient
zkClient) {
+ return new ZookeeperDataChangedInit(zkClient);
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/ZookeeperProperties.java
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/config/properties/ZookeeperProperties.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/config/properties/ZookeeperProperties.java
rename to
shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/config/properties/ZookeeperProperties.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedInit.java
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedInit.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedInit.java
rename to
shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedInit.java
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedListener.java
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedListener.java
similarity index 100%
rename from
shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedListener.java
rename to
shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/java/org/apache/shenyu/admin/listener/zookeeper/ZookeeperDataChangedListener.java
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/resources/META-INF/spring.factories
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000000..1d04f3e2b3
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+org.apache.shenyu.admin.config.ZookeeperSyncConfiguration
diff --git
a/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/resources/META-INF/spring.provides
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/resources/META-INF/spring.provides
new file mode 100644
index 0000000000..0793b7bffb
--- /dev/null
+++
b/shenyu-admin-listener/shenyu-admin-listener-zookeeper/src/main/resources/META-INF/spring.provides
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+provides: shenyu-admin-listener-zookeeper
diff --git a/shenyu-admin/pom.xml b/shenyu-admin/pom.xml
index 2d64565c7e..814cd8a70f 100644
--- a/shenyu-admin/pom.xml
+++ b/shenyu-admin/pom.xml
@@ -28,7 +28,6 @@
<properties>
<commons-io.version>2.11.0</commons-io.version>
<orai18n.version>19.7.0.0</orai18n.version>
- <polaris-all.version>1.13.0</polaris-all.version>
</properties>
<dependencies>
@@ -174,28 +173,6 @@
<artifactId>pagehelper</artifactId>
</dependency>
- <dependency>
- <groupId>com.tencent.polaris</groupId>
- <artifactId>polaris-all</artifactId>
- <version>${polaris-all.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.etcd</groupId>
- <artifactId>jetcd-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.ctrip.framework.apollo</groupId>
- <artifactId>apollo-openapi</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.ecwid.consul</groupId>
- <artifactId>consul-api</artifactId>
- <version>${consul.api.version}</version>
- </dependency>
-
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-ldap</artifactId>
@@ -303,6 +280,12 @@
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-discovery-etcd</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-discovery-zookeeper</artifactId>
@@ -311,7 +294,7 @@
<dependency>
<groupId>org.apache.shenyu</groupId>
- <artifactId>shenyu-discovery-etcd</artifactId>
+ <artifactId>shenyu-discovery-nacos</artifactId>
<version>${project.version}</version>
</dependency>
@@ -327,11 +310,45 @@
<version>${project.version}</version>
</dependency>
+ <!-- shenyu-admin-listener start-->
+
<dependency>
<groupId>org.apache.shenyu</groupId>
- <artifactId>shenyu-discovery-nacos</artifactId>
+ <artifactId>shenyu-admin-listener-apollo</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-consul</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-etcd</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-nacos</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-polaris</artifactId>
<version>${project.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.shenyu</groupId>
+ <artifactId>shenyu-admin-listener-zookeeper</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <!-- shenyu-admin-listener end-->
+
</dependencies>
<profiles>
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
deleted file mode 100644
index a0af3a3139..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/DataSyncConfiguration.java
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.config;
-
-import com.alibaba.nacos.api.NacosFactory;
-import com.alibaba.nacos.api.PropertyKeyConst;
-import com.alibaba.nacos.api.config.ConfigService;
-import com.ecwid.consul.v1.ConsulClient;
-import com.tencent.polaris.configuration.api.core.ConfigFilePublishService;
-import com.tencent.polaris.configuration.api.core.ConfigFileService;
-import com.tencent.polaris.configuration.factory.ConfigFileServiceFactory;
-import
com.tencent.polaris.configuration.factory.ConfigFileServicePublishFactory;
-import com.tencent.polaris.factory.ConfigAPIFactory;
-import io.etcd.jetcd.Client;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.shenyu.admin.config.properties.ConsulProperties;
-import org.apache.shenyu.admin.config.properties.EtcdProperties;
-import org.apache.shenyu.admin.config.properties.HttpSyncProperties;
-import org.apache.shenyu.admin.config.properties.NacosProperties;
-import org.apache.shenyu.admin.config.properties.PolarisProperties;
-import org.apache.shenyu.admin.config.properties.WebsocketSyncProperties;
-import org.apache.shenyu.admin.config.properties.ZookeeperProperties;
-import org.apache.shenyu.admin.config.properties.ApolloProperties;
-import org.apache.shenyu.admin.controller.ConfigController;
-import org.apache.shenyu.admin.listener.DataChangedInit;
-import org.apache.shenyu.admin.listener.DataChangedListener;
-import org.apache.shenyu.admin.listener.apollo.ApolloClient;
-import org.apache.shenyu.admin.listener.apollo.ApolloDataChangedInit;
-import org.apache.shenyu.admin.listener.apollo.ApolloDataChangedListener;
-import org.apache.shenyu.admin.listener.consul.ConsulDataChangedInit;
-import org.apache.shenyu.admin.listener.consul.ConsulDataChangedListener;
-import org.apache.shenyu.admin.listener.etcd.EtcdClient;
-import org.apache.shenyu.admin.listener.etcd.EtcdDataChangedInit;
-import org.apache.shenyu.admin.listener.etcd.EtcdDataDataChangedListener;
-import
org.apache.shenyu.admin.listener.http.HttpLongPollingDataChangedListener;
-import org.apache.shenyu.admin.listener.nacos.NacosDataChangedInit;
-import org.apache.shenyu.admin.listener.nacos.NacosDataChangedListener;
-import org.apache.shenyu.admin.listener.polaris.PolarisDataChangedInit;
-import org.apache.shenyu.admin.listener.polaris.PolarisDataChangedListener;
-import org.apache.shenyu.admin.listener.websocket.WebsocketCollector;
-import org.apache.shenyu.admin.listener.websocket.WebsocketDataChangedListener;
-import org.apache.shenyu.admin.listener.zookeeper.ZookeeperDataChangedInit;
-import org.apache.shenyu.admin.listener.zookeeper.ZookeeperDataChangedListener;
-import org.apache.shenyu.common.exception.ShenyuException;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperClient;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperConfig;
-import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import
org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.socket.server.standard.ServerEndpointExporter;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Properties;
-
-/**
- * The type Data sync configuration.
- */
-@Configuration
-public class DataSyncConfiguration {
-
- /**
- * http long polling.
- */
- @Configuration
- @ConditionalOnProperty(name = "shenyu.sync.http.enabled", havingValue =
"true")
- @EnableConfigurationProperties(HttpSyncProperties.class)
- static class HttpLongPollingListener {
-
- @Bean
- @ConditionalOnMissingBean(HttpLongPollingDataChangedListener.class)
- public HttpLongPollingDataChangedListener
httpLongPollingDataChangedListener(final HttpSyncProperties httpSyncProperties)
{
- return new HttpLongPollingDataChangedListener(httpSyncProperties);
- }
-
- @Bean
- @ConditionalOnMissingBean(ConfigController.class)
- public ConfigController configController(final
HttpLongPollingDataChangedListener httpLongPollingDataChangedListener) {
- return new ConfigController(httpLongPollingDataChangedListener);
- }
- }
-
- /**
- * The type Zookeeper listener.
- */
- @Configuration
- @ConditionalOnProperty(prefix = "shenyu.sync.zookeeper", name = "url")
- @EnableConfigurationProperties(ZookeeperProperties.class)
- static class ZookeeperListener {
-
- /**
- * register ZookeeperClient in spring ioc.
- *
- * @param zookeeperProp the zookeeper configuration
- * @return ZookeeperClient {@linkplain ZookeeperClient}
- */
- @Bean
- @ConditionalOnMissingBean(ZookeeperClient.class)
- public ZookeeperClient zookeeperClient(final ZookeeperProperties
zookeeperProp) {
- int sessionTimeout =
Objects.isNull(zookeeperProp.getSessionTimeout()) ? 3000 :
zookeeperProp.getSessionTimeout();
- int connectionTimeout =
Objects.isNull(zookeeperProp.getConnectionTimeout()) ? 3000 :
zookeeperProp.getConnectionTimeout();
- ZookeeperConfig zkConfig = new
ZookeeperConfig(zookeeperProp.getUrl());
- zkConfig.setSessionTimeoutMilliseconds(sessionTimeout)
- .setConnectionTimeoutMilliseconds(connectionTimeout);
- ZookeeperClient client = new ZookeeperClient(zkConfig);
- client.start();
- return client;
- }
-
- /**
- * Config event listener data changed listener.
- *
- * @param zkClient the zk client
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(ZookeeperDataChangedListener.class)
- public DataChangedListener zookeeperDataChangedListener(final
ZookeeperClient zkClient) {
- return new ZookeeperDataChangedListener(zkClient);
- }
-
- /**
- * Zookeeper data init zookeeper data init.
- *
- * @param zkClient the zk client
- * @return the zookeeper data init
- */
- @Bean
- @ConditionalOnMissingBean(ZookeeperDataChangedInit.class)
- public DataChangedInit zookeeperDataChangedInit(final ZookeeperClient
zkClient) {
- return new ZookeeperDataChangedInit(zkClient);
- }
- }
-
- /**
- * The type Nacos listener.
- */
- @Configuration
- @ConditionalOnProperty(prefix = "shenyu.sync.nacos", name = "url")
- @EnableConfigurationProperties(NacosProperties.class)
- static class NacosListener {
-
- /**
- * register configService in spring ioc.
- *
- * @param nacosProp the nacos configuration
- * @return ConfigService {@linkplain ConfigService}
- * @throws Exception the exception
- */
- @Bean
- @ConditionalOnMissingBean(ConfigService.class)
- public ConfigService nacosConfigService(final NacosProperties
nacosProp) throws Exception {
- Properties properties = new Properties();
- if (Objects.nonNull(nacosProp.getAcm()) &&
nacosProp.getAcm().isEnabled()) {
- // Use aliyun ACM service
- properties.put(PropertyKeyConst.ENDPOINT,
nacosProp.getAcm().getEndpoint());
- properties.put(PropertyKeyConst.NAMESPACE,
nacosProp.getAcm().getNamespace());
- // Use subaccount ACM administrative authority
- properties.put(PropertyKeyConst.ACCESS_KEY,
nacosProp.getAcm().getAccessKey());
- properties.put(PropertyKeyConst.SECRET_KEY,
nacosProp.getAcm().getSecretKey());
- } else {
- properties.put(PropertyKeyConst.SERVER_ADDR,
nacosProp.getUrl());
- if (StringUtils.isNotBlank(nacosProp.getNamespace())) {
- properties.put(PropertyKeyConst.NAMESPACE,
nacosProp.getNamespace());
- }
- if (StringUtils.isNotBlank(nacosProp.getUsername())) {
- properties.put(PropertyKeyConst.USERNAME,
nacosProp.getUsername());
- }
- if (StringUtils.isNotBlank(nacosProp.getPassword())) {
- properties.put(PropertyKeyConst.PASSWORD,
nacosProp.getPassword());
- }
- }
- return NacosFactory.createConfigService(properties);
- }
-
- /**
- * Data changed listener data changed listener.
- *
- * @param configService the config service
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(NacosDataChangedListener.class)
- public DataChangedListener nacosDataChangedListener(final
ConfigService configService) {
- return new NacosDataChangedListener(configService);
- }
-
- /**
- * Nacos data init nacos data init.
- *
- * @param configService the config service
- * @return the nacos data init
- */
- @Bean
- @ConditionalOnMissingBean(NacosDataChangedInit.class)
- public DataChangedInit nacosDataChangedInit(final ConfigService
configService) {
- return new NacosDataChangedInit(configService);
- }
- }
-
- /**
- * The type Polaris listener.
- */
- @Configuration
- @ConditionalOnProperty(prefix = "shenyu.sync.polaris", name = "url")
- @EnableConfigurationProperties(PolarisProperties.class)
- static class PolarisListener {
-
- /**
- * register configFileService in spring ioc.
- *
- * @return ConfigFileService {@linkplain ConfigFileService}
- */
- @Bean
- @ConditionalOnMissingBean(ConfigFileService.class)
- public ConfigFileService polarisConfigFileService(final
PolarisProperties polarisProperties) {
- com.tencent.polaris.api.config.Configuration configuration =
ConfigAPIFactory.defaultConfig();
-
configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl()));
- return
ConfigFileServiceFactory.createConfigFileService(configuration);
- }
-
- /**
- * register configFilePublishService in spring ioc.
- *
- * @return ConfigFilePublishService {@linkplain
ConfigFilePublishService}
- */
- @Bean
- @ConditionalOnMissingBean(ConfigFilePublishService.class)
- public ConfigFilePublishService polarisConfigFilePublishService(final
PolarisProperties polarisProperties) {
- com.tencent.polaris.api.config.Configuration configuration =
ConfigAPIFactory.defaultConfig();
-
configuration.getConfigFile().getServerConnector().setAddresses(Collections.singletonList(polarisProperties.getUrl()));
- return
ConfigFileServicePublishFactory.createConfigFilePublishService(configuration);
- }
-
- /**
- * Data changed listener data changed listener.
- *
- * @param configFileService the config service
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(PolarisDataChangedListener.class)
- public DataChangedListener polarisDataChangedListener(final
PolarisProperties polarisProperties, final ConfigFileService configFileService,
- final
ConfigFilePublishService configFilePublishService) {
- return new PolarisDataChangedListener(polarisProperties,
configFileService, configFilePublishService);
- }
-
- /**
- * Polaris data init polaris data init.
- *
- * @param configFileService the config service
- * @return the polaris data init
- */
- @Bean
- @ConditionalOnMissingBean(PolarisDataChangedInit.class)
- public DataChangedInit polarisDataChangedInit(final PolarisProperties
polarisProperties, final ConfigFileService configFileService) {
- return new PolarisDataChangedInit(polarisProperties,
configFileService);
- }
-
- }
-
- /**
- * The WebsocketListener(default strategy).
- */
- @Configuration
- @ConditionalOnProperty(name = "shenyu.sync.websocket.enabled", havingValue
= "true", matchIfMissing = true)
- @EnableConfigurationProperties(WebsocketSyncProperties.class)
- static class WebsocketListener {
-
- /**
- * Config event listener data changed listener.
- *
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(WebsocketDataChangedListener.class)
- public DataChangedListener websocketDataChangedListener() {
- return new WebsocketDataChangedListener();
- }
-
- /**
- * Websocket collector.
- *
- * @return the websocket collector
- */
- @Bean
- @ConditionalOnMissingBean(WebsocketCollector.class)
- public WebsocketCollector websocketCollector() {
- return new WebsocketCollector();
- }
-
- /**
- * Server endpoint exporter server endpoint exporter.
- *
- * @return the server endpoint exporter
- */
- @Bean
- @ConditionalOnMissingBean(ServerEndpointExporter.class)
- public ServerEndpointExporter serverEndpointExporter() {
- return new ServerEndpointExporter();
- }
- }
-
- /**
- * The type Etcd listener.
- */
- @Configuration
- @ConditionalOnProperty(prefix = "shenyu.sync.etcd", name = "url")
- @EnableConfigurationProperties(EtcdProperties.class)
- static class EtcdListener {
-
- /**
- * Init etcd client.
- *
- * @param etcdProperties etcd properties
- * @return Etcd Client
- */
- @Bean
- public EtcdClient etcdClient(final EtcdProperties etcdProperties) {
- Client client = Client.builder()
- .endpoints(etcdProperties.getUrl().split(","))
- .build();
- return new EtcdClient(client);
- }
-
- /**
- * Config event listener data changed listener.
- *
- * @param etcdClient the etcd client
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(EtcdDataDataChangedListener.class)
- public DataChangedListener etcdDataChangedListener(final EtcdClient
etcdClient) {
- return new EtcdDataDataChangedListener(etcdClient);
- }
-
- /**
- * data init.
- *
- * @param etcdClient the etcd client
- * @return the etcd data init
- */
- @Bean
- @ConditionalOnMissingBean(EtcdDataChangedInit.class)
- public DataChangedInit etcdDataChangedInit(final EtcdClient
etcdClient) {
- return new EtcdDataChangedInit(etcdClient);
- }
- }
-
- /**
- * The type Consul listener.
- */
- @Configuration
- @ConditionalOnProperty(prefix = "shenyu.sync.consul", name = "url")
- @EnableConfigurationProperties(ConsulProperties.class)
- static class ConsulListener {
-
- /**
- * init Consul client.
- *
- * @param consulProperties the consul properties
- * @return Consul client
- */
- @Bean
- public ConsulClient consulClient(final ConsulProperties
consulProperties) {
- String url = consulProperties.getUrl();
- if (StringUtils.isBlank(url)) {
- throw new ShenyuException("sync.consul.url can not be null.");
- }
- try {
- URL consulUrl = new URL(url);
- return consulUrl.getPort() < 0 ? new
ConsulClient(consulUrl.getHost()) : new ConsulClient(consulUrl.getHost(),
consulUrl.getPort());
- } catch (MalformedURLException e) {
- throw new ShenyuException("sync.consul.url formatter is not
incorrect.");
- }
- }
-
- /**
- * Config event listener data changed listener.
- *
- * @param consulClient the consul client
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(ConsulDataChangedListener.class)
- public DataChangedListener consulDataChangedListener(final
ConsulClient consulClient) {
- return new ConsulDataChangedListener(consulClient);
- }
-
- /**
- * Consul data init.
- *
- * @param consulClient the consul client
- * @return the consul data init
- */
- @Bean
- @ConditionalOnMissingBean(ConsulDataChangedInit.class)
- public DataChangedInit consulDataChangedInit(final ConsulClient
consulClient) {
- return new ConsulDataChangedInit(consulClient);
- }
- }
-
- /**
- * the type apollo listener.
- */
- @Configuration
- @ConditionalOnProperty(prefix = "shenyu.sync.apollo", name = "meta")
- @EnableConfigurationProperties(ApolloProperties.class)
- static class ApolloListener {
-
- /**
- * init Consul client.
- *
- * @param apolloProperties the apollo properties
- * @return apollo client
- */
- @Bean
- public ApolloClient apolloClient(final ApolloProperties
apolloProperties) {
- return new ApolloClient(apolloProperties);
- }
-
- /**
- * Config event listener data changed listener.
- *
- * @param apolloClient the apollo client
- * @return the data changed listener
- */
- @Bean
- @ConditionalOnMissingBean(ApolloDataChangedListener.class)
- public DataChangedListener apolloDataChangeListener(final ApolloClient
apolloClient) {
- return new ApolloDataChangedListener(apolloClient);
- }
-
- /**
- * apollo data init.
- *
- * @param apolloClient the apollo client
- * @return the apollo data init
- */
- @Bean
- @ConditionalOnMissingBean(ApolloDataChangedInit.class)
- public DataChangedInit apolloDataChangeInit(final ApolloClient
apolloClient) {
- return new ApolloDataChangedInit(apolloClient);
- }
-
- }
-}
-
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
new file mode 100644
index 0000000000..7e14e83a9c
--- /dev/null
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/HttpLongPollingSyncConfiguration.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import org.apache.shenyu.admin.config.properties.HttpSyncProperties;
+import org.apache.shenyu.admin.controller.ConfigController;
+import
org.apache.shenyu.admin.listener.http.HttpLongPollingDataChangedListener;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * http long polling.
+ */
+@Configuration
+@ConditionalOnProperty(name = "shenyu.sync.http.enabled", havingValue = "true")
+@EnableConfigurationProperties(HttpSyncProperties.class)
+public class HttpLongPollingSyncConfiguration {
+
+ /**
+ * httpLongPollingDataChangedListener.
+ *
+ * @param httpSyncProperties httpSyncProperties
+ * @return {@link HttpLongPollingDataChangedListener}
+ */
+ @Bean
+ @ConditionalOnMissingBean(HttpLongPollingDataChangedListener.class)
+ public HttpLongPollingDataChangedListener
httpLongPollingDataChangedListener(final HttpSyncProperties httpSyncProperties)
{
+ return new HttpLongPollingDataChangedListener(httpSyncProperties);
+ }
+
+ /**
+ * configController.
+ *
+ * @param httpLongPollingDataChangedListener
httpLongPollingDataChangedListener
+ * @return {@link ConfigController}
+ */
+ @Bean
+ @ConditionalOnMissingBean(ConfigController.class)
+ public ConfigController configController(final
HttpLongPollingDataChangedListener httpLongPollingDataChangedListener) {
+ return new ConfigController(httpLongPollingDataChangedListener);
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/WebSocketSyncConfiguration.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/WebSocketSyncConfiguration.java
new file mode 100644
index 0000000000..a914a493c4
--- /dev/null
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/config/WebSocketSyncConfiguration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shenyu.admin.config;
+
+import org.apache.shenyu.admin.config.properties.WebsocketSyncProperties;
+import org.apache.shenyu.admin.listener.DataChangedListener;
+import org.apache.shenyu.admin.listener.websocket.WebsocketCollector;
+import org.apache.shenyu.admin.listener.websocket.WebsocketDataChangedListener;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+/**
+ * The WebsocketListener(default strategy).
+ */
+@Configuration
+@ConditionalOnProperty(name = "shenyu.sync.websocket.enabled", havingValue =
"true", matchIfMissing = true)
+@EnableConfigurationProperties(WebsocketSyncProperties.class)
+public class WebSocketSyncConfiguration {
+
+ /**
+ * Config event listener data changed listener.
+ *
+ * @return the data changed listener
+ */
+ @Bean
+ @ConditionalOnMissingBean(WebsocketDataChangedListener.class)
+ public DataChangedListener websocketDataChangedListener() {
+ return new WebsocketDataChangedListener();
+ }
+
+ /**
+ * Websocket collector.
+ *
+ * @return the websocket collector
+ */
+ @Bean
+ @ConditionalOnMissingBean(WebsocketCollector.class)
+ public WebsocketCollector websocketCollector() {
+ return new WebsocketCollector();
+ }
+
+ /**
+ * Server endpoint exporter server endpoint exporter.
+ *
+ * @return the server endpoint exporter
+ */
+ @Bean
+ @ConditionalOnMissingBean(ServerEndpointExporter.class)
+ public ServerEndpointExporter serverEndpointExporter() {
+ return new ServerEndpointExporter();
+ }
+}
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java
index 66f3c93039..d78749f783 100644
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java
+++
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/http/HttpLongPollingDataChangedListener.java
@@ -18,9 +18,6 @@
package org.apache.shenyu.admin.listener.http;
import com.google.common.collect.Lists;
-
-import java.util.Objects;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
@@ -32,12 +29,12 @@ import org.apache.shenyu.admin.utils.ShenyuResultMessage;
import org.apache.shenyu.common.concurrent.ShenyuThreadFactory;
import org.apache.shenyu.common.constant.HttpConstants;
import org.apache.shenyu.common.dto.AppAuthData;
+import org.apache.shenyu.common.dto.DiscoverySyncData;
import org.apache.shenyu.common.dto.MetaData;
import org.apache.shenyu.common.dto.PluginData;
+import org.apache.shenyu.common.dto.ProxySelectorData;
import org.apache.shenyu.common.dto.RuleData;
import org.apache.shenyu.common.dto.SelectorData;
-import org.apache.shenyu.common.dto.ProxySelectorData;
-import org.apache.shenyu.common.dto.DiscoverySyncData;
import org.apache.shenyu.common.enums.ConfigGroupEnum;
import org.apache.shenyu.common.enums.DataEventTypeEnum;
import org.apache.shenyu.common.exception.ShenyuException;
@@ -55,6 +52,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Future;
diff --git
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/HttpServiceDiscovery.java
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/HttpServiceDiscovery.java
deleted file mode 100644
index dc6adadb93..0000000000
---
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/listener/zookeeper/HttpServiceDiscovery.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shenyu.admin.listener.zookeeper;
-
-import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
-import org.apache.curator.framework.recipes.cache.TreeCacheListener;
-import org.apache.shenyu.admin.listener.DataChangedEvent;
-import org.apache.shenyu.admin.mapper.SelectorMapper;
-import org.apache.shenyu.admin.model.entity.SelectorDO;
-import org.apache.shenyu.admin.service.SelectorService;
-import org.apache.shenyu.common.constant.Constants;
-import org.apache.shenyu.common.dto.SelectorData;
-import org.apache.shenyu.common.dto.convert.selector.DivideUpstream;
-import org.apache.shenyu.common.enums.ConfigGroupEnum;
-import org.apache.shenyu.common.enums.DataEventTypeEnum;
-import org.apache.shenyu.common.utils.GsonUtils;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperClient;
-import org.apache.shenyu.register.client.server.zookeeper.ZookeeperConfig;
-import org.apache.zookeeper.CreateMode;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * The type Http service discovery.
- *
- * @deprecated sice 2.2.0 Deprecated
- */
-@Component
-@SuppressWarnings("all")
-@Deprecated
-public class HttpServiceDiscovery implements InitializingBean {
-
- public static final String ROOT = "/shenyu/register";
-
- public static final String URI_PATH = "/shenyu/register/*/*";
-
- private ZookeeperClient zkClient;
-
- private final SelectorService selectorService;
-
- private final SelectorMapper selectorMapper;
-
- private final ApplicationEventPublisher eventPublisher;
-
- private final Environment env;
-
- private volatile List<String> contextPathList;
-
- /**
- * Instantiates a new Http service discovery.
- *
- * @param selectorService the selector service
- * @param selectorMapper the selector mapper
- * @param eventPublisher the event publisher
- * @param env the env
- */
- @Autowired(required = false)
- public HttpServiceDiscovery(final SelectorService selectorService,
- final SelectorMapper selectorMapper,
- final ApplicationEventPublisher eventPublisher,
- final Environment env) {
- this.selectorService = selectorService;
- this.selectorMapper = selectorMapper;
- this.eventPublisher = eventPublisher;
- this.env = env;
- }
-
- @Override
- public void afterPropertiesSet() {
- Boolean register = env.getProperty("shenyu.http.register",
Boolean.class, false);
- if (!register) {
- return;
- }
- String zookeeperUrl = env.getProperty("shenyu.http.zookeeperUrl", "");
- if (StringUtils.isNoneBlank(zookeeperUrl)) {
- zkClient = createZkClient(zookeeperUrl);
- boolean exists = zkClient.isExist(ROOT);
- if (!exists) {
- zkClient.createOrUpdate(ROOT, "", CreateMode.PERSISTENT);
- }
-
- zkClient.addCache(ROOT, new HttpServiceListener());
- }
- }
-
- @VisibleForTesting
- ZookeeperClient createZkClient(final String zookeeperUrl) {
- ZookeeperConfig config = new ZookeeperConfig(zookeeperUrl);
- config.setSessionTimeoutMilliseconds(5000)
- .setConnectionTimeoutMilliseconds(2000);
- ZookeeperClient client = new ZookeeperClient(config);
- client.start();
- return client;
- }
-
- private void updateServiceList(final List<String> children, final String
contextPath) {
- List<String> uriList = new ArrayList<>();
- for (String subNode : children) {
- // Read node data
- String data = zkClient.get(subNode);
- uriList.add(data);
- }
- updateSelectorHandler(contextPath, uriList);
- }
-
- private void updateSelectorHandler(final String contextPath, final
List<String> uriList) {
- SelectorDO selector = selectorService.findByName(contextPath);
- if (Objects.nonNull(selector)) {
- SelectorData selectorData =
selectorService.buildByName(contextPath);
- if (Objects.isNull(uriList)) {
- selector.setHandle("");
- selectorData.setHandle("");
- } else {
- String handler =
GsonUtils.getInstance().toJson(buildDivideUpstream(uriList));
- selector.setHandle(handler);
- selectorData.setHandle(handler);
- }
- selectorMapper.updateSelective(selector);
-
- // publish change event.
- eventPublisher.publishEvent(new
DataChangedEvent(ConfigGroupEnum.SELECTOR, DataEventTypeEnum.UPDATE,
- Collections.singletonList(selectorData)));
- }
- }
-
- private List<DivideUpstream> buildDivideUpstream(final List<String>
uriList) {
- return uriList.stream().map(uri -> {
- DivideUpstream divideUpstream = DivideUpstream.builder()
- .upstreamHost("localhost")
- .protocol("http://")
- .upstreamUrl(uri)
- .weight(50)
- .build();
- return divideUpstream;
- }).collect(Collectors.toList());
- }
-
- class HttpServiceListener implements TreeCacheListener {
- @Override
- public void childEvent(final CuratorFramework client, final
TreeCacheEvent event) throws Exception {
- String path = event.getData().getPath();
- // if not uri register path, return.
- if (!path.contains(ROOT)) {
- return;
- }
-
- // get children under context path
- int lastSepIndex = path.lastIndexOf(Constants.PATH_SEPARATOR);
- String contextPath = path.substring(0, lastSepIndex);
- List<String> childrenList = zkClient.getChildren(contextPath);
- List<String> collect = childrenList.stream().map(r -> contextPath
+ "/" + r).collect(Collectors.toList());
- updateServiceList(collect, contextPath);
- }
- }
-}
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/DataSyncConfigurationTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/DataSyncConfigurationTest.java
index ef821aee31..7115ed7999 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/DataSyncConfigurationTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/config/DataSyncConfigurationTest.java
@@ -112,7 +112,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
@Test
public void testHttpLongPollingDataChangedListener() {
final HttpSyncProperties httpSyncProperties = new HttpSyncProperties();
- DataSyncConfiguration.HttpLongPollingListener httpLongPollingListener
= new DataSyncConfiguration.HttpLongPollingListener();
+ HttpLongPollingSyncConfiguration httpLongPollingListener = new
HttpLongPollingSyncConfiguration();
assertNotNull(httpLongPollingListener.httpLongPollingDataChangedListener(httpSyncProperties));
}
@@ -120,7 +120,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
public void zookeeperClientTest() {
try (MockedConstruction<ZookeeperClient>
zookeeperClientMockedConstruction = mockConstruction(ZookeeperClient.class)) {
final ZookeeperProperties zookeeperProperties = new
ZookeeperProperties();
- DataSyncConfiguration.ZookeeperListener zookeeperListener = new
DataSyncConfiguration.ZookeeperListener();
+ ZookeeperSyncConfiguration zookeeperListener = new
ZookeeperSyncConfiguration();
assertNotNull(zookeeperListener.zookeeperClient(zookeeperProperties));
zookeeperProperties.setSessionTimeout(3000);
zookeeperProperties.setConnectionTimeout(3000);
@@ -130,7 +130,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
@Test
public void testZookeeperDataChangedListener() {
- DataSyncConfiguration.ZookeeperListener zookeeperListener = new
DataSyncConfiguration.ZookeeperListener();
+ ZookeeperSyncConfiguration zookeeperListener = new
ZookeeperSyncConfiguration();
assertNotNull(zookeeperListener.zookeeperDataChangedListener(zkClient));
}
@@ -138,38 +138,38 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
public void testZookeeperDataInit() {
final SyncDataService syncDataService = new
SyncDataServiceImpl(appAuthService, pluginService, selectorService,
ruleService, eventPublisher, metaDataService,
discoveryService);
- DataSyncConfiguration.ZookeeperListener zookeeperListener = new
DataSyncConfiguration.ZookeeperListener();
+ ZookeeperSyncConfiguration zookeeperListener = new
ZookeeperSyncConfiguration();
assertNotNull(zookeeperListener.zookeeperDataChangedInit(zkClient));
}
@Test
public void testWebsocketDataChangedListener() {
- DataSyncConfiguration.WebsocketListener websocketListener = new
DataSyncConfiguration.WebsocketListener();
+ WebSocketSyncConfiguration websocketListener = new
WebSocketSyncConfiguration();
assertNotNull(websocketListener.websocketDataChangedListener());
}
@Test
public void testWebsocketCollector() {
- DataSyncConfiguration.WebsocketListener websocketListener = new
DataSyncConfiguration.WebsocketListener();
+ WebSocketSyncConfiguration websocketListener = new
WebSocketSyncConfiguration();
assertNotNull(websocketListener.websocketCollector());
}
@Test
public void testServerEndpointExporter() {
- DataSyncConfiguration.WebsocketListener websocketListener = new
DataSyncConfiguration.WebsocketListener();
+ WebSocketSyncConfiguration websocketListener = new
WebSocketSyncConfiguration();
assertNotNull(websocketListener.serverEndpointExporter());
}
@Test
public void testNacosDataChangedListener() {
- DataSyncConfiguration.NacosListener nacosListener = new
DataSyncConfiguration.NacosListener();
+ NacosSyncConfiguration nacosListener = new NacosSyncConfiguration();
NacosConfigService configService = mock(NacosConfigService.class);
assertNotNull(nacosListener.nacosDataChangedListener(configService));
}
@Test
public void testNacosDataInit() {
- DataSyncConfiguration.NacosListener nacosListener = new
DataSyncConfiguration.NacosListener();
+ NacosSyncConfiguration nacosListener = new NacosSyncConfiguration();
NacosConfigService configService = mock(NacosConfigService.class);
assertNotNull(nacosListener.nacosDataChangedInit(configService));
}
@@ -181,7 +181,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
final NacosProperties.NacosACMProperties nacosACMProperties = new
NacosProperties.NacosACMProperties();
nacosProperties.setAcm(nacosACMProperties);
nacosFactoryMockedStatic.when(() ->
NacosFactory.createConfigService(any(Properties.class))).thenReturn(mock(ConfigService.class));
- DataSyncConfiguration.NacosListener nacosListener = new
DataSyncConfiguration.NacosListener();
+ NacosSyncConfiguration nacosListener = new
NacosSyncConfiguration();
nacosProperties.setUrl("url");
Assertions.assertDoesNotThrow(() ->
nacosListener.nacosConfigService(nacosProperties));
nacosProperties.setNamespace("url");
@@ -199,7 +199,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
@Test
public void testPolarisDataChangedListener() {
- DataSyncConfiguration.PolarisListener polarisListener = new
DataSyncConfiguration.PolarisListener();
+ PolarisSyncConfiguration polarisListener = new
PolarisSyncConfiguration();
PolarisProperties polarisProperties = mock(PolarisProperties.class);
ConfigFileService polarisConfigFileService =
mock(ConfigFileService.class);
ConfigFilePublishService polarisConfigFilePublishService =
mock(ConfigFilePublishService.class);
@@ -208,7 +208,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
@Test
public void testPolarisDataInit() {
- DataSyncConfiguration.PolarisListener polarisListener = new
DataSyncConfiguration.PolarisListener();
+ PolarisSyncConfiguration polarisListener = new
PolarisSyncConfiguration();
PolarisProperties polarisProperties = mock(PolarisProperties.class);
ConfigFileService polarisConfigFileService =
mock(ConfigFileService.class);
assertNotNull(polarisListener.polarisDataChangedInit(polarisProperties,
polarisConfigFileService));
@@ -219,21 +219,21 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
final PolarisProperties polarisProperties = new PolarisProperties();
polarisProperties.setUrl("127.0.0.1:8093");
polarisProperties.setNamespace("namespace");
- DataSyncConfiguration.PolarisListener polarisListener = new
DataSyncConfiguration.PolarisListener();
+ PolarisSyncConfiguration polarisListener = new
PolarisSyncConfiguration();
assertNotNull(polarisListener.polarisConfigFileService(polarisProperties));
assertNotNull(polarisListener.polarisConfigFilePublishService(polarisProperties));
}
@Test
public void testEtcdDataChangedListener() {
- DataSyncConfiguration.EtcdListener etcdListener = new
DataSyncConfiguration.EtcdListener();
+ EtcdSyncConfiguration etcdListener = new EtcdSyncConfiguration();
EtcdClient client = mock(EtcdClient.class);
assertNotNull(etcdListener.etcdDataChangedListener(client));
}
@Test
public void testEtcdDataInit() {
- DataSyncConfiguration.EtcdListener etcdListener = new
DataSyncConfiguration.EtcdListener();
+ EtcdSyncConfiguration etcdListener = new EtcdSyncConfiguration();
EtcdClient client = mock(EtcdClient.class);
SyncDataService syncDataService = mock(SyncDataService.class);
assertNotNull(etcdListener.etcdDataChangedInit(client));
@@ -241,7 +241,7 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
@Test
public void testConsulClient() {
- DataSyncConfiguration.ConsulListener consulListener = new
DataSyncConfiguration.ConsulListener();
+ ConsulSyncConfiguration consulListener = new ConsulSyncConfiguration();
ConsulProperties consulProperties = mock(ConsulProperties.class);
when(consulProperties.getUrl()).thenReturn("http://127.0.0.1:8500");
assertNotNull(consulListener.consulClient(consulProperties));
@@ -249,14 +249,14 @@ public final class DataSyncConfigurationTest extends
AbstractConfigurationTest {
@Test
public void testConsulDataChangedListener() {
- DataSyncConfiguration.ConsulListener consulListener = new
DataSyncConfiguration.ConsulListener();
+ ConsulSyncConfiguration consulListener = new ConsulSyncConfiguration();
ConsulClient consulClient = mock(ConsulClient.class);
assertNotNull(consulListener.consulDataChangedListener(consulClient));
}
@Test
public void testConsulDataInit() {
- DataSyncConfiguration.ConsulListener consulListener = new
DataSyncConfiguration.ConsulListener();
+ ConsulSyncConfiguration consulListener = new ConsulSyncConfiguration();
ConsulClient consulClient = mock(ConsulClient.class);
SyncDataService syncDataService = mock(SyncDataService.class);
assertNotNull(consulListener.consulDataChangedInit(consulClient));