From a357c9f20e9041ca5aad898b740379a4370a9781 Mon Sep 17 00:00:00 2001 From: redkale Date: Wed, 13 Dec 2023 13:07:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/redkale/net/http/Rest.java | 16 ++++++++++------ src/main/java/org/redkale/net/sncp/Sncp.java | 20 +++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/redkale/net/http/Rest.java b/src/main/java/org/redkale/net/http/Rest.java index 14ffa05c1..03878fb33 100644 --- a/src/main/java/org/redkale/net/http/Rest.java +++ b/src/main/java/org/redkale/net/http/Rest.java @@ -536,7 +536,7 @@ public final class Rest { FieldVisitor fv; MethodDebugVisitor mv; AnnotationVisitor av0; - cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null); + cw.visit(V11, ACC_PUBLIC + ACC_SUPER, newDynName, null, supDynName, null); { //RestDyn av0 = cw.visitAnnotation(Type.getDescriptor(RestDyn.class), true); av0.visit("simple", false); //WebSocketServlet必须要解析http-header @@ -588,7 +588,8 @@ public final class Rest { Resource res = field.getAnnotation(Resource.class); javax.annotation.Resource res2 = field.getAnnotation(javax.annotation.Resource.class); java.lang.reflect.Type fieldType = field.getGenericType(); - fv = cw.visitField(ACC_PRIVATE, "_redkale_resource_" + i, Type.getDescriptor(field.getType()), fieldType == field.getType() ? null : Utility.getTypeDescriptor(fieldType), null); + fv = cw.visitField(ACC_PRIVATE, "_redkale_resource_" + i, Type.getDescriptor(field.getType()), + fieldType == field.getType() ? null : Utility.getTypeDescriptor(fieldType), null); { av0 = fv.visitAnnotation(resDesc, true); av0.visit("name", res != null ? res.name() : res2.name()); @@ -599,7 +600,8 @@ public final class Rest { } } { //_redkale_annotations - fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, "_redkale_annotations", "Ljava/util/Map;", "Ljava/util/Map;", null); + fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, "_redkale_annotations", "Ljava/util/Map;", + "Ljava/util/Map;", null); fv.visitEnd(); } { //_DynWebSocketServlet构造函数 @@ -635,7 +637,8 @@ public final class Rest { mv.visitEnd(); } { //createWebSocket 方法 - mv = new MethodDebugVisitor(cw.visitMethod(ACC_PROTECTED, "createWebSocket", "()" + wsDesc, "()L" + WebSocket.class.getName().replace('.', '/') + ";", null)); + mv = new MethodDebugVisitor(cw.visitMethod(ACC_PROTECTED, "createWebSocket", "()" + wsDesc, + "()L" + WebSocket.class.getName().replace('.', '/') + ";", null)); mv.visitTypeInsn(NEW, newDynName + "$" + newDynWebSokcetSimpleName); mv.visitInsn(DUP); for (int i = 0; i < resourcesFields.size(); i++) { @@ -648,7 +651,8 @@ public final class Rest { mv.visitEnd(); } { //createRestOnMessageConsumer - mv = new MethodDebugVisitor(cw.visitMethod(ACC_PROTECTED, "createRestOnMessageConsumer", "()Ljava/util/function/BiConsumer;", "()Ljava/util/function/BiConsumer<" + wsDesc + "Ljava/lang/Object;>;", null)); + mv = new MethodDebugVisitor(cw.visitMethod(ACC_PROTECTED, "createRestOnMessageConsumer", + "()Ljava/util/function/BiConsumer;", "()Ljava/util/function/BiConsumer<" + wsDesc + "Ljava/lang/Object;>;", null)); mv.visitTypeInsn(NEW, newDynConsumerFullName); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, newDynConsumerFullName, "", "()V", false); @@ -1683,7 +1687,7 @@ public final class Rest { final List restConverts = new ArrayList<>(); final Map mappingurlToMethod = new HashMap<>(); - cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null); + cw.visit(V11, ACC_PUBLIC + ACC_SUPER, newDynName, null, supDynName, null); { //RestDynSourceType av0 = cw.visitAnnotation(Type.getDescriptor(RestDynSourceType.class), true); diff --git a/src/main/java/org/redkale/net/sncp/Sncp.java b/src/main/java/org/redkale/net/sncp/Sncp.java index 2447aa26d..d2d19887e 100644 --- a/src/main/java/org/redkale/net/sncp/Sncp.java +++ b/src/main/java/org/redkale/net/sncp/Sncp.java @@ -22,6 +22,7 @@ import org.redkale.convert.bson.BsonConvert; import org.redkale.mq.MessageAgent; import org.redkale.net.http.WebSocketNode; import org.redkale.net.sncp.SncpRemoteInfo.SncpRemoteAction; +import org.redkale.schedule.Scheduled; import org.redkale.service.*; import org.redkale.util.AnyValue; import org.redkale.util.RedkaleClassLoader; @@ -30,7 +31,6 @@ import org.redkale.util.ResourceFactory; import org.redkale.util.TypeToken; import org.redkale.util.Uint128; import org.redkale.util.Utility; -import org.redkale.schedule.Scheduled; /** * Service Node Communicate Protocol @@ -173,7 +173,8 @@ public abstract class Sncp { Method old = actionids.get(actionid); if (old != null) { if (old.getDeclaringClass().equals(method.getDeclaringClass())) { - throw new SncpException(serviceTypeOrImplClass.getName() + " have one more same action(Method=" + method + ", " + old + ", actionid=" + actionid + ")"); + throw new SncpException(serviceTypeOrImplClass.getName() + + " have one more same action(Method=" + method + ", " + old + ", actionid=" + actionid + ")"); } continue; } @@ -324,7 +325,9 @@ public abstract class Sncp { if (WebSocketNode.class.isAssignableFrom(resourceType)) { return getSncpReqTopicPrefix() + "module.wsnode" + nodeid + (resourceName.isEmpty() ? "" : ("-" + resourceName)); } - return getSncpReqTopicPrefix() + "module." + resourceType.getSimpleName().replaceAll("Service.*$", "").toLowerCase() + (resourceName.isEmpty() ? "" : ("-" + resourceName)); + return getSncpReqTopicPrefix() + "module." + + resourceType.getSimpleName().replaceAll("Service.*$", "").toLowerCase() + + (resourceName.isEmpty() ? "" : ("-" + resourceName)); } public static String getSncpReqTopicPrefix() { @@ -557,7 +560,7 @@ public abstract class Sncp { MethodDebugVisitor mv; AnnotationVisitor av0; - cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, supDynName, null); + cw.visit(V11, ACC_PUBLIC + ACC_SUPER, newDynName, null, supDynName, null); { //给动态生成的Service类标记上Resource av0 = cw.visitAnnotation(resDesc, true); av0.visit("name", name); @@ -786,7 +789,8 @@ public abstract class Sncp { if (!java.lang.reflect.Modifier.isPublic(mod)) { return null; } - final SncpRemoteInfo info = createSncpRemoteInfo(name, getResourceType(serviceTypeOrImplClass), serviceTypeOrImplClass, BsonConvert.root(), sncpRpcGroups, client, agent, remoteGroup); + final SncpRemoteInfo info = createSncpRemoteInfo(name, getResourceType(serviceTypeOrImplClass), + serviceTypeOrImplClass, BsonConvert.root(), sncpRpcGroups, client, agent, remoteGroup); final String supDynName = serviceTypeOrImplClass.getName().replace('.', '/'); final String sncpInfoName = SncpRemoteInfo.class.getName().replace('.', '/'); final String resDesc = Type.getDescriptor(Resource.class); @@ -836,7 +840,8 @@ public abstract class Sncp { MethodDebugVisitor mv; AnnotationVisitor av0; - cw.visit(V11, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, newDynName, null, serviceTypeOrImplClass.isInterface() ? "java/lang/Object" : supDynName, serviceTypeOrImplClass.isInterface() ? new String[]{supDynName} : null); + cw.visit(V11, ACC_PUBLIC + ACC_SUPER, newDynName, null, serviceTypeOrImplClass.isInterface() ? "java/lang/Object" : supDynName, + serviceTypeOrImplClass.isInterface() ? new String[]{supDynName} : null); { //给动态生成的Service类标记上Resource av0 = cw.visitAnnotation(resDesc, true); av0.visit("name", name); @@ -956,7 +961,8 @@ public abstract class Sncp { mv.visitVarInsn(ILOAD, insn); } Class bigclaz = TypeToken.primitiveToWrapper((Class) pt); - mv.visitMethodInsn(INVOKESTATIC, bigclaz.getName().replace('.', '/'), "valueOf", "(" + Type.getDescriptor((Class) pt) + ")" + Type.getDescriptor(bigclaz), false); + mv.visitMethodInsn(INVOKESTATIC, bigclaz.getName().replace('.', '/'), "valueOf", + "(" + Type.getDescriptor((Class) pt) + ")" + Type.getDescriptor(bigclaz), false); } else { mv.visitVarInsn(ALOAD, insn); }