Search in sources :

Example 1 with SchemaWriter

use of io.protostuff.SchemaWriter 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);
    };
}
Also used : SchemaWriter(io.protostuff.SchemaWriter) WireFormat(io.protostuff.WireFormat) OutputEx(io.protostuff.OutputEx) SchemaEx(io.protostuff.SchemaEx) ProtoMapper(org.apache.servicecomb.foundation.protobuf.ProtoMapper) IOException(java.io.IOException) InputEx(io.protostuff.InputEx) Type(java.lang.reflect.Type) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory) ProtoConst(org.apache.servicecomb.foundation.protobuf.internal.ProtoConst) Map(java.util.Map) RootDeserializer(org.apache.servicecomb.foundation.protobuf.RootDeserializer) Message(io.protostuff.compiler.model.Message) ConcurrentHashMapEx(org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx) JavaType(com.fasterxml.jackson.databind.JavaType) RootSerializer(org.apache.servicecomb.foundation.protobuf.RootSerializer) PropertyWrapper(org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyWrapper) Message(io.protostuff.compiler.model.Message) RootSerializer(org.apache.servicecomb.foundation.protobuf.RootSerializer)

Example 2 with SchemaWriter

use of io.protostuff.SchemaWriter in project incubator-servicecomb-java-chassis by apache.

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);
    };
}
Also used : SchemaWriter(io.protostuff.SchemaWriter) WireFormat(io.protostuff.WireFormat) OutputEx(io.protostuff.OutputEx) SchemaEx(io.protostuff.SchemaEx) ProtoMapper(org.apache.servicecomb.foundation.protobuf.ProtoMapper) IOException(java.io.IOException) InputEx(io.protostuff.InputEx) Type(java.lang.reflect.Type) TypeFactory(com.fasterxml.jackson.databind.type.TypeFactory) ProtoConst(org.apache.servicecomb.foundation.protobuf.internal.ProtoConst) Map(java.util.Map) RootDeserializer(org.apache.servicecomb.foundation.protobuf.RootDeserializer) Message(io.protostuff.compiler.model.Message) ConcurrentHashMapEx(org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx) JavaType(com.fasterxml.jackson.databind.JavaType) RootSerializer(org.apache.servicecomb.foundation.protobuf.RootSerializer) PropertyWrapper(org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyWrapper) Message(io.protostuff.compiler.model.Message) RootSerializer(org.apache.servicecomb.foundation.protobuf.RootSerializer)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)2 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)2 InputEx (io.protostuff.InputEx)2 OutputEx (io.protostuff.OutputEx)2 SchemaEx (io.protostuff.SchemaEx)2 SchemaWriter (io.protostuff.SchemaWriter)2 WireFormat (io.protostuff.WireFormat)2 Message (io.protostuff.compiler.model.Message)2 IOException (java.io.IOException)2 Type (java.lang.reflect.Type)2 Map (java.util.Map)2 ConcurrentHashMapEx (org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx)2 ProtoMapper (org.apache.servicecomb.foundation.protobuf.ProtoMapper)2 RootDeserializer (org.apache.servicecomb.foundation.protobuf.RootDeserializer)2 RootSerializer (org.apache.servicecomb.foundation.protobuf.RootSerializer)2 ProtoConst (org.apache.servicecomb.foundation.protobuf.internal.ProtoConst)2 PropertyWrapper (org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyWrapper)2