mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-20 13:33:51 +01:00
java: rollback MessagePack.java
This commit is contained in:
parent
b5617f7df9
commit
dd452b05e3
@ -161,21 +161,11 @@ public class MessagePack {
|
||||
} else {
|
||||
if (MessagePackTemplateProvider.class.isAssignableFrom(target)) {
|
||||
try {
|
||||
Method m = target.getMethod("getTemplate", new Class[0]);
|
||||
tmpl = (Template)m.invoke(null, new Object[0]);
|
||||
tmpl = ((MessagePackTemplateProvider) target.newInstance()).getTemplate();
|
||||
} catch (InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (SecurityException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} else {
|
||||
tmpl = DynamicTemplate.create(target);
|
||||
@ -187,6 +177,22 @@ public class MessagePack {
|
||||
CustomUnpacker.register(target, tmpl);
|
||||
}
|
||||
|
||||
public static class Foo implements MessagePackTemplateProvider {
|
||||
public int f1;
|
||||
|
||||
public int f2;
|
||||
|
||||
public Foo() {}
|
||||
|
||||
public Template getTemplate() {
|
||||
return DynamicTemplate.create(Foo.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
MessagePack.register(Foo.class);
|
||||
}
|
||||
|
||||
public static void register(Class<?> target, FieldList opts) {
|
||||
Template tmpl = DynamicTemplate.create(target, opts);
|
||||
CustomPacker.register(target, tmpl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user