This is an automated email from the ASF dual-hosted git repository.
jefflv pushed a commit to branch 3.x-dev
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/3.x-dev by this push:
new bef8f6d [Feature] add AppendParametersComponent (#3583)
bef8f6d is described below
commit bef8f6d9013c9f086327939e0c39fe102f47dfbd
Author: qinliujie <[email protected]>
AuthorDate: Fri Mar 1 17:52:46 2019 +0800
[Feature] add AppendParametersComponent (#3583)
* feature:add AppendParametersComponent to dynamically add some parameters
/ check config
* feature:add AppendParametersComponent to dynamically add some parameters
/ check config
---
.../dubbo/config/AppendParametersComponent.java | 34 ++++++++++++++++++++++
.../org/apache/dubbo/config/ReferenceConfig.java | 7 +++++
.../org/apache/dubbo/config/ServiceConfig.java | 7 +++++
3 files changed, 48 insertions(+)
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AppendParametersComponent.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AppendParametersComponent.java
new file mode 100644
index 0000000..01de9bc
--- /dev/null
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AppendParametersComponent.java
@@ -0,0 +1,34 @@
+/*
+ * 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.dubbo.config;
+
+import org.apache.dubbo.common.extension.SPI;
+
+/**
+ * Dynamically add some parameters / check config
+ */
+
+@SPI
+public interface AppendParametersComponent {
+ default void appendReferParameters(ReferenceConfig referenceConfig) {
+
+ }
+
+ default void appendExportParameters(ServiceConfig serviceConfig) {
+
+ }
+}
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
index 4d89a4a..4e1d467 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ReferenceConfig.java
@@ -214,6 +214,13 @@ public class ReferenceConfig<T> extends
AbstractReferenceConfig {
resolveFile();
checkApplication();
checkMetadataReport();
+ appendParameters();
+ }
+
+ private void appendParameters() {
+ URL appendParametersUrl = URL.valueOf("appendParameters://");
+ List<AppendParametersComponent> appendParametersComponents =
ExtensionLoader.getExtensionLoader(AppendParametersComponent.class).getActivateExtension(appendParametersUrl,
(String[]) null);
+ appendParametersComponents.forEach(component ->
component.appendReferParameters(this));
}
public synchronized T get() {
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
index c02e745..c2bd430 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/ServiceConfig.java
@@ -322,6 +322,13 @@ public class ServiceConfig<T> extends
AbstractServiceConfig {
}
checkStubAndLocal(interfaceClass);
checkMock(interfaceClass);
+ appendParameters();
+ }
+
+ private void appendParameters() {
+ URL appendParametersUrl = URL.valueOf("appendParameters://");
+ List<AppendParametersComponent> appendParametersComponents =
ExtensionLoader.getExtensionLoader(AppendParametersComponent.class).getActivateExtension(appendParametersUrl,
(String[]) null);
+ appendParametersComponents.forEach(component ->
component.appendExportParameters(this));
}
public synchronized void export() {