作者 crossoverJie

:sparkles: Introducing new features.google protocol

... ... @@ -14,6 +14,11 @@
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<scope>compile</scope>
... ...
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: BaseProtoc.proto
package com.crossoverjie.netty.action.common.protocol;
public final class BaseProto {
private BaseProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
public interface ProtocolOrBuilder extends
// @@protoc_insertion_point(interface_extends:protocol.Protocol)
com.google.protobuf.MessageOrBuilder {
/**
* <code>required int32 header = 2;</code>
*/
boolean hasHeader();
/**
* <code>required int32 header = 2;</code>
*/
int getHeader();
/**
* <code>required string msg = 1;</code>
*/
boolean hasMsg();
/**
* <code>required string msg = 1;</code>
*/
String getMsg();
/**
* <code>required string msg = 1;</code>
*/
com.google.protobuf.ByteString
getMsgBytes();
}
/**
* Protobuf type {@code protocol.Protocol}
*/
public static final class Protocol extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:protocol.Protocol)
ProtocolOrBuilder {
private static final long serialVersionUID = 0L;
// Use Protocol.newBuilder() to construct.
private Protocol(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private Protocol() {
header_ = 0;
msg_ = "";
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private Protocol(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
case 10: {
com.google.protobuf.ByteString bs = input.readBytes();
bitField0_ |= 0x00000002;
msg_ = bs;
break;
}
case 16: {
bitField0_ |= 0x00000001;
header_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return BaseProto.internal_static_protocol_Protocol_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return BaseProto.internal_static_protocol_Protocol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Protocol.class, Builder.class);
}
private int bitField0_;
public static final int HEADER_FIELD_NUMBER = 2;
private int header_;
/**
* <code>required int32 header = 2;</code>
*/
public boolean hasHeader() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int32 header = 2;</code>
*/
public int getHeader() {
return header_;
}
public static final int MSG_FIELD_NUMBER = 1;
private volatile Object msg_;
/**
* <code>required string msg = 1;</code>
*/
public boolean hasMsg() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required string msg = 1;</code>
*/
public String getMsg() {
Object ref = msg_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
msg_ = s;
}
return s;
}
}
/**
* <code>required string msg = 1;</code>
*/
public com.google.protobuf.ByteString
getMsgBytes() {
Object ref = msg_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
msg_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
if (!hasHeader()) {
memoizedIsInitialized = 0;
return false;
}
if (!hasMsg()) {
memoizedIsInitialized = 0;
return false;
}
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (((bitField0_ & 0x00000002) == 0x00000002)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, msg_);
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeInt32(2, header_);
}
unknownFields.writeTo(output);
}
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, msg_);
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(2, header_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Protocol)) {
return super.equals(obj);
}
Protocol other = (Protocol) obj;
boolean result = true;
result = result && (hasHeader() == other.hasHeader());
if (hasHeader()) {
result = result && (getHeader()
== other.getHeader());
}
result = result && (hasMsg() == other.hasMsg());
if (hasMsg()) {
result = result && getMsg()
.equals(other.getMsg());
}
result = result && unknownFields.equals(other.unknownFields);
return result;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
if (hasHeader()) {
hash = (37 * hash) + HEADER_FIELD_NUMBER;
hash = (53 * hash) + getHeader();
}
if (hasMsg()) {
hash = (37 * hash) + MSG_FIELD_NUMBER;
hash = (53 * hash) + getMsg().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static Protocol parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Protocol parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Protocol parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Protocol parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Protocol parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Protocol parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Protocol parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Protocol parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static Protocol parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static Protocol parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static Protocol parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Protocol parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(Protocol prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code protocol.Protocol}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:protocol.Protocol)
ProtocolOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return BaseProto.internal_static_protocol_Protocol_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return BaseProto.internal_static_protocol_Protocol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Protocol.class, Builder.class);
}
// Construct using com.crossoverjie.netty.action.protocol.BaseProto.Protocol.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
header_ = 0;
bitField0_ = (bitField0_ & ~0x00000001);
msg_ = "";
bitField0_ = (bitField0_ & ~0x00000002);
return this;
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return BaseProto.internal_static_protocol_Protocol_descriptor;
}
public Protocol getDefaultInstanceForType() {
return Protocol.getDefaultInstance();
}
public Protocol build() {
Protocol result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public Protocol buildPartial() {
Protocol result = new Protocol(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
result.header_ = header_;
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
to_bitField0_ |= 0x00000002;
}
result.msg_ = msg_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
}
public Builder clone() {
return (Builder) super.clone();
}
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.setField(field, value);
}
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return (Builder) super.clearField(field);
}
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return (Builder) super.clearOneof(oneof);
}
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return (Builder) super.setRepeatedField(field, index, value);
}
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.addRepeatedField(field, value);
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof Protocol) {
return mergeFrom((Protocol)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(Protocol other) {
if (other == Protocol.getDefaultInstance()) return this;
if (other.hasHeader()) {
setHeader(other.getHeader());
}
if (other.hasMsg()) {
bitField0_ |= 0x00000002;
msg_ = other.msg_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
public final boolean isInitialized() {
if (!hasHeader()) {
return false;
}
if (!hasMsg()) {
return false;
}
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
Protocol parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (Protocol) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
private int header_ ;
/**
* <code>required int32 header = 2;</code>
*/
public boolean hasHeader() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int32 header = 2;</code>
*/
public int getHeader() {
return header_;
}
/**
* <code>required int32 header = 2;</code>
*/
public Builder setHeader(int value) {
bitField0_ |= 0x00000001;
header_ = value;
onChanged();
return this;
}
/**
* <code>required int32 header = 2;</code>
*/
public Builder clearHeader() {
bitField0_ = (bitField0_ & ~0x00000001);
header_ = 0;
onChanged();
return this;
}
private Object msg_ = "";
/**
* <code>required string msg = 1;</code>
*/
public boolean hasMsg() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required string msg = 1;</code>
*/
public String getMsg() {
Object ref = msg_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
msg_ = s;
}
return s;
} else {
return (String) ref;
}
}
/**
* <code>required string msg = 1;</code>
*/
public com.google.protobuf.ByteString
getMsgBytes() {
Object ref = msg_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
msg_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>required string msg = 1;</code>
*/
public Builder setMsg(
String value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
msg_ = value;
onChanged();
return this;
}
/**
* <code>required string msg = 1;</code>
*/
public Builder clearMsg() {
bitField0_ = (bitField0_ & ~0x00000002);
msg_ = getDefaultInstance().getMsg();
onChanged();
return this;
}
/**
* <code>required string msg = 1;</code>
*/
public Builder setMsgBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
msg_ = value;
onChanged();
return this;
}
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:protocol.Protocol)
}
// @@protoc_insertion_point(class_scope:protocol.Protocol)
private static final Protocol DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new Protocol();
}
public static Protocol getDefaultInstance() {
return DEFAULT_INSTANCE;
}
@Deprecated public static final com.google.protobuf.Parser<Protocol>
PARSER = new com.google.protobuf.AbstractParser<Protocol>() {
public Protocol parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new Protocol(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<Protocol> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<Protocol> getParserForType() {
return PARSER;
}
public Protocol getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_protocol_Protocol_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_protocol_Protocol_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
String[] descriptorData = {
"\n\020BaseProtoc.proto\022\010protocol\"\'\n\010Protocol" +
"\022\016\n\006header\030\002 \002(\005\022\013\n\003msg\030\001 \002(\tB3\n&com.cro" +
"ssoverjie.netty.action.protocolB\tBasePro" +
"to"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_protocol_Protocol_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_protocol_Protocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_protocol_Protocol_descriptor,
new String[] { "Header", "Msg", });
}
// @@protoc_insertion_point(outer_class_scope)
}
... ...
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: BaseRequestProto.proto
package com.crossoverjie.netty.action.common.protocol;
public final class BaseRequestProto {
private BaseRequestProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
public interface RequestProtocolOrBuilder extends
// @@protoc_insertion_point(interface_extends:protocol.RequestProtocol)
com.google.protobuf.MessageOrBuilder {
/**
* <code>required int32 requestId = 2;</code>
*/
boolean hasRequestId();
/**
* <code>required int32 requestId = 2;</code>
*/
int getRequestId();
/**
* <code>required string reqMsg = 1;</code>
*/
boolean hasReqMsg();
/**
* <code>required string reqMsg = 1;</code>
*/
String getReqMsg();
/**
* <code>required string reqMsg = 1;</code>
*/
com.google.protobuf.ByteString
getReqMsgBytes();
}
/**
* Protobuf type {@code protocol.RequestProtocol}
*/
public static final class RequestProtocol extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:protocol.RequestProtocol)
RequestProtocolOrBuilder {
private static final long serialVersionUID = 0L;
// Use RequestProtocol.newBuilder() to construct.
private RequestProtocol(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private RequestProtocol() {
requestId_ = 0;
reqMsg_ = "";
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private RequestProtocol(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
case 10: {
com.google.protobuf.ByteString bs = input.readBytes();
bitField0_ |= 0x00000002;
reqMsg_ = bs;
break;
}
case 16: {
bitField0_ |= 0x00000001;
requestId_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return BaseRequestProto.internal_static_protocol_RequestProtocol_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return BaseRequestProto.internal_static_protocol_RequestProtocol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
RequestProtocol.class, Builder.class);
}
private int bitField0_;
public static final int REQUESTID_FIELD_NUMBER = 2;
private int requestId_;
/**
* <code>required int32 requestId = 2;</code>
*/
public boolean hasRequestId() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int32 requestId = 2;</code>
*/
public int getRequestId() {
return requestId_;
}
public static final int REQMSG_FIELD_NUMBER = 1;
private volatile Object reqMsg_;
/**
* <code>required string reqMsg = 1;</code>
*/
public boolean hasReqMsg() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required string reqMsg = 1;</code>
*/
public String getReqMsg() {
Object ref = reqMsg_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
reqMsg_ = s;
}
return s;
}
}
/**
* <code>required string reqMsg = 1;</code>
*/
public com.google.protobuf.ByteString
getReqMsgBytes() {
Object ref = reqMsg_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
reqMsg_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
if (!hasRequestId()) {
memoizedIsInitialized = 0;
return false;
}
if (!hasReqMsg()) {
memoizedIsInitialized = 0;
return false;
}
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (((bitField0_ & 0x00000002) == 0x00000002)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, reqMsg_);
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeInt32(2, requestId_);
}
unknownFields.writeTo(output);
}
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, reqMsg_);
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(2, requestId_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof RequestProtocol)) {
return super.equals(obj);
}
RequestProtocol other = (RequestProtocol) obj;
boolean result = true;
result = result && (hasRequestId() == other.hasRequestId());
if (hasRequestId()) {
result = result && (getRequestId()
== other.getRequestId());
}
result = result && (hasReqMsg() == other.hasReqMsg());
if (hasReqMsg()) {
result = result && getReqMsg()
.equals(other.getReqMsg());
}
result = result && unknownFields.equals(other.unknownFields);
return result;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
if (hasRequestId()) {
hash = (37 * hash) + REQUESTID_FIELD_NUMBER;
hash = (53 * hash) + getRequestId();
}
if (hasReqMsg()) {
hash = (37 * hash) + REQMSG_FIELD_NUMBER;
hash = (53 * hash) + getReqMsg().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static RequestProtocol parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static RequestProtocol parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static RequestProtocol parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static RequestProtocol parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static RequestProtocol parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static RequestProtocol parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static RequestProtocol parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static RequestProtocol parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static RequestProtocol parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static RequestProtocol parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static RequestProtocol parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static RequestProtocol parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(RequestProtocol prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code protocol.RequestProtocol}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:protocol.RequestProtocol)
RequestProtocolOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return BaseRequestProto.internal_static_protocol_RequestProtocol_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return BaseRequestProto.internal_static_protocol_RequestProtocol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
RequestProtocol.class, Builder.class);
}
// Construct using com.crossoverjie.netty.action.protocol.BaseRequestProto.RequestProtocol.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
requestId_ = 0;
bitField0_ = (bitField0_ & ~0x00000001);
reqMsg_ = "";
bitField0_ = (bitField0_ & ~0x00000002);
return this;
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return BaseRequestProto.internal_static_protocol_RequestProtocol_descriptor;
}
public RequestProtocol getDefaultInstanceForType() {
return RequestProtocol.getDefaultInstance();
}
public RequestProtocol build() {
RequestProtocol result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public RequestProtocol buildPartial() {
RequestProtocol result = new RequestProtocol(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
result.requestId_ = requestId_;
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
to_bitField0_ |= 0x00000002;
}
result.reqMsg_ = reqMsg_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
}
public Builder clone() {
return (Builder) super.clone();
}
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.setField(field, value);
}
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return (Builder) super.clearField(field);
}
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return (Builder) super.clearOneof(oneof);
}
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return (Builder) super.setRepeatedField(field, index, value);
}
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.addRepeatedField(field, value);
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof RequestProtocol) {
return mergeFrom((RequestProtocol)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(RequestProtocol other) {
if (other == RequestProtocol.getDefaultInstance()) return this;
if (other.hasRequestId()) {
setRequestId(other.getRequestId());
}
if (other.hasReqMsg()) {
bitField0_ |= 0x00000002;
reqMsg_ = other.reqMsg_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
public final boolean isInitialized() {
if (!hasRequestId()) {
return false;
}
if (!hasReqMsg()) {
return false;
}
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
RequestProtocol parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (RequestProtocol) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
private int requestId_ ;
/**
* <code>required int32 requestId = 2;</code>
*/
public boolean hasRequestId() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int32 requestId = 2;</code>
*/
public int getRequestId() {
return requestId_;
}
/**
* <code>required int32 requestId = 2;</code>
*/
public Builder setRequestId(int value) {
bitField0_ |= 0x00000001;
requestId_ = value;
onChanged();
return this;
}
/**
* <code>required int32 requestId = 2;</code>
*/
public Builder clearRequestId() {
bitField0_ = (bitField0_ & ~0x00000001);
requestId_ = 0;
onChanged();
return this;
}
private Object reqMsg_ = "";
/**
* <code>required string reqMsg = 1;</code>
*/
public boolean hasReqMsg() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required string reqMsg = 1;</code>
*/
public String getReqMsg() {
Object ref = reqMsg_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
reqMsg_ = s;
}
return s;
} else {
return (String) ref;
}
}
/**
* <code>required string reqMsg = 1;</code>
*/
public com.google.protobuf.ByteString
getReqMsgBytes() {
Object ref = reqMsg_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
reqMsg_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>required string reqMsg = 1;</code>
*/
public Builder setReqMsg(
String value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
reqMsg_ = value;
onChanged();
return this;
}
/**
* <code>required string reqMsg = 1;</code>
*/
public Builder clearReqMsg() {
bitField0_ = (bitField0_ & ~0x00000002);
reqMsg_ = getDefaultInstance().getReqMsg();
onChanged();
return this;
}
/**
* <code>required string reqMsg = 1;</code>
*/
public Builder setReqMsgBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
reqMsg_ = value;
onChanged();
return this;
}
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:protocol.RequestProtocol)
}
// @@protoc_insertion_point(class_scope:protocol.RequestProtocol)
private static final RequestProtocol DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new RequestProtocol();
}
public static RequestProtocol getDefaultInstance() {
return DEFAULT_INSTANCE;
}
@Deprecated public static final com.google.protobuf.Parser<RequestProtocol>
PARSER = new com.google.protobuf.AbstractParser<RequestProtocol>() {
public RequestProtocol parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new RequestProtocol(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<RequestProtocol> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<RequestProtocol> getParserForType() {
return PARSER;
}
public RequestProtocol getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_protocol_RequestProtocol_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_protocol_RequestProtocol_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
String[] descriptorData = {
"\n\026BaseRequestProto.proto\022\010protocol\"4\n\017Re" +
"questProtocol\022\021\n\trequestId\030\002 \002(\005\022\016\n\006reqM" +
"sg\030\001 \002(\tB:\n&com.crossoverjie.netty.actio" +
"n.protocolB\020BaseRequestProto"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_protocol_RequestProtocol_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_protocol_RequestProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_protocol_RequestProtocol_descriptor,
new String[] { "RequestId", "ReqMsg", });
}
// @@protoc_insertion_point(outer_class_scope)
}
... ...
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: BaseResponseProto.proto
package com.crossoverjie.netty.action.common.protocol;
public final class BaseResponseProto {
private BaseResponseProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
public interface ResponseProtocolOrBuilder extends
// @@protoc_insertion_point(interface_extends:protocol.ResponseProtocol)
com.google.protobuf.MessageOrBuilder {
/**
* <code>required int32 responseId = 2;</code>
*/
boolean hasResponseId();
/**
* <code>required int32 responseId = 2;</code>
*/
int getResponseId();
/**
* <code>required string resMsg = 1;</code>
*/
boolean hasResMsg();
/**
* <code>required string resMsg = 1;</code>
*/
String getResMsg();
/**
* <code>required string resMsg = 1;</code>
*/
com.google.protobuf.ByteString
getResMsgBytes();
}
/**
* Protobuf type {@code protocol.ResponseProtocol}
*/
public static final class ResponseProtocol extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:protocol.ResponseProtocol)
ResponseProtocolOrBuilder {
private static final long serialVersionUID = 0L;
// Use ResponseProtocol.newBuilder() to construct.
private ResponseProtocol(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private ResponseProtocol() {
responseId_ = 0;
resMsg_ = "";
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private ResponseProtocol(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
case 10: {
com.google.protobuf.ByteString bs = input.readBytes();
bitField0_ |= 0x00000002;
resMsg_ = bs;
break;
}
case 16: {
bitField0_ |= 0x00000001;
responseId_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return BaseResponseProto.internal_static_protocol_ResponseProtocol_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return BaseResponseProto.internal_static_protocol_ResponseProtocol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
ResponseProtocol.class, Builder.class);
}
private int bitField0_;
public static final int RESPONSEID_FIELD_NUMBER = 2;
private int responseId_;
/**
* <code>required int32 responseId = 2;</code>
*/
public boolean hasResponseId() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int32 responseId = 2;</code>
*/
public int getResponseId() {
return responseId_;
}
public static final int RESMSG_FIELD_NUMBER = 1;
private volatile Object resMsg_;
/**
* <code>required string resMsg = 1;</code>
*/
public boolean hasResMsg() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required string resMsg = 1;</code>
*/
public String getResMsg() {
Object ref = resMsg_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
resMsg_ = s;
}
return s;
}
}
/**
* <code>required string resMsg = 1;</code>
*/
public com.google.protobuf.ByteString
getResMsgBytes() {
Object ref = resMsg_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
resMsg_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
if (!hasResponseId()) {
memoizedIsInitialized = 0;
return false;
}
if (!hasResMsg()) {
memoizedIsInitialized = 0;
return false;
}
memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (((bitField0_ & 0x00000002) == 0x00000002)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, resMsg_);
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
output.writeInt32(2, responseId_);
}
unknownFields.writeTo(output);
}
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, resMsg_);
}
if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(2, responseId_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof ResponseProtocol)) {
return super.equals(obj);
}
ResponseProtocol other = (ResponseProtocol) obj;
boolean result = true;
result = result && (hasResponseId() == other.hasResponseId());
if (hasResponseId()) {
result = result && (getResponseId()
== other.getResponseId());
}
result = result && (hasResMsg() == other.hasResMsg());
if (hasResMsg()) {
result = result && getResMsg()
.equals(other.getResMsg());
}
result = result && unknownFields.equals(other.unknownFields);
return result;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
if (hasResponseId()) {
hash = (37 * hash) + RESPONSEID_FIELD_NUMBER;
hash = (53 * hash) + getResponseId();
}
if (hasResMsg()) {
hash = (37 * hash) + RESMSG_FIELD_NUMBER;
hash = (53 * hash) + getResMsg().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static ResponseProtocol parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ResponseProtocol parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ResponseProtocol parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ResponseProtocol parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ResponseProtocol parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static ResponseProtocol parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static ResponseProtocol parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static ResponseProtocol parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static ResponseProtocol parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static ResponseProtocol parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static ResponseProtocol parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static ResponseProtocol parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(ResponseProtocol prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code protocol.ResponseProtocol}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:protocol.ResponseProtocol)
ResponseProtocolOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return BaseResponseProto.internal_static_protocol_ResponseProtocol_descriptor;
}
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return BaseResponseProto.internal_static_protocol_ResponseProtocol_fieldAccessorTable
.ensureFieldAccessorsInitialized(
ResponseProtocol.class, Builder.class);
}
// Construct using com.crossoverjie.netty.action.protocol.BaseResponseProto.ResponseProtocol.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
public Builder clear() {
super.clear();
responseId_ = 0;
bitField0_ = (bitField0_ & ~0x00000001);
resMsg_ = "";
bitField0_ = (bitField0_ & ~0x00000002);
return this;
}
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return BaseResponseProto.internal_static_protocol_ResponseProtocol_descriptor;
}
public ResponseProtocol getDefaultInstanceForType() {
return ResponseProtocol.getDefaultInstance();
}
public ResponseProtocol build() {
ResponseProtocol result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
public ResponseProtocol buildPartial() {
ResponseProtocol result = new ResponseProtocol(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
to_bitField0_ |= 0x00000001;
}
result.responseId_ = responseId_;
if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
to_bitField0_ |= 0x00000002;
}
result.resMsg_ = resMsg_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
}
public Builder clone() {
return (Builder) super.clone();
}
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.setField(field, value);
}
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return (Builder) super.clearField(field);
}
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return (Builder) super.clearOneof(oneof);
}
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return (Builder) super.setRepeatedField(field, index, value);
}
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return (Builder) super.addRepeatedField(field, value);
}
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof ResponseProtocol) {
return mergeFrom((ResponseProtocol)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(ResponseProtocol other) {
if (other == ResponseProtocol.getDefaultInstance()) return this;
if (other.hasResponseId()) {
setResponseId(other.getResponseId());
}
if (other.hasResMsg()) {
bitField0_ |= 0x00000002;
resMsg_ = other.resMsg_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
public final boolean isInitialized() {
if (!hasResponseId()) {
return false;
}
if (!hasResMsg()) {
return false;
}
return true;
}
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
ResponseProtocol parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (ResponseProtocol) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
private int responseId_ ;
/**
* <code>required int32 responseId = 2;</code>
*/
public boolean hasResponseId() {
return ((bitField0_ & 0x00000001) == 0x00000001);
}
/**
* <code>required int32 responseId = 2;</code>
*/
public int getResponseId() {
return responseId_;
}
/**
* <code>required int32 responseId = 2;</code>
*/
public Builder setResponseId(int value) {
bitField0_ |= 0x00000001;
responseId_ = value;
onChanged();
return this;
}
/**
* <code>required int32 responseId = 2;</code>
*/
public Builder clearResponseId() {
bitField0_ = (bitField0_ & ~0x00000001);
responseId_ = 0;
onChanged();
return this;
}
private Object resMsg_ = "";
/**
* <code>required string resMsg = 1;</code>
*/
public boolean hasResMsg() {
return ((bitField0_ & 0x00000002) == 0x00000002);
}
/**
* <code>required string resMsg = 1;</code>
*/
public String getResMsg() {
Object ref = resMsg_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
if (bs.isValidUtf8()) {
resMsg_ = s;
}
return s;
} else {
return (String) ref;
}
}
/**
* <code>required string resMsg = 1;</code>
*/
public com.google.protobuf.ByteString
getResMsgBytes() {
Object ref = resMsg_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
resMsg_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>required string resMsg = 1;</code>
*/
public Builder setResMsg(
String value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
resMsg_ = value;
onChanged();
return this;
}
/**
* <code>required string resMsg = 1;</code>
*/
public Builder clearResMsg() {
bitField0_ = (bitField0_ & ~0x00000002);
resMsg_ = getDefaultInstance().getResMsg();
onChanged();
return this;
}
/**
* <code>required string resMsg = 1;</code>
*/
public Builder setResMsgBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000002;
resMsg_ = value;
onChanged();
return this;
}
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:protocol.ResponseProtocol)
}
// @@protoc_insertion_point(class_scope:protocol.ResponseProtocol)
private static final ResponseProtocol DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new ResponseProtocol();
}
public static ResponseProtocol getDefaultInstance() {
return DEFAULT_INSTANCE;
}
@Deprecated public static final com.google.protobuf.Parser<ResponseProtocol>
PARSER = new com.google.protobuf.AbstractParser<ResponseProtocol>() {
public ResponseProtocol parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new ResponseProtocol(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<ResponseProtocol> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<ResponseProtocol> getParserForType() {
return PARSER;
}
public ResponseProtocol getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_protocol_ResponseProtocol_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_protocol_ResponseProtocol_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
String[] descriptorData = {
"\n\027BaseResponseProto.proto\022\010protocol\"6\n\020R" +
"esponseProtocol\022\022\n\nresponseId\030\002 \002(\005\022\016\n\006r" +
"esMsg\030\001 \002(\tB;\n&com.crossoverjie.netty.ac" +
"tion.protocolB\021BaseResponseProto"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_protocol_ResponseProtocol_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_protocol_ResponseProtocol_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_protocol_ResponseProtocol_descriptor,
new String[] { "ResponseId", "ResMsg", });
}
// @@protoc_insertion_point(outer_class_scope)
}
... ...
package com.crossoverjie.netty.action.common.protocol;
import com.google.protobuf.InvalidProtocolBufferException;
/**
* Function:
*
* @author crossoverJie
* Date: 2018/8/1 12:24
* @since JDK 1.8
*/
public class ProtocolUtil {
public static void main(String[] args) throws InvalidProtocolBufferException {
BaseRequestProto.RequestProtocol protocol = BaseRequestProto.RequestProtocol.newBuilder()
.setRequestId(123)
.setReqMsg("你好啊")
.build();
byte[] encode = encode(protocol);
BaseRequestProto.RequestProtocol parseFrom = decode(encode);
System.out.println(protocol.toString());
System.out.println(protocol.toString().equals(parseFrom.toString()));
}
/**
* 编码
* @param protocol
* @return
*/
public static byte[] encode(BaseRequestProto.RequestProtocol protocol){
return protocol.toByteArray() ;
}
/**
* 解码
* @param bytes
* @return
* @throws InvalidProtocolBufferException
*/
public static BaseRequestProto.RequestProtocol decode(byte[] bytes) throws InvalidProtocolBufferException {
return BaseRequestProto.RequestProtocol.parseFrom(bytes);
}
}
... ...
... ... @@ -22,6 +22,12 @@
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>com.crossoverjie.netty</groupId>
<artifactId>netty-action-common</artifactId>
... ...
... ... @@ -2,7 +2,9 @@ package com.crossoverjie.netty.action.client;
import com.alibaba.fastjson.JSON;
import com.crossoverjie.netty.action.client.init.CustomerHandleInitializer;
import com.crossoverjie.netty.action.client.vo.req.GoogleProtocolVO;
import com.crossoverjie.netty.action.common.pojo.CustomProtocol;
import com.crossoverjie.netty.action.common.protocol.BaseRequestProto;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
... ... @@ -81,4 +83,23 @@ public class HeartbeatClient {
LOGGER.info("客户端手动发消息成功={}", msg));
}
/**
* 发送 Google Protocol 编解码字符串
*
* @param googleProtocolVO
*/
public void sendGoogleProtocolMsg(GoogleProtocolVO googleProtocolVO) {
BaseRequestProto.RequestProtocol protocol = BaseRequestProto.RequestProtocol.newBuilder()
.setRequestId(googleProtocolVO.getRequestId())
.setReqMsg(googleProtocolVO.getMsg())
.build();
ChannelFuture future = channel.writeAndFlush(protocol);
future.addListener((ChannelFutureListener) channelFuture ->
LOGGER.info("客户端手动发送 Google Protocol 成功={}", googleProtocolVO.toString()));
}
}
... ...
package com.crossoverjie.netty.action.client.controller;
import com.crossoverjie.netty.action.client.HeartbeatClient;
import com.crossoverjie.netty.action.client.vo.req.GoogleProtocolVO;
import com.crossoverjie.netty.action.client.vo.req.SendMsgReqVO;
import com.crossoverjie.netty.action.client.vo.req.StringReqVO;
import com.crossoverjie.netty.action.client.vo.res.SendMsgResVO;
... ... @@ -82,4 +83,29 @@ public class IndexController {
res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
return res ;
}
/**
* 向服务端发消息 Google ProtoBuf
* @param googleProtocolVO
* @return
*/
@ApiOperation("向服务端发消息 Google ProtoBuf")
@RequestMapping(value = "sendProtoBufMsg", method = RequestMethod.POST)
@ResponseBody
public BaseResponse<NULLBody> sendProtoBufMsg(@RequestBody GoogleProtocolVO googleProtocolVO){
BaseResponse<NULLBody> res = new BaseResponse();
for (int i=0 ;i <100 ;i++){
heartbeatClient.sendGoogleProtocolMsg(googleProtocolVO) ;
}
// 利用 actuator 来自增
counterService.increment(Constants.COUNTER_CLIENT_PUSH_COUNT);
SendMsgResVO sendMsgResVO = new SendMsgResVO() ;
sendMsgResVO.setMsg("OK") ;
res.setCode(StatusEnum.SUCCESS.getCode()) ;
res.setMessage(StatusEnum.SUCCESS.getMessage()) ;
return res ;
}
}
... ...
package com.crossoverjie.netty.action.client.init;
import com.crossoverjie.netty.action.client.encode.HeartbeatEncode;
import com.crossoverjie.netty.action.client.handle.EchoClientHandle;
import com.crossoverjie.netty.action.common.protocol.BaseResponseProto;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
import io.netty.handler.timeout.IdleStateHandler;
/**
... ... @@ -19,7 +23,19 @@ public class CustomerHandleInitializer extends ChannelInitializer<Channel> {
ch.pipeline()
//10 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中
.addLast(new IdleStateHandler(0, 10, 0))
.addLast(new HeartbeatEncode())
//心跳解码
//.addLast(new HeartbeatEncode())
// google Protobuf 编解码
//拆包解码
.addLast(new ProtobufVarint32FrameDecoder())
.addLast(new ProtobufDecoder(BaseResponseProto.ResponseProtocol.getDefaultInstance()))
//拆包编码
.addLast(new ProtobufVarint32LengthFieldPrepender())
.addLast(new ProtobufEncoder())
.addLast(new EchoClientHandle())
;
}
... ...
package com.crossoverjie.netty.action.client.vo.req;
import com.crossoverjie.netty.action.common.req.BaseRequest;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
/**
* Function: Google Protocol 编解码发送
*
* @author crossoverJie
* Date: 2018/05/21 15:56
* @since JDK 1.8
*/
public class GoogleProtocolVO extends BaseRequest {
@NotNull(message = "requestId 不能为空")
@ApiModelProperty(required = true, value = "requestId", example = "123")
private Integer requestId ;
@NotNull(message = "msg 不能为空")
@ApiModelProperty(required = true, value = "msg", example = "hello")
private String msg ;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Integer getRequestId() {
return requestId;
}
public void setRequestId(Integer requestId) {
this.requestId = requestId;
}
@Override
public String toString() {
return "GoogleProtocolVO{" +
"requestId=" + requestId +
", msg='" + msg + '\'' +
"} " + super.toString();
}
}
... ...
... ... @@ -22,6 +22,11 @@
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</dependency>
<dependency>
<groupId>com.crossoverjie.netty</groupId>
<artifactId>netty-action-common</artifactId>
</dependency>
... ...
package com.crossoverjie.netty.action.handle;
import com.crossoverjie.netty.action.common.pojo.CustomProtocol;
import com.crossoverjie.netty.action.common.protocol.BaseRequestProto;
import com.crossoverjie.netty.action.util.NettySocketHolder;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
... ... @@ -18,7 +19,7 @@ import org.slf4j.LoggerFactory;
* Date: 17/05/2018 18:52
* @since JDK 1.8
*/
public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<String> {
public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<BaseRequestProto.RequestProtocol> {
private final static Logger LOGGER = LoggerFactory.getLogger(HeartBeatSimpleHandle.class);
... ... @@ -55,8 +56,8 @@ public class HeartBeatSimpleHandle extends SimpleChannelInboundHandler<String> {
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
LOGGER.info("收到msg={}", msg);
protected void channelRead0(ChannelHandlerContext ctx, BaseRequestProto.RequestProtocol msg) throws Exception {
LOGGER.info("收到msg={}", msg.getReqMsg());
//保存客户端与 Channel 之间的关系
//NettySocketHolder.put(CustomProtocolProtocol.getId(),(NioSocketChannel)ctx.channel()) ;
... ...
package com.crossoverjie.netty.action.init;
import com.crossoverjie.netty.action.common.protocol.BaseRequestProto;
import com.crossoverjie.netty.action.handle.HeartBeatSimpleHandle;
import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.handler.codec.LineBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.protobuf.ProtobufDecoder;
import io.netty.handler.codec.protobuf.ProtobufEncoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder;
import io.netty.handler.codec.protobuf.ProtobufVarint32LengthFieldPrepender;
import io.netty.handler.timeout.IdleStateHandler;
/**
... ... @@ -21,8 +24,17 @@ public class HeartbeatInitializer extends ChannelInitializer<Channel> {
//五秒没有收到消息 将IdleStateHandler 添加到 ChannelPipeline 中
.addLast(new IdleStateHandler(5, 0, 0))
//.addLast(new HeartbeatDecoder())
.addLast(new LineBasedFrameDecoder(1024))
.addLast(new StringDecoder())
//字符串解析,换行防拆包
//.addLast(new LineBasedFrameDecoder(1024))
//.addLast(new StringDecoder())
// google Protobuf 编解码
.addLast(new ProtobufVarint32FrameDecoder())
.addLast(new ProtobufDecoder(BaseRequestProto.RequestProtocol.getDefaultInstance()))
.addLast(new ProtobufVarint32LengthFieldPrepender())
.addLast(new ProtobufEncoder())
.addLast(new HeartBeatSimpleHandle());
}
}
... ...
... ... @@ -43,6 +43,13 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
... ...