本文整理汇总了Java中org.msgpack.template.Template类的典型用法代码示例。如果您正苦于以下问题:Java Template类的具体用法?Java Template怎么用?Java Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Template类属于org.msgpack.template包,在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: unmarshall
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <T> T unmarshall(final Type type, final Response response) throws IOException {
final int statusCode = response.getStatusCode();
if (statusCode < 200 || statusCode >= 300) {
log.debug("request fail, status code: {}", statusCode, response);
throw new IOException("Call failed for url: " + response.getUrl() + ", status code: " + statusCode + ".\n" +
response.getResponseBody());
}
if (HttpResponseStatus.NO_CONTENT.code() == statusCode || !response.hasResponseBody()) {
// on empty body the object mapper throws "JsonMappingException: No content to map due to end-of-input"
return null;
}
final Value value = messagePack.read(response.getResponseBodyAsBytes());
final Template<T> template = (Template<T>) messagePack.lookup(type);
return template.read(new Converter(messagePack, value), null);
}
开发者ID:outbrain,项目名称:ob1k,代码行数:22,代码来源:MessagePackMarshallingStrategy.java
示例2: testReferenceTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestReflectionBeansBufferPackConvert.java
示例3: testUserDefinedTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testUserDefinedTypeFieldsClass(UserDefinedTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<UserDefinedTypeFieldsClass> tmpl = builder.buildTemplate(UserDefinedTypeFieldsClass.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
UserDefinedTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistPackConvert.java
示例4: testListTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testListTypeFieldsClassNotNullable(ListTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ListTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ListTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ListTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistBufferPackConvert.java
示例5: testListTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testListTypeFieldsClassNotNullable(ListTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<ListTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ListTypeFieldsClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ListTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBeansBufferPackBufferUnpack.java
示例6: testMessagePackableTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testMessagePackableTypeFieldsClass(MessagePackableTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<MessagePackableTypeFieldsClass> tmpl = builder.buildTemplate(MessagePackableTypeFieldsClass.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
MessagePackableTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:20,代码来源:TestReflectionBeansPackConvert.java
示例7: testReferenceTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
unpacker.resetReadByteCount();
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestJavassistPackUnpack.java
示例8: testModifiersFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testModifiersFieldsClass(ModifiersFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ModifiersFieldsClass> tmpl = builder.buildTemplate(ModifiersFieldsClass.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ModifiersFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistPackConvert.java
示例9: testUserDefinedTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testUserDefinedTypeFieldsClassNotNullable(UserDefinedTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<UserDefinedTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(UserDefinedTypeFieldsClassNotNullable.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
UserDefinedTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:20,代码来源:TestReflectionPackConvert.java
示例10: testReferenceCycleTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testReferenceCycleTypeFieldsClass(ReferenceCycleTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ReferenceCycleTypeFieldsClass> tmpl = builder.buildTemplate(ReferenceCycleTypeFieldsClass.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceCycleTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistPackConvert.java
示例11: testFinalClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testFinalClass(FinalClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<FinalClass> tmpl = builder.buildTemplate(FinalClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
FinalClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistBufferPackConvert.java
示例12: testReferenceCycleTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testReferenceCycleTypeFieldsClass(ReferenceCycleTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<ReferenceCycleTypeFieldsClass> tmpl = builder.buildTemplate(ReferenceCycleTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ReferenceCycleTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBufferPackBufferUnpack.java
示例13: testReferenceTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testReferenceTypeFieldsClass(ReferenceTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ReferenceTypeFieldsClass> tmpl = builder.buildTemplate(ReferenceTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
ReferenceTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistBufferPackConvert.java
示例14: testMapTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testMapTypeFieldsClass(MapTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionTemplateBuilder builder = new ReflectionTemplateBuilder(registry);
Template<MapTypeFieldsClass> tmpl = builder.buildTemplate(MapTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
MapTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestReflectionBufferPackConvert.java
示例15: testUserDefinedTypeFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testUserDefinedTypeFieldsClass(UserDefinedTypeFieldsClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<UserDefinedTypeFieldsClass> tmpl = builder.buildTemplate(UserDefinedTypeFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker u = msgpack.createBufferUnpacker();
u.resetReadByteCount();
u.wrap(bytes);
Value value = u.readValue();
Converter unpacker = new Converter(value);
UserDefinedTypeFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, u.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:19,代码来源:TestJavassistBufferPackConvert.java
示例16: testInheritanceClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testInheritanceClass(InheritanceClass v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<InheritanceClass> tmpl = builder.buildTemplate(InheritanceClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
InheritanceClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBeansBufferPackBufferUnpack.java
示例17: testModifiersFieldsClass
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testModifiersFieldsClass(ModifiersFieldsClass v)
throws Exception {
System.getProperties().setProperty(TemplatePrecompiler.DEST,
"./target/test-classes");
MessagePack msgpack = new MessagePack();
try {
TemplatePrecompiler.saveTemplateClass(new TemplateRegistry(null),
ModifiersFieldsClass.class);
Template<ModifiersFieldsClass> tmpl = msgpack
.lookup(ModifiersFieldsClass.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.wrap(bytes);
ModifiersFieldsClass ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
} finally {
TemplatePrecompiler.deleteTemplateClass(ModifiersFieldsClass.class);
msgpack.unregister(ModifiersFieldsClass.class);
}
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:24,代码来源:TestTemplatePreCompilerBufferPackBufferUnpack.java
示例18: testInheritanceClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testInheritanceClassNotNullable(InheritanceClassNotNullable v)
throws Exception {
System.getProperties().setProperty(TemplatePrecompiler.DEST,
"./target/test-classes");
MessagePack msgpack = new MessagePack();
try {
TemplatePrecompiler.saveTemplateClass(new TemplateRegistry(null),
InheritanceClassNotNullable.class);
Template<InheritanceClassNotNullable> tmpl = msgpack
.lookup(InheritanceClassNotNullable.class);
BufferPacker packer = msgpack.createBufferPacker();
tmpl.write(packer, v);
byte[] bytes = packer.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.wrap(bytes);
InheritanceClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
} finally {
TemplatePrecompiler
.deleteTemplateClass(InheritanceClassNotNullable.class);
msgpack.unregister(InheritanceClassNotNullable.class);
}
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:25,代码来源:TestTemplatePreCompilerBufferPackBufferUnpack.java
示例19: testPrimitiveTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testPrimitiveTypeFieldsClassNotNullable(PrimitiveTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
ReflectionBeansTemplateBuilder builder = new ReflectionBeansTemplateBuilder(registry);
Template<PrimitiveTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(PrimitiveTypeFieldsClassNotNullable.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
Unpacker unpacker = msgpack.createUnpacker(new ByteArrayInputStream(bytes));
unpacker.resetReadByteCount();
PrimitiveTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:17,代码来源:TestReflectionBeansPackUnpack.java
示例20: testReferenceTypeFieldsClassNotNullable
import org.msgpack.template.Template; //导入依赖的package包/类
@Override
public void testReferenceTypeFieldsClassNotNullable(ReferenceTypeFieldsClassNotNullable v) throws Exception {
MessagePack msgpack = new MessagePack();
TemplateRegistry registry = new TemplateRegistry(null);
JavassistTemplateBuilder builder = new JavassistTemplateBuilder(registry);
Template<ReferenceTypeFieldsClassNotNullable> tmpl = builder.buildTemplate(ReferenceTypeFieldsClassNotNullable.class);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Packer packer = msgpack.createPacker(out);
tmpl.write(packer, v);
byte[] bytes = out.toByteArray();
BufferUnpacker unpacker = msgpack.createBufferUnpacker();
unpacker.resetReadByteCount();
unpacker.wrap(bytes);
ReferenceTypeFieldsClassNotNullable ret = tmpl.read(unpacker, null);
assertEquals(v, ret);
assertEquals(bytes.length, unpacker.getReadByteCount());
}
开发者ID:nict-wisdom,项目名称:rasc,代码行数:18,代码来源:TestJavassistPackBufferUnpack.java
注:本文中的org.msgpack.template.Template类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论