use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.
the class AbstractFieldCodec method initFieldMap.
private void initFieldMap(ProtobufSchema schema, Type[] types) {
Iterator<ProtobufField> fieldIter = schema.getRootType().fields().iterator();
for (int idx = 0; idx < schema.getRootType().getFieldCount(); idx++) {
JavaType type = TypeFactory.defaultInstance().constructType(types[idx]);
ProtobufField field = fieldIter.next();
ReaderHelpData helpData = new ReaderHelpData();
helpData.index = idx;
helpData.deser = ((CseObjectReader) reader).findDeserializer(type);
readerHelpDataMap.put(field.name, helpData);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.
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));
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.
the class ResponseMeta method init.
public void init(ClassLoader classLoader, String packageName, Swagger swagger, Response response) {
if (javaType == null) {
Property property = response.getSchema();
javaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, property);
}
if (response.getHeaders() == null) {
return;
}
for (Entry<String, Property> entry : response.getHeaders().entrySet()) {
JavaType headerJavaType = ConverterMgr.findJavaType(classLoader, packageName, swagger, entry.getValue());
headers.put(entry.getKey(), headerJavaType);
}
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.
the class QueryProcessorCreator method create.
@Override
public ParamValueProcessor create(String paramValue, Type genericParamType) {
JavaType targetType = TypeFactory.defaultInstance().constructType(genericParamType);
Class<?> rawCls = targetType.getRawClass();
boolean isArrayOrCollection = rawCls.isArray() || Collection.class.isAssignableFrom(rawCls);
return new QueryProcessor(paramValue, targetType, isArrayOrCollection);
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.
the class TestProduce method testProduce.
/**
* Test Produce
*
* @throws Exception
*/
@Test
public void testProduce() throws Exception {
Assert.assertEquals("produce processor mgr", ProduceProcessorManager.INSTANCE.getName());
Buffer oBuffer = ProduceProcessorManager.DEFAULT_PROCESSOR.encodeResponse("test");
OutputStream oOutputStream = new BufferOutputStream();
ProduceProcessorManager.DEFAULT_PROCESSOR.encodeResponse(oOutputStream, "test2");
JavaType targetType = TypeFactory.defaultInstance().constructType(String.class);
InputStream oInputStream = new ByteArrayInputStream(("true").getBytes());
ProduceProcessorManager.DEFAULT_PROCESSOR.decodeResponse(oInputStream, targetType);
ProduceProcessorManager.PLAIN_PROCESSOR.encodeResponse(new BufferOutputStream(), "test2");
Assert.assertNotEquals(null, ProduceProcessorManager.PLAIN_PROCESSOR.decodeResponse(oInputStream, targetType));
oInputStream = new ByteArrayInputStream(("true").getBytes());
Assert.assertNotEquals(null, ProduceProcessorManager.DEFAULT_PROCESSOR.decodeResponse(oInputStream, targetType));
ProduceProcessorManager.DEFAULT_PROCESSOR.decodeResponse(oBuffer, targetType);
Assert.assertEquals(null, ProduceProcessorManager.DEFAULT_PROCESSOR.encodeResponse(null));
}
Aggregations