net.dongliu.prettypb.rpc.coder.ProtobufDecoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of prettypb-rpc Show documentation
Show all versions of prettypb-rpc Show documentation
proto rpc libs, compatible with proto-rpc-pro
package net.dongliu.prettypb.rpc.coder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
import net.dongliu.prettypb.runtime.ExtensionRegistry;
import net.dongliu.prettypb.runtime.ProtoBufDecoder;
import java.util.List;
/**
* Decodes a received ByteBuf into a Google Protocol Buffers Message.
*/
public class ProtobufDecoder extends MessageToMessageDecoder {
private final Class> clazz;
private final ExtensionRegistry extensionRegistry;
/**
* Creates a new instance.
*/
public ProtobufDecoder(Class> clazz) {
this(clazz, null);
}
public ProtobufDecoder(Class> clazz, ExtensionRegistry extensionRegistry) {
if (clazz == null) {
throw new NullPointerException("clazz cannot be null");
}
this.clazz = clazz;
this.extensionRegistry = extensionRegistry;
}
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List