From 69367002b1f84cdbae7045a3f6ef18dec9193c0a Mon Sep 17 00:00:00 2001 From: qinliujie Date: Fri, 1 Mar 2019 14:49:56 +0800 Subject: [PATCH 1/2] feature:add AppendParametersComponent to dynamically add some parameters / check config --- .../config/AppendParametersComponent.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/AppendParametersComponent.java 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 00000000000..01de9bc4a65 --- /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) { + + } +} From 350c4f89dd286b6e91e0a3d49b1e0770b00d5e03 Mon Sep 17 00:00:00 2001 From: qinliujie Date: Fri, 1 Mar 2019 14:53:28 +0800 Subject: [PATCH 2/2] feature:add AppendParametersComponent to dynamically add some parameters / check config --- .../main/java/org/apache/dubbo/config/ReferenceConfig.java | 7 +++++++ .../main/java/org/apache/dubbo/config/ServiceConfig.java | 7 +++++++ 2 files changed, 14 insertions(+) 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 4d89a4a5b7b..4e1d46722fa 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 void checkAndUpdateSubConfigs() { resolveFile(); checkApplication(); checkMetadataReport(); + appendParameters(); + } + + private void appendParameters() { + URL appendParametersUrl = URL.valueOf("appendParameters://"); + List 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 c02e745a3ef..c2bd4307c75 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 void checkAndUpdateSubConfigs() { } checkStubAndLocal(interfaceClass); checkMock(interfaceClass); + appendParameters(); + } + + private void appendParameters() { + URL appendParametersUrl = URL.valueOf("appendParameters://"); + List appendParametersComponents = ExtensionLoader.getExtensionLoader(AppendParametersComponent.class).getActivateExtension(appendParametersUrl, (String[]) null); + appendParametersComponents.forEach(component -> component.appendExportParameters(this)); } public synchronized void export() {