This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new c5f8ce6478 auto detect proxy type (#12232)
c5f8ce6478 is described below

commit c5f8ce64787cbb17628ac5176947d46a457ee0ee
Author: icodening <[email protected]>
AuthorDate: Fri May 5 16:18:31 2023 +0800

    auto detect proxy type (#12232)
    
    * auto detect proxy type
    
    * auto detect proxy type
---
 .../java/org/apache/dubbo/rpc/model/DubboStub.java | 25 ++++++++++++++++++++++
 .../main/resources/Dubbo3InterfaceStub.mustache    |  2 +-
 .../resources/Dubbo3TripleInterfaceStub.mustache   |  2 +-
 .../src/main/resources/DubboStub.mustache          |  2 +-
 .../src/main/resources/DubboStub3Single.mustache   |  2 +-
 .../ReactorDubbo3TripleInterfaceStub.mustache      |  2 +-
 .../org/apache/dubbo/config/ReferenceConfig.java   |  7 ++++++
 7 files changed, 37 insertions(+), 5 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/DubboStub.java 
b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/DubboStub.java
new file mode 100644
index 0000000000..7047eeaa1d
--- /dev/null
+++ b/dubbo-common/src/main/java/org/apache/dubbo/rpc/model/DubboStub.java
@@ -0,0 +1,25 @@
+/*
+ * 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.rpc.model;
+
+/**
+ * Marker interface implemented by all stub. Used to detect
+ * whether objects are Dubbo-generated stub.
+ */
+public interface DubboStub {
+}
diff --git a/dubbo-compiler/src/main/resources/Dubbo3InterfaceStub.mustache 
b/dubbo-compiler/src/main/resources/Dubbo3InterfaceStub.mustache
index f97b7183b0..ebbaad9f7d 100644
--- a/dubbo-compiler/src/main/resources/Dubbo3InterfaceStub.mustache
+++ b/dubbo-compiler/src/main/resources/Dubbo3InterfaceStub.mustache
@@ -25,7 +25,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 {{#deprecated}}
     @java.lang.Deprecated
 {{/deprecated}}
-public interface {{interfaceClassName}} {
+public interface {{interfaceClassName}} extends 
org.apache.dubbo.rpc.model.DubboStub {
 
     static final String JAVA_SERVICE_NAME = "{{packageName}}.{{serviceName}}";
     static final String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
diff --git 
a/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache 
b/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
index 6788bfb653..72b68c3d67 100644
--- a/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
+++ b/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
@@ -27,7 +27,7 @@ import java.util.Map;
 import java.util.function.BiConsumer;
 import java.util.concurrent.CompletableFuture;
 
-public interface {{interfaceClassName}} {
+public interface {{interfaceClassName}} extends 
org.apache.dubbo.rpc.model.DubboStub {
 
     String JAVA_SERVICE_NAME = "{{packageName}}.{{serviceName}}";
     String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
diff --git a/dubbo-compiler/src/main/resources/DubboStub.mustache 
b/dubbo-compiler/src/main/resources/DubboStub.mustache
index c45995587c..8bf729e8dd 100644
--- a/dubbo-compiler/src/main/resources/DubboStub.mustache
+++ b/dubbo-compiler/src/main/resources/DubboStub.mustache
@@ -51,7 +51,7 @@ public static final String SERVICE_NAME = 
"{{packageName}}.{{serviceName}}";
 /**
 * Code generated for Dubbo
 */
-public interface I{{serviceName}} {
+public interface I{{serviceName}} extends org.apache.dubbo.rpc.model.DubboStub 
{
 
 static Class<?> clazz = init();
 
diff --git a/dubbo-compiler/src/main/resources/DubboStub3Single.mustache 
b/dubbo-compiler/src/main/resources/DubboStub3Single.mustache
index 25a45e86d7..b46653b488 100644
--- a/dubbo-compiler/src/main/resources/DubboStub3Single.mustache
+++ b/dubbo-compiler/src/main/resources/DubboStub3Single.mustache
@@ -51,7 +51,7 @@ public static final String SERVICE_NAME = 
"{{packageName}}.{{serviceName}}";
 /**
 * Code generated for Dubbo
 */
-public interface I{{serviceName}} {
+public interface I{{serviceName}} extends org.apache.dubbo.rpc.model.DubboStub 
{
 
     static Class<?> clazz = init();
 
diff --git 
a/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache 
b/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
index b3b900831e..43e427f9f3 100644
--- 
a/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
+++ 
b/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
@@ -22,7 +22,7 @@ package {{packageName}};
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
-public interface {{interfaceClassName}} {
+public interface {{interfaceClassName}} extends 
org.apache.dubbo.rpc.model.DubboStub {
 
     String JAVA_SERVICE_NAME = "{{packageName}}.{{serviceName}}";
 
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 fb34d5110c..fd2868864b 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
@@ -43,6 +43,7 @@ import org.apache.dubbo.rpc.cluster.support.ClusterUtils;
 import org.apache.dubbo.rpc.cluster.support.registry.ZoneAwareCluster;
 import org.apache.dubbo.rpc.model.AsyncMethodInfo;
 import org.apache.dubbo.rpc.model.ConsumerModel;
+import org.apache.dubbo.rpc.model.DubboStub;
 import org.apache.dubbo.rpc.model.ModuleModel;
 import org.apache.dubbo.rpc.model.ModuleServiceRepository;
 import org.apache.dubbo.rpc.model.ScopeModel;
@@ -264,6 +265,12 @@ public class ReferenceConfig<T> extends 
ReferenceConfigBase<T> {
             if (!this.isRefreshed()) {
                 this.refresh();
             }
+            //auto detect proxy type
+            String proxyType = getProxy();
+            if (StringUtils.isBlank(proxyType)
+                && DubboStub.class.isAssignableFrom(interfaceClass)) {
+                setProxy(CommonConstants.NATIVE_STUB);
+            }
 
             // init serviceMetadata
             initServiceMetadata(consumer);

Reply via email to