diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectDeserializer.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectDeserializer.java deleted file mode 100644 index 42654a66..00000000 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectDeserializer.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.jd.blockchain.crypto.serialize; - -import com.alibaba.fastjson.parser.DefaultJSONParser; -import com.alibaba.fastjson.parser.JSONToken; -import com.alibaba.fastjson.parser.ParserConfig; -import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer; -import com.jd.blockchain.crypto.HashDigest; -import com.jd.blockchain.crypto.PubKey; -import com.jd.blockchain.crypto.SignatureDigest; -import com.jd.blockchain.utils.Bytes; -import com.jd.blockchain.utils.codec.Base58Utils; -import com.jd.blockchain.utils.io.BytesSlice; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Type; -import java.util.Map; - -public class ByteArrayObjectDeserializer extends JavaBeanDeserializer { - - private ByteArrayObjectDeserializer(Class clazz) { - super(ParserConfig.global, clazz); - } - - public static ByteArrayObjectDeserializer getInstance(Class clazz) { - return new ByteArrayObjectDeserializer(clazz); - } - - @SuppressWarnings("unchecked") - @Override - public T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { - if (type instanceof Class && clazz.isAssignableFrom((Class) type)) { - String base58Str = parser.parseObject(String.class); - byte[] hashBytes = Base58Utils.decode(base58Str); - if (clazz == HashDigest.class) { - return (T) new HashDigest(hashBytes); - } else if (clazz == PubKey.class) { - return (T) new HashDigest(hashBytes); - } else if (clazz == SignatureDigest.class) { - return (T) new SignatureDigest(hashBytes); - } else if (clazz == Bytes.class) { - return (T) new Bytes(hashBytes); - } else if (clazz == BytesSlice.class) { - return (T) new BytesSlice(hashBytes); - } - } - return (T) parser.parse(fieldName); - } - - @Override - public Object createInstance(Map map, ParserConfig config) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - if (map == null || map.isEmpty()) { - return null; - } - for (Map.Entry entry : map.entrySet()) { - Object value = entry.getValue(); - if (value instanceof String) { - byte[] hashBytes = Base58Utils.decode((String)value); - if (clazz == HashDigest.class) { - return new HashDigest(hashBytes); - } else if (clazz == PubKey.class) { - return new PubKey(hashBytes); - } else if (clazz == SignatureDigest.class) { - return new SignatureDigest(hashBytes); - } else if (clazz == Bytes.class) { - return new Bytes(hashBytes); - } else if (clazz == BytesSlice.class) { - return new BytesSlice(hashBytes); - } - } - } - return null; - } - - @Override - public int getFastMatchToken() { - return JSONToken.LBRACE; - } -} diff --git a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectSerializer.java b/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectSerializer.java deleted file mode 100644 index 282605ed..00000000 --- a/source/crypto/crypto-framework/src/main/java/com/jd/blockchain/crypto/serialize/ByteArrayObjectSerializer.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.jd.blockchain.crypto.serialize; - -import java.lang.reflect.Type; - -import com.alibaba.fastjson.serializer.JSONSerializer; -import com.alibaba.fastjson.serializer.ObjectSerializer; -import com.jd.blockchain.crypto.HashDigest; -import com.jd.blockchain.crypto.PubKey; -import com.jd.blockchain.crypto.SignatureDigest; -import com.jd.blockchain.utils.Bytes; -import com.jd.blockchain.utils.io.BytesSlice; - -public class ByteArrayObjectSerializer implements ObjectSerializer { - - private Class clazz; - - private ByteArrayObjectSerializer(Class clazz) { - this.clazz = clazz; - } - - public static ByteArrayObjectSerializer getInstance(Class clazz) { - return new ByteArrayObjectSerializer(clazz); - } - - @Override - public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) { - if (object.getClass() != clazz) { - serializer.writeNull(); - return; - } - if (object instanceof HashDigest) { - serializer.write(new HashDigestJson(((HashDigest) object).toBase58())); - } else if (object instanceof PubKey) { - serializer.write(new HashDigestJson(((PubKey) object).toBase58())); - } else if (object instanceof SignatureDigest) { - serializer.write(new HashDigestJson(((SignatureDigest) object).toBase58())); - } else if (object instanceof Bytes) { - serializer.write(new HashDigestJson(((Bytes) object).toBase58())); - } else if (object instanceof BytesSlice) { - byte[] bytes = ((BytesSlice) object).toBytes(); - serializer.write(new HashDigestJson(new String(bytes))); - } - } - - private static class HashDigestJson { - - String value; - - public HashDigestJson(String value) { - this.value = value; - } - - @SuppressWarnings("unused") - public String getValue() { - return value; - } - - @SuppressWarnings("unused") - public void setValue(String value) { - this.value = value; - } - } -} diff --git a/source/gateway/src/main/java/com/jd/blockchain/gateway/web/GatewayWebServerConfigurer.java b/source/gateway/src/main/java/com/jd/blockchain/gateway/web/GatewayWebServerConfigurer.java index 5174950e..b93a8008 100644 --- a/source/gateway/src/main/java/com/jd/blockchain/gateway/web/GatewayWebServerConfigurer.java +++ b/source/gateway/src/main/java/com/jd/blockchain/gateway/web/GatewayWebServerConfigurer.java @@ -2,7 +2,7 @@ package com.jd.blockchain.gateway.web; import java.util.List; -import com.jd.blockchain.utils.io.BytesSlice; +import com.jd.blockchain.web.serializes.ByteArrayObjectUtil; import org.springframework.context.annotation.Configuration; import org.springframework.format.FormatterRegistry; import org.springframework.http.converter.HttpMessageConverter; @@ -11,12 +11,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import com.jd.blockchain.crypto.HashDigest; -import com.jd.blockchain.crypto.PubKey; -import com.jd.blockchain.crypto.SignatureDigest; -import com.jd.blockchain.crypto.serialize.ByteArrayObjectDeserializer; -import com.jd.blockchain.crypto.serialize.ByteArrayObjectSerializer; -import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.io.ByteArray; import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter; @@ -30,13 +24,6 @@ import com.jd.blockchain.web.converters.HashDigestInputConverter; @Configuration public class GatewayWebServerConfigurer implements WebMvcConfigurer { - private static final Class[] BYTEARRAY_JSON_SERIALIZE_CLASS = new Class[] { - HashDigest.class, - PubKey.class, - SignatureDigest.class, - Bytes.class, - BytesSlice.class}; - static { JSONSerializeUtils.disableCircularReferenceDetect(); JSONSerializeUtils.configStringSerializer(ByteArray.class); @@ -67,11 +54,11 @@ public class GatewayWebServerConfigurer implements WebMvcConfigurer { registry.addConverter(new HashDigestInputConverter()); } - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources"); - } + } @Override public void addViewControllers(ViewControllerRegistry registry) { @@ -79,10 +66,6 @@ public class GatewayWebServerConfigurer implements WebMvcConfigurer { } private void initByteArrayJsonSerialize() { - for (Class byteArrayClass : BYTEARRAY_JSON_SERIALIZE_CLASS) { - JSONSerializeUtils.configSerialization(byteArrayClass, - ByteArrayObjectSerializer.getInstance(byteArrayClass), - ByteArrayObjectDeserializer.getInstance(byteArrayClass)); - } + ByteArrayObjectUtil.init(); } } diff --git a/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonDeserializer.java b/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonDeserializer.java new file mode 100644 index 00000000..c0384183 --- /dev/null +++ b/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonDeserializer.java @@ -0,0 +1,101 @@ +package com.jd.blockchain.web.serializes; + +import com.alibaba.fastjson.parser.DefaultJSONParser; +import com.alibaba.fastjson.parser.JSONToken; +import com.alibaba.fastjson.parser.ParserConfig; +import com.alibaba.fastjson.parser.deserializer.JavaBeanDeserializer; +import com.jd.blockchain.crypto.HashDigest; +import com.jd.blockchain.crypto.PubKey; +import com.jd.blockchain.crypto.SignatureDigest; +import com.jd.blockchain.utils.Bytes; +import com.jd.blockchain.utils.codec.Base58Utils; +import com.jd.blockchain.utils.io.BytesSlice; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Type; +import java.util.Map; + +public class ByteArrayObjectJsonDeserializer extends JavaBeanDeserializer { + + private ByteArrayObjectJsonDeserializer(Class clazz) { + super(ParserConfig.global, clazz); + } + + public static ByteArrayObjectJsonDeserializer getInstance(Class clazz) { + return new ByteArrayObjectJsonDeserializer(clazz); + } + + @SuppressWarnings("unchecked") + @Override + public T deserialze(DefaultJSONParser parser, Type type, Object fieldName) { + if (type instanceof Class && clazz.isAssignableFrom((Class) type)) { + String parseText = parser.parseObject(String.class); + byte[] hashBytes = Base58Utils.decode(parseText); + if (clazz == HashDigest.class) { + return (T) new HashDigest(hashBytes); + } else if (clazz == PubKey.class) { + return (T) new HashDigest(hashBytes); + } else if (clazz == SignatureDigest.class) { + return (T) new SignatureDigest(hashBytes); + } else if (clazz == Bytes.class) { + return (T) new Bytes(hashBytes); + } else if (clazz == BytesSlice.class) { + return (T) new BytesSlice(hashBytes); + } + +// else if (clazz == BytesValue.class) { +// ByteArrayObjectJsonSerializer.BytesValueJson valueJson = JSON.parseObject(parseText, ByteArrayObjectJsonSerializer.BytesValueJson.class); +// DataType dataType = valueJson.getType(); +// Object dataVal = valueJson.getValue(); +// byte[] bytes = null; +// switch (dataType) { +// case BYTES: +// bytes = ByteArray.fromHex((String) dataVal); +// break; +// case TEXT: +// bytes = ((String) dataVal).getBytes(); +// break; +// case INT64: +// bytes = BytesUtils.toBytes((Long) dataVal); +// break; +// case JSON: +// bytes = ((String) dataVal).getBytes(); +// break; +// } +// BytesValue bytesValue = new BytesValueImpl(dataType, bytes); +// return (T) bytesValue; +// } + } + return (T) parser.parse(fieldName); + } + + @Override + public Object createInstance(Map map, ParserConfig config) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { + if (map == null || map.isEmpty()) { + return null; + } + for (Map.Entry entry : map.entrySet()) { + Object value = entry.getValue(); + if (value instanceof String) { + byte[] hashBytes = Base58Utils.decode((String) value); + if (clazz == HashDigest.class) { + return new HashDigest(hashBytes); + } else if (clazz == PubKey.class) { + return new PubKey(hashBytes); + } else if (clazz == SignatureDigest.class) { + return new SignatureDigest(hashBytes); + } else if (clazz == Bytes.class) { + return new Bytes(hashBytes); + } else if (clazz == BytesSlice.class) { + return new BytesSlice(hashBytes); + } + } + } + return null; + } + + @Override + public int getFastMatchToken() { + return JSONToken.LBRACE; + } +} diff --git a/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonSerializer.java b/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonSerializer.java new file mode 100644 index 00000000..896e1f4a --- /dev/null +++ b/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectJsonSerializer.java @@ -0,0 +1,120 @@ +package com.jd.blockchain.web.serializes; + +import com.alibaba.fastjson.serializer.JSONSerializer; +import com.alibaba.fastjson.serializer.ObjectSerializer; +import com.jd.blockchain.binaryproto.DataType; +import com.jd.blockchain.crypto.HashDigest; +import com.jd.blockchain.crypto.PubKey; +import com.jd.blockchain.crypto.SignatureDigest; +import com.jd.blockchain.utils.Bytes; +import com.jd.blockchain.utils.codec.Base58Utils; +import com.jd.blockchain.utils.io.BytesSlice; + +import java.lang.reflect.Type; + +public class ByteArrayObjectJsonSerializer implements ObjectSerializer { + + private Class clazz; + + private ByteArrayObjectJsonSerializer(Class clazz) { + this.clazz = clazz; + } + + public static ByteArrayObjectJsonSerializer getInstance(Class clazz) { + return new ByteArrayObjectJsonSerializer(clazz); + } + + @Override + public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) { + if (object.getClass() != clazz) { + serializer.writeNull(); + return; + } + if (object instanceof HashDigest) { + serializer.write(new HashDigestJson(((HashDigest) object).toBase58())); + } else if (object instanceof PubKey) { + serializer.write(new HashDigestJson(((PubKey) object).toBase58())); + } else if (object instanceof SignatureDigest) { + serializer.write(new HashDigestJson(((SignatureDigest) object).toBase58())); + } else if (object instanceof Bytes) { + serializer.write(new HashDigestJson(((Bytes) object).toBase58())); + } else if (object instanceof BytesSlice) { + serializer.write(Base58Utils.encode(((BytesSlice) object).toBytes())); + } + +// else if (object instanceof BytesValue) { +// DataType dataType = ((BytesValue) object).getType(); +// BytesSlice bytesValue = ((BytesValue) object).getValue(); +// Object realVal; +// switch (dataType) { +// case NIL: +// realVal = null; +// break; +// case TEXT: +// realVal = bytesValue.getString(); +// break; +// case BYTES: +// realVal = ByteArray.toHex(bytesValue.toBytes()); +// break; +// case INT32: +// realVal = bytesValue.getInt(); +// break; +// case INT64: +// realVal = bytesValue.getLong(); +// break; +// case JSON: +// realVal = bytesValue.getString(); +// break; +// default: +// realVal = ByteArray.toHex(bytesValue.toBytes()); +// break; +// } +// serializer.write(new BytesValueJson(dataType, realVal)); +// } + } + + private static class HashDigestJson { + + String value; + + public HashDigestJson(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + + public static class BytesValueJson { + + public BytesValueJson(DataType type, Object value) { + this.type = type; + this.value = value; + } + + DataType type; + + Object value; + + public DataType getType() { + return type; + } + + public void setType(DataType type) { + this.type = type; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + } +} diff --git a/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectUtil.java b/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectUtil.java new file mode 100644 index 00000000..e6d23910 --- /dev/null +++ b/source/ledger/ledger-rpc/src/main/java/com/jd/blockchain/web/serializes/ByteArrayObjectUtil.java @@ -0,0 +1,41 @@ +/** + * Copyright: Copyright 2016-2020 JD.COM All Right Reserved + * FileName: com.jd.blockchain.web.serializes.ByteArrayObjectUtil + * Author: shaozhuguang + * Department: Y事业部 + * Date: 2019/3/27 上午11:23 + * Description: + */ +package com.jd.blockchain.web.serializes; + +import com.jd.blockchain.crypto.HashDigest; +import com.jd.blockchain.crypto.PubKey; +import com.jd.blockchain.crypto.SignatureDigest; +import com.jd.blockchain.utils.Bytes; +import com.jd.blockchain.utils.io.BytesSlice; +import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; + +/** + * + * @author shaozhuguang + * @create 2019/3/27 + * @since 1.0.0 + */ + +public class ByteArrayObjectUtil { + + public static final Class[] BYTEARRAY_JSON_SERIALIZE_CLASS = new Class[] { + HashDigest.class, + PubKey.class, + SignatureDigest.class, + Bytes.class, + BytesSlice.class}; + + public static void init() { + for (Class byteArrayClass : BYTEARRAY_JSON_SERIALIZE_CLASS) { + JSONSerializeUtils.configSerialization(byteArrayClass, + ByteArrayObjectJsonSerializer.getInstance(byteArrayClass), + ByteArrayObjectJsonDeserializer.getInstance(byteArrayClass)); + } + } +} \ No newline at end of file diff --git a/source/peer/src/main/java/com/jd/blockchain/peer/web/PeerWebServerConfigurer.java b/source/peer/src/main/java/com/jd/blockchain/peer/web/PeerWebServerConfigurer.java index bc286117..f0d52ac5 100644 --- a/source/peer/src/main/java/com/jd/blockchain/peer/web/PeerWebServerConfigurer.java +++ b/source/peer/src/main/java/com/jd/blockchain/peer/web/PeerWebServerConfigurer.java @@ -2,22 +2,16 @@ package com.jd.blockchain.peer.web; import java.util.List; -import com.jd.blockchain.utils.io.BytesSlice; import com.jd.blockchain.web.converters.BinaryMessageConverter; import com.jd.blockchain.web.converters.HashDigestInputConverter; +import com.jd.blockchain.web.serializes.ByteArrayObjectUtil; import org.springframework.context.annotation.Configuration; import org.springframework.format.FormatterRegistry; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import com.jd.blockchain.crypto.HashDigest; -import com.jd.blockchain.crypto.PubKey; -import com.jd.blockchain.crypto.SignatureDigest; -import com.jd.blockchain.crypto.serialize.ByteArrayObjectDeserializer; -import com.jd.blockchain.crypto.serialize.ByteArrayObjectSerializer; -import com.jd.blockchain.utils.Bytes; import com.jd.blockchain.utils.io.ByteArray; import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter; @@ -25,13 +19,6 @@ import com.jd.blockchain.utils.web.model.JsonWebResponseMessageConverter; @Configuration public class PeerWebServerConfigurer implements WebMvcConfigurer { - private static final Class[] BYTEARRAY_JSON_SERIALIZE_CLASS = new Class[] { - HashDigest.class, - PubKey.class, - SignatureDigest.class, - Bytes.class, - BytesSlice.class}; - static { JSONSerializeUtils.disableCircularReferenceDetect(); JSONSerializeUtils.configStringSerializer(ByteArray.class); @@ -59,10 +46,6 @@ public class PeerWebServerConfigurer implements WebMvcConfigurer { } private void initByteArrayJsonSerialize() { - for (Class byteArrayClass : BYTEARRAY_JSON_SERIALIZE_CLASS) { - JSONSerializeUtils.configSerialization(byteArrayClass, - ByteArrayObjectSerializer.getInstance(byteArrayClass), - ByteArrayObjectDeserializer.getInstance(byteArrayClass)); - } + ByteArrayObjectUtil.init(); } } diff --git a/source/sdk/sdk-client/pom.xml b/source/sdk/sdk-client/pom.xml index a33f309d..17ccdf88 100644 --- a/source/sdk/sdk-client/pom.xml +++ b/source/sdk/sdk-client/pom.xml @@ -14,5 +14,11 @@ sdk-base ${project.version} + + + com.jd.blockchain + ledger-rpc + ${project.version} + \ No newline at end of file diff --git a/source/sdk/sdk-client/src/main/java/com/jd/blockchain/sdk/client/GatewayServiceFactory.java b/source/sdk/sdk-client/src/main/java/com/jd/blockchain/sdk/client/GatewayServiceFactory.java index 49348b90..5396a430 100644 --- a/source/sdk/sdk-client/src/main/java/com/jd/blockchain/sdk/client/GatewayServiceFactory.java +++ b/source/sdk/sdk-client/src/main/java/com/jd/blockchain/sdk/client/GatewayServiceFactory.java @@ -3,15 +3,16 @@ package com.jd.blockchain.sdk.client; import java.io.Closeable; import com.jd.blockchain.binaryproto.BinaryProtocol; +import com.jd.blockchain.binaryproto.DataContractRegistry; +import com.jd.blockchain.consensus.ClientIdentification; +import com.jd.blockchain.consensus.ClientIdentifications; +import com.jd.blockchain.consensus.action.ActionRequest; +import com.jd.blockchain.consensus.action.ActionResponse; import com.jd.blockchain.crypto.Crypto; import com.jd.blockchain.crypto.PrivKey; import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureFunction; -import com.jd.blockchain.ledger.BlockchainKeypair; -import com.jd.blockchain.ledger.DigitalSignature; -import com.jd.blockchain.ledger.TransactionContent; -import com.jd.blockchain.ledger.TransactionRequest; -import com.jd.blockchain.ledger.TransactionResponse; +import com.jd.blockchain.ledger.*; import com.jd.blockchain.sdk.BlockchainService; import com.jd.blockchain.sdk.BlockchainServiceFactory; import com.jd.blockchain.sdk.proxy.HttpBlockchainQueryService; @@ -24,6 +25,7 @@ import com.jd.blockchain.utils.http.agent.ServiceConnection; import com.jd.blockchain.utils.http.agent.ServiceConnectionManager; import com.jd.blockchain.utils.http.agent.ServiceEndpoint; import com.jd.blockchain.utils.net.NetworkAddress; +import com.jd.blockchain.web.serializes.ByteArrayObjectUtil; public class GatewayServiceFactory implements BlockchainServiceFactory, Closeable { @@ -33,6 +35,31 @@ public class GatewayServiceFactory implements BlockchainServiceFactory, Closeabl private BlockchainService blockchainService; + static { + DataContractRegistry.register(TransactionContent.class); + DataContractRegistry.register(TransactionContentBody.class); + DataContractRegistry.register(TransactionRequest.class); + DataContractRegistry.register(NodeRequest.class); + DataContractRegistry.register(EndpointRequest.class); + DataContractRegistry.register(TransactionResponse.class); + DataContractRegistry.register(DataAccountKVSetOperation.class); + DataContractRegistry.register(DataAccountKVSetOperation.KVWriteEntry.class); + + DataContractRegistry.register(Operation.class); + DataContractRegistry.register(ContractCodeDeployOperation.class); + DataContractRegistry.register(ContractEventSendOperation.class); + DataContractRegistry.register(DataAccountRegisterOperation.class); + DataContractRegistry.register(UserRegisterOperation.class); + + DataContractRegistry.register(ActionRequest.class); + DataContractRegistry.register(ActionResponse.class); + DataContractRegistry.register(ClientIdentifications.class); + DataContractRegistry.register(ClientIdentification.class); + + ByteArrayObjectUtil.init(); + } + + protected GatewayServiceFactory(ServiceEndpoint gatewayEndpoint, BlockchainKeypair userKey) { httpConnectionManager = new ServiceConnectionManager(); this.userKey = userKey; diff --git a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java index a5343eb6..3851d6a7 100644 --- a/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java +++ b/source/sdk/sdk-samples/src/test/java/test/com/jd/blockchain/sdk/test/SDK_GateWay_Query_Test_.java @@ -19,8 +19,6 @@ import com.jd.blockchain.crypto.HashFunction; import com.jd.blockchain.crypto.PubKey; import com.jd.blockchain.crypto.SignatureDigest; import com.jd.blockchain.crypto.SignatureFunction; -import com.jd.blockchain.crypto.serialize.ByteArrayObjectDeserializer; -import com.jd.blockchain.crypto.serialize.ByteArrayObjectSerializer; import com.jd.blockchain.ledger.AccountHeader; import com.jd.blockchain.ledger.BlockchainKeyGenerator; import com.jd.blockchain.ledger.BlockchainKeypair; @@ -53,17 +51,6 @@ import com.jd.blockchain.utils.serialize.json.JSONSerializeUtils; public class SDK_GateWay_Query_Test_ { - private static Class[] byteArrayClasss = new Class[] { HashDigest.class, PubKey.class, - SignatureDigest.class }; - - static { - for (Class byteArrayClass : byteArrayClasss) { - JSONSerializeUtils.configSerialization(byteArrayClass, - ByteArrayObjectSerializer.getInstance(byteArrayClass), - ByteArrayObjectDeserializer.getInstance(byteArrayClass)); - } - } - private BlockchainKeypair CLIENT_CERT = null; private String GATEWAY_IPADDR = null;