Skip to content

Commit

Permalink
修改长连接request response 类注册逻辑,由类扫描改成手动注册 (#9738)
Browse files Browse the repository at this point in the history
* 修改request response 类加载逻辑,有类扫描改成手动注册

* 优化注册方式,直接SPI注册payload
  • Loading branch information
shiyiyue1102 authored Dec 21, 2022
1 parent b472d70 commit 6904707
Show file tree
Hide file tree
Showing 20 changed files with 147 additions and 394 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed 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.
#
#
com.alibaba.nacos.api.remote.request.ClientDetectionRequest
com.alibaba.nacos.api.remote.request.ConnectionSetupRequest
com.alibaba.nacos.api.remote.request.ConnectResetRequest
com.alibaba.nacos.api.remote.request.HealthCheckRequest
com.alibaba.nacos.api.remote.request.PushAckRequest
com.alibaba.nacos.api.remote.request.ServerCheckRequest
com.alibaba.nacos.api.remote.request.ServerLoaderInfoRequest
com.alibaba.nacos.api.remote.request.ServerReloadRequest
com.alibaba.nacos.api.remote.response.ClientDetectionResponse
com.alibaba.nacos.api.remote.response.ConnectResetResponse
com.alibaba.nacos.api.remote.response.ErrorResponse
com.alibaba.nacos.api.remote.response.HealthCheckResponse
com.alibaba.nacos.api.remote.response.ServerCheckResponse
com.alibaba.nacos.api.remote.response.ServerLoaderInfoResponse
com.alibaba.nacos.api.remote.response.ServerReloadResponse
com.alibaba.nacos.api.config.remote.request.ClientConfigMetricRequest
com.alibaba.nacos.api.config.remote.request.ConfigBatchListenRequest
com.alibaba.nacos.api.config.remote.request.ConfigChangeNotifyRequest
com.alibaba.nacos.api.config.remote.request.ConfigPublishRequest
com.alibaba.nacos.api.config.remote.request.ConfigQueryRequest
com.alibaba.nacos.api.config.remote.request.ConfigRemoveRequest
com.alibaba.nacos.api.config.remote.response.ClientConfigMetricResponse
com.alibaba.nacos.api.config.remote.response.ConfigChangeBatchListenResponse
com.alibaba.nacos.api.config.remote.response.ConfigChangeNotifyResponse
com.alibaba.nacos.api.config.remote.response.ConfigPublishResponse
com.alibaba.nacos.api.config.remote.response.ConfigQueryResponse
com.alibaba.nacos.api.config.remote.response.ConfigRemoveResponse
com.alibaba.nacos.api.config.remote.request.cluster.ConfigChangeClusterSyncRequest
com.alibaba.nacos.api.config.remote.response.cluster.ConfigChangeClusterSyncResponse
com.alibaba.nacos.api.naming.remote.request.BatchInstanceRequest
com.alibaba.nacos.api.naming.remote.request.InstanceRequest
com.alibaba.nacos.api.naming.remote.request.NotifySubscriberRequest
com.alibaba.nacos.api.naming.remote.request.ServiceListRequest
com.alibaba.nacos.api.naming.remote.request.ServiceQueryRequest
com.alibaba.nacos.api.naming.remote.request.SubscribeServiceRequest
com.alibaba.nacos.api.naming.remote.response.BatchInstanceResponse
com.alibaba.nacos.api.naming.remote.response.InstanceResponse
com.alibaba.nacos.api.naming.remote.response.NotifySubscriberResponse
com.alibaba.nacos.api.naming.remote.response.QueryServiceResponse
com.alibaba.nacos.api.naming.remote.response.ServiceListResponse
com.alibaba.nacos.api.naming.remote.response.SubscribeServiceResponse
6 changes: 6 additions & 0 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@
<include>
com/alibaba/nacos/api/**/**
</include>
<include>
META-INF/**/*.*
</include>
</includes>
</filter>

Expand Down Expand Up @@ -339,6 +342,9 @@
<include>
com/alibaba/nacos/api/**/**
</include>
<include>
META-INF/**/*.*
</include>
</includes>
</filter>

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
package com.alibaba.nacos.common.remote;

import com.alibaba.nacos.api.remote.Payload;
import com.alibaba.nacos.common.packagescan.DefaultPackageScan;

import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;

/**
* payload regitry,Define basic scan behavior request and response.
* payload registry,Define basic scan behavior request and response.
*
* @author liuzunfei
* @author hujun
Expand All @@ -47,18 +45,9 @@ private static synchronized void scan() {
if (initialized) {
return;
}

ServiceLoader<PayloadPackageProvider> payloadPackages = ServiceLoader.load(PayloadPackageProvider.class);
Set<String> result = new HashSet<>();
for (PayloadPackageProvider payloadPackage : payloadPackages) {
result.addAll(payloadPackage.getScanPackage());
}
for (String pkg : result) {
DefaultPackageScan packageScan = new DefaultPackageScan();
Set<Class<Payload>> subTypesResponse = packageScan.getSubTypesOf(pkg, Payload.class);
for (Class<?> clazz : subTypesResponse) {
register(clazz.getSimpleName(), clazz);
}
ServiceLoader<Payload> payloads = ServiceLoader.load(Payload.class);
for (Payload payload : payloads) {
register(payload.getClass().getSimpleName(), payload.getClass());
}
initialized = true;
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 6904707

Please sign in to comment.