diff --git a/doc/TODO.md b/doc/TODO.md
index 94779982..9886a596 100644
--- a/doc/TODO.md
+++ b/doc/TODO.md
@@ -1,6 +1,6 @@
### protocol
-- 考虑用javassist的方式支持protobuf,放弃使用jprotobuf(可以省略很多不必要的注解,代码更加简洁),用约定大于配置的方式,还可以原生的和pojo对象结合起来
+- 考虑用javassist的方式支持protobuf,用约定大于配置的方式,还可以原生的和pojo对象结合起来
- 通过protobuf的proto文件生成java的pojo源代码,通过动态编译java源代码的方式生成其它语言的源代码
diff --git a/net/pom.xml b/net/pom.xml
index 7ff4524d..1ceb8744 100644
--- a/net/pom.xml
+++ b/net/pom.xml
@@ -30,7 +30,6 @@
5.2.31.10.0
- 2.4.193.3.13.3.1
@@ -140,17 +139,6 @@
${spring.boot.version}provided
-
- com.baidu
- jprotobuf
- ${jprotobuf.version}
-
-
- slf4j-api
- org.slf4j
-
-
- junitjunit
diff --git a/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufGatewayServer.java b/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufGatewayServer.java
deleted file mode 100644
index 442f07b9..00000000
--- a/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufGatewayServer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- * 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.zfoo.net.core.jprotobuf;
-
-import com.zfoo.net.core.AbstractServer;
-import com.zfoo.net.core.HostAndPort;
-import com.zfoo.net.handler.GatewayRouteHandler;
-import com.zfoo.net.handler.codec.jprotobuf.JProtobufTcpCodecHandler;
-import com.zfoo.net.handler.idle.ServerIdleHandler;
-import com.zfoo.net.session.Session;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.handler.timeout.IdleStateHandler;
-import org.springframework.lang.Nullable;
-
-import java.util.function.BiFunction;
-
-/**
- * @author godotg
- */
-public class JProtobufGatewayServer extends AbstractServer {
-
- private final BiFunction packetFilter;
-
- public JProtobufGatewayServer(HostAndPort host, @Nullable BiFunction packetFilter) {
- super(host);
- this.packetFilter = packetFilter;
- }
-
- @Override
- protected void initChannel(SocketChannel channel) {
- channel.pipeline().addLast(new IdleStateHandler(0, 0, 180));
- channel.pipeline().addLast(new ServerIdleHandler());
- channel.pipeline().addLast(new JProtobufTcpCodecHandler());
- channel.pipeline().addLast(new GatewayRouteHandler(packetFilter));
- }
-
-}
diff --git a/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufTcpClient.java b/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufTcpClient.java
deleted file mode 100644
index 01d2e96b..00000000
--- a/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufTcpClient.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- *
- * 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.zfoo.net.core.jprotobuf;
-
-import com.zfoo.net.core.AbstractClient;
-import com.zfoo.net.core.HostAndPort;
-import com.zfoo.net.handler.ClientRouteHandler;
-import com.zfoo.net.handler.codec.jprotobuf.JProtobufTcpCodecHandler;
-import com.zfoo.net.handler.idle.ClientIdleHandler;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.handler.timeout.IdleStateHandler;
-
-/**
- * @author godotg
- */
-public class JProtobufTcpClient extends AbstractClient {
-
- public JProtobufTcpClient(HostAndPort host) {
- super(host);
- }
-
- @Override
- protected void initChannel(SocketChannel channel) {
- channel.pipeline().addLast(new IdleStateHandler(0, 0, 60));
- channel.pipeline().addLast(new ClientIdleHandler());
- channel.pipeline().addLast(new JProtobufTcpCodecHandler());
- channel.pipeline().addLast(new ClientRouteHandler());
- }
-}
diff --git a/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufTcpServer.java b/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufTcpServer.java
deleted file mode 100644
index b74e28c1..00000000
--- a/net/src/main/java/com/zfoo/net/core/jprotobuf/JProtobufTcpServer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- *
- * 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.zfoo.net.core.jprotobuf;
-
-import com.zfoo.net.core.AbstractServer;
-import com.zfoo.net.core.HostAndPort;
-import com.zfoo.net.handler.ServerRouteHandler;
-import com.zfoo.net.handler.codec.jprotobuf.JProtobufTcpCodecHandler;
-import com.zfoo.net.handler.idle.ServerIdleHandler;
-import io.netty.channel.socket.SocketChannel;
-import io.netty.handler.timeout.IdleStateHandler;
-
-/**
- * @author godotg
- */
-public class JProtobufTcpServer extends AbstractServer {
-
- public JProtobufTcpServer(HostAndPort host) {
- super(host);
- }
-
- @Override
- protected void initChannel(SocketChannel channel) {
- channel.pipeline().addLast(new IdleStateHandler(0, 0, 180));
- channel.pipeline().addLast(new ServerIdleHandler());
- channel.pipeline().addLast(new JProtobufTcpCodecHandler());
- channel.pipeline().addLast(new ServerRouteHandler());
- }
-}
diff --git a/net/src/main/java/com/zfoo/net/handler/codec/jprotobuf/JProtobufTcpCodecHandler.java b/net/src/main/java/com/zfoo/net/handler/codec/jprotobuf/JProtobufTcpCodecHandler.java
deleted file mode 100644
index 7ed464d2..00000000
--- a/net/src/main/java/com/zfoo/net/handler/codec/jprotobuf/JProtobufTcpCodecHandler.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- *
- * 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.zfoo.net.handler.codec.jprotobuf;
-
-import com.baidu.bjf.remoting.protobuf.Codec;
-import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
-import com.zfoo.net.packet.DecodedPacketInfo;
-import com.zfoo.net.packet.EncodedPacketInfo;
-import com.zfoo.net.packet.PacketService;
-import com.zfoo.protocol.ProtocolManager;
-import com.zfoo.protocol.buffer.ByteBufUtils;
-import com.zfoo.protocol.util.IOUtils;
-import com.zfoo.protocol.util.StringUtils;
-import io.netty.buffer.ByteBuf;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageCodec;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * header(4byte) + protocolId(2byte) + packet
- * header = body(bytes.length) + protocolId.length(2byte)
- *
- * @author godotg
- */
-public class JProtobufTcpCodecHandler extends ByteToMessageCodec {
-
- @Override
- protected void decode(ChannelHandlerContext ctx, ByteBuf in, List
-
- com.baidu
- jprotobuf
- 2.4.19
- test
-
-
- slf4j-api
- org.slf4j
-
-
-
-
-
-
-
- com.google.code.findbugs
- jsr305
- 3.0.2
-
-
org.openjdk.jmh
@@ -137,6 +116,13 @@
test
+
+ com.google.protobuf
+ protobuf-java
+ 3.21.7
+ test
+
+
com.esotericsoftwarekryo
diff --git a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/JProtobufTesting.java b/protocol/src/test/java/com/zfoo/protocol/jprotobuf/JProtobufTesting.java
deleted file mode 100644
index b4db7c62..00000000
--- a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/JProtobufTesting.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- * 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.zfoo.protocol.jprotobuf;
-
-import com.baidu.bjf.remoting.protobuf.ProtobufProxy;
-import com.zfoo.protocol.ProtocolManager;
-import com.zfoo.protocol.generate.GenerateOperation;
-import com.zfoo.protocol.packet.ProtobufObject;
-import com.zfoo.protocol.serializer.CodeLanguage;
-import com.zfoo.protocol.util.JsonUtils;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author godotg
- */
-@Ignore
-public class JProtobufTesting {
-
- private static final Map mapWithInteger = new HashMap<>(Map.of(Integer.MIN_VALUE, "a", -99, "b", 0, "c", 99, "d", Integer.MAX_VALUE, "e"));
-
- @Test
- public void deserializerTest() throws IOException {
- var simpleTypeCodec = ProtobufProxy.create(ObjectA.class);
-
- var obj = new ObjectA();
- obj.a = Integer.MAX_VALUE;
- obj.m = mapWithInteger;
-
- // 序列化
- byte[] bytes = simpleTypeCodec.encode(obj);
- // 反序列化
- var newObj = simpleTypeCodec.decode(bytes);
-
- // 反序列化到protobuf
- var newProtobufObj = ProtobufObject.ObjectA.parseFrom(bytes);
- System.out.println(JsonUtils.object2String(newObj));
- }
-
-
- @Test
- public void serializerTest() throws IOException {
- // 原生protobuf对象
- var protobufObjectB = ProtobufObject.ObjectB.newBuilder().setFlag(false).build();
- var protobufObjectA = ProtobufObject.ObjectA.newBuilder()
- .setA(Integer.MAX_VALUE)
- .putAllM(mapWithInteger)
- .setObjectB(protobufObjectB)
- .build();
-
- byte[] bytes = protobufObjectA.toByteArray();
-
- var simpleTypeCodec = ProtobufProxy.create(ObjectA.class);
- var newObj = simpleTypeCodec.decode(bytes);
- System.out.println(JsonUtils.object2String(newObj));
- }
-}
diff --git a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectA.java b/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectA.java
deleted file mode 100644
index 00ad16da..00000000
--- a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectA.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- *
- * 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.zfoo.protocol.jprotobuf;
-
-import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
-import com.zfoo.protocol.anno.Protocol;
-
-import java.util.Map;
-
-/**
- * protobuf的测试类型
- * 包括了各种复杂的结构,对象,map
- *
- * @author godotg
- */
-@Protocol(id = 102)
-public class ObjectA {
-
-
- // int类型,在protobuf中叫int32
- @Protobuf(order = 1)
- public int a;
-
- // map类型
- // protobuf中的map的key只能为基础类型
- @Protobuf(order = 2)
- public Map m;
-
- /**
- * 对象类型
- */
- @Protobuf(order = 3)
- public ObjectB objectB;
-
-}
diff --git a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectB.java b/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectB.java
deleted file mode 100644
index c8a4ee18..00000000
--- a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectB.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- *
- * 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.zfoo.protocol.jprotobuf;
-
-import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
-import com.zfoo.protocol.anno.Protocol;
-
-/**
- * @author godotg
- */
-@Protocol(id = 103)
-public class ObjectB {
-
- @Protobuf(order = 1)
- public boolean flag;
-
-}
-
diff --git a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectC.java b/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectC.java
deleted file mode 100644
index 15e5593f..00000000
--- a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ObjectC.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- *
- * 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.zfoo.protocol.jprotobuf;
-
-import com.baidu.bjf.remoting.protobuf.annotation.Protobuf;
-import com.zfoo.protocol.anno.Protocol;
-
-import java.util.Map;
-
-/**
- * ObjectC的测试类型
- *
- * @author godotg
- */
-@Protocol(id = 104)
-public class ObjectC {
-
- // int类型,在protobuf中叫int32
- @Protobuf(order = 1)
- public int a;
-
- // map类型
- // protobuf中的map的key只能为基础类型
- @Protobuf(order = 2)
- public Map m;
-
- /**
- * 对象类型
- */
- @Protobuf(order = 3)
- public ObjectB objectB;
-
-}
diff --git a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ProtobufTagTesting.java b/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ProtobufTagTesting.java
deleted file mode 100644
index cb5cbe18..00000000
--- a/protocol/src/test/java/com/zfoo/protocol/jprotobuf/ProtobufTagTesting.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 The zfoo Authors
- * 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.zfoo.protocol.jprotobuf;
-
-import com.google.protobuf.CodedOutputStream;
-import com.zfoo.protocol.buffer.ByteBufUtils;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.UnpooledUnsafeHeapByteBuf;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import java.io.IOException;
-
-/**
- * @author godotg
- */
-@Ignore
-public class ProtobufTagTesting {
-
- @Test
- public void test() throws IOException {
- var buffer = new byte[1024 * 8];
- var output = CodedOutputStream.newInstance(buffer);
- output.writeSInt32NoTag(Integer.MAX_VALUE);
-
- var length = output.getTotalBytesWritten();
- for (int i = 0; i < length; i++) {
- System.out.println(buffer[i]);
- }
- System.out.println("----------------------------------");
-
- var byteBuf = new UnpooledUnsafeHeapByteBuf(ByteBufAllocator.DEFAULT, 100, 1_0000);
- ByteBufUtils.writeInt(byteBuf, Integer.MAX_VALUE);
- var bytes = ByteBufUtils.readAllBytes(byteBuf);
- for (int i = 0; i < bytes.length; i++) {
- System.out.println(bytes[i]);
- }
- }
-
-}