Search in sources :

Example 1 with StandardObjectReader

use of org.apache.servicecomb.codec.protobuf.jackson.StandardObjectReader in project incubator-servicecomb-java-chassis by apache.

the class StandardParamCodec method init.

@Override
public void init(ProtobufSchema schema, Type... types) {
    writer = ProtobufManager.getMapper().writer(schema);
    reader = ProtobufManager.getMapper().reader(schema);
    // 需要考虑没参数的场景
    if (types.length == 1) {
        JavaType javaType = TypeFactory.defaultInstance().constructType(types[0]);
        writer = new StandardObjectWriter(writer.forType(javaType));
        reader = new StandardObjectReader(reader.forType(javaType));
    }
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) StandardObjectWriter(org.apache.servicecomb.codec.protobuf.jackson.StandardObjectWriter) StandardObjectReader(org.apache.servicecomb.codec.protobuf.jackson.StandardObjectReader)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)1 StandardObjectReader (org.apache.servicecomb.codec.protobuf.jackson.StandardObjectReader)1 StandardObjectWriter (org.apache.servicecomb.codec.protobuf.jackson.StandardObjectWriter)1