use of io.protostuff.compiler.model.Message in project java-chassis by ServiceComb.
the class OperationProtobuf method initRequestCodec.
private void initRequestCodec(ScopedProtobufSchemaManager scopedProtobufSchemaManager, Invocation invocation) {
ProtoMapper mapper = scopedProtobufSchemaManager.getOrCreateProtoMapper(invocation.getSchemaMeta());
Message requestMessage = mapper.getRequestMessage(invocation.getOperationMeta().getOperationId());
if (!invocation.isConsumer()) {
initProducerRequestCodec(invocation, requestMessage, mapper);
} else {
initConsumerRequestCodec(invocation, requestMessage, mapper);
}
}
use of io.protostuff.compiler.model.Message in project java-chassis by ServiceComb.
the class AnyEntrySchema method createEntryWriter.
private SchemaWriter<Object> createEntryWriter(String actualTypeName, Object _value) {
Message message = protoMapper.getProto().getMessage(actualTypeName);
if (message == null) {
// not standard, protobuf can not support or not define this type , just extend
return this::jsonExtend;
}
// standard pack
RootSerializer valueSerializer = protoMapper.createRootSerializer(message, _value.getClass());
String valueCanonicalName = message.getCanonicalName();
return (output, value) -> {
standardPack(output, value, valueCanonicalName, valueSerializer);
};
}
use of io.protostuff.compiler.model.Message in project java-chassis by ServiceComb.
the class ProtoToStringGenerator method protoToString.
public String protoToString() {
StringBuilder sb = new StringBuilder();
appendLine(sb, "syntax = \"%s\";", proto.getSyntax());
for (Import importValue : proto.getImports()) {
appendLine(sb, "import \"%s\";", importValue.getValue());
}
appendLine(sb, "package %s;\n", proto.getPackage().getValue());
for (Message message : proto.getMessages()) {
messageToString(message, sb);
}
for (Enum enumValue : proto.getEnums()) {
enumToString(enumValue, sb);
}
for (Service service : proto.getServices()) {
serviceToString(service, sb);
}
return sb.toString();
}
use of io.protostuff.compiler.model.Message in project java-chassis by ServiceComb.
the class ProtoToStringGenerator method fieldMapToString.
private void fieldMapToString(Field field, StringBuilder sb) {
Message entryMessage = (Message) field.getType();
Field keyField = entryMessage.getField(1);
Field valueField = entryMessage.getField(2);
// map<string, string> name = 1;
appendLine(sb, "map<%s, %s> %s = %d;", keyField.getTypeName(), valueField.getTypeName(), field.getName(), field.getTag());
}
use of io.protostuff.compiler.model.Message in project incubator-servicecomb-java-chassis by apache.
the class OperationProtobuf method initRequestCodec.
private void initRequestCodec(ScopedProtobufSchemaManager scopedProtobufSchemaManager, Invocation invocation) {
ProtoMapper mapper = scopedProtobufSchemaManager.getOrCreateProtoMapper(invocation.getSchemaMeta());
Message requestMessage = mapper.getRequestMessage(invocation.getOperationMeta().getOperationId());
if (!invocation.isConsumer()) {
initProducerRequestCodec(invocation, requestMessage, mapper);
} else {
initConsumerRequestCodec(invocation, requestMessage, mapper);
}
}
Aggregations