diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/transaction/DistributedDatabaseOperateImpl.java b/config/src/main/java/com/alibaba/nacos/config/server/service/transaction/DistributedDatabaseOperateImpl.java index b1bf3f257..68e1c357c 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/transaction/DistributedDatabaseOperateImpl.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/transaction/DistributedDatabaseOperateImpl.java @@ -23,7 +23,7 @@ import com.alibaba.nacos.config.server.utils.LogUtil; import com.alibaba.nacos.consistency.LogFuture; import com.alibaba.nacos.consistency.SerializeFactory; import com.alibaba.nacos.consistency.Serializer; -import com.alibaba.nacos.common.utils.ClassUtils; +import com.alibaba.nacos.core.utils.ClassUtils; import com.alibaba.nacos.config.server.constant.Constants; import com.alibaba.nacos.config.server.exception.NJdbcException; import com.alibaba.nacos.config.server.service.DynamicDataSource; diff --git a/config/src/test/java/com/alibaba/nacos/config/server/service/RowMapperManagerTest.java b/config/src/test/java/com/alibaba/nacos/config/server/service/RowMapperManagerTest.java index c41770853..749facd0e 100644 --- a/config/src/test/java/com/alibaba/nacos/config/server/service/RowMapperManagerTest.java +++ b/config/src/test/java/com/alibaba/nacos/config/server/service/RowMapperManagerTest.java @@ -1,7 +1,8 @@ package com.alibaba.nacos.config.server.service; -import com.alibaba.nacos.common.utils.ClassUtils; +import com.alibaba.nacos.core.utils.ClassUtils; import com.alibaba.nacos.config.server.model.User; +import org.junit.Assert; import org.junit.Test; import org.springframework.jdbc.core.RowMapper; @@ -10,7 +11,7 @@ public class RowMapperManagerTest { @Test public void test_user_mapper() { RowMapper mapper = new RowMapperManager.UserRowMapper(); - System.out.println(ClassUtils.resolveGenericTypeByInterface(mapper.getClass())); + Assert.assertEquals(ClassUtils.resolveGenericTypeByInterface(mapper.getClass()).getSimpleName(), User.class.getSimpleName()); } } \ No newline at end of file diff --git a/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java b/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java index db6118090..a0b8b1a8d 100644 --- a/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java +++ b/core/src/main/java/com/alibaba/nacos/core/cluster/ServerMemberManager.java @@ -16,7 +16,7 @@ package com.alibaba.nacos.core.cluster; -import com.alibaba.nacos.common.utils.ClassUtils; +import com.alibaba.nacos.core.utils.ClassUtils; import com.alibaba.nacos.consistency.Config; import com.alibaba.nacos.consistency.ConsistencyProtocol; import com.alibaba.nacos.consistency.LogProcessor; diff --git a/core/src/main/java/com/alibaba/nacos/core/controller/BaseController.java b/core/src/main/java/com/alibaba/nacos/core/controller/BaseController.java deleted file mode 100644 index 89d9a2b0d..000000000 --- a/core/src/main/java/com/alibaba/nacos/core/controller/BaseController.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 1999-2018 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. - */ - -package com.alibaba.nacos.core.controller; - -import org.springframework.web.bind.annotation.RestController; - -/** - * @author liaochuntao - */ -@RestController -public class BaseController { -} diff --git a/common/src/main/java/com/alibaba/nacos/common/utils/ClassUtils.java b/core/src/main/java/com/alibaba/nacos/core/utils/ClassUtils.java similarity index 65% rename from common/src/main/java/com/alibaba/nacos/common/utils/ClassUtils.java rename to core/src/main/java/com/alibaba/nacos/core/utils/ClassUtils.java index 3b3eac389..3b906f75a 100644 --- a/common/src/main/java/com/alibaba/nacos/common/utils/ClassUtils.java +++ b/core/src/main/java/com/alibaba/nacos/core/utils/ClassUtils.java @@ -14,26 +14,22 @@ * limitations under the License. */ -package com.alibaba.nacos.common.utils; +package com.alibaba.nacos.core.utils; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; +import org.springframework.core.ResolvableType; /** * @author liaochuntao */ -public class ClassUtils { +@SuppressWarnings("all") +public final class ClassUtils { public static Class resolveGenericType(Class declaredClass) { - ParameterizedType parameterizedType = (ParameterizedType) declaredClass.getGenericSuperclass(); - Type[] actualTypeArguments = parameterizedType.getActualTypeArguments(); - return (Class) actualTypeArguments[0]; + return (Class) ResolvableType.forClass(declaredClass).getSuperType().resolveGeneric(0); } - public static Class resolveGenericTypeByInterface(Class cls) { - Type[] types = cls.getGenericInterfaces(); - Type[] actualTypeArguments = ((ParameterizedType) types[0]).getActualTypeArguments(); - return (Class) actualTypeArguments[0]; + public static Class resolveGenericTypeByInterface(Class declaredClass) { + return (Class) ResolvableType.forClass(declaredClass).getInterfaces()[0].resolveGeneric(0); } public static Class findClassByName(String className) {