mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-24 09:32:49 +01:00
java: edit MessagePack.java for TemplateProvider
This commit is contained in:
parent
39ad071c4f
commit
b73ca1ba3a
java/src/main/java/org/msgpack
@ -156,7 +156,17 @@ public class MessagePack {
|
|||||||
//} else if(Collection.isAssignableFrom(target)) {
|
//} else if(Collection.isAssignableFrom(target)) {
|
||||||
//} else if(BigInteger.isAssignableFrom(target)) {
|
//} else if(BigInteger.isAssignableFrom(target)) {
|
||||||
} else {
|
} else {
|
||||||
tmpl = DynamicTemplate.create(target);
|
if (MessagePackTemplateProvider.class.isAssignableFrom(target)) {
|
||||||
|
try {
|
||||||
|
tmpl = ((MessagePackTemplateProvider) target.newInstance()).getTemplate();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tmpl = DynamicTemplate.create(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomPacker.register(target, tmpl);
|
CustomPacker.register(target, tmpl);
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for Java
|
||||||
|
//
|
||||||
|
// Copyright (C) 2009-2010 FURUHASHI Sadayuki
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
package org.msgpack;
|
||||||
|
|
||||||
|
public interface MessagePackTemplateProvider {
|
||||||
|
|
||||||
|
Template getTemplate();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user