Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto detect proxy type #12232

Merged
merged 2 commits into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}";
Expand Down
2 changes: 1 addition & 1 deletion dubbo-compiler/src/main/resources/DubboStub.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
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;
Expand Down Expand Up @@ -264,6 +265,12 @@ protected synchronized void init() {
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);
Expand Down