| @@ -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> 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<String, Object> map, ParserConfig config) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { | |||
| if (map == null || map.isEmpty()) { | |||
| return null; | |||
| } | |||
| for (Map.Entry<String, Object> 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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -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(); | |||
| } | |||
| } | |||
| @@ -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> 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<String, Object> map, ParserConfig config) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { | |||
| if (map == null || map.isEmpty()) { | |||
| return null; | |||
| } | |||
| for (Map.Entry<String, Object> 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; | |||
| } | |||
| } | |||
| @@ -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; | |||
| } | |||
| } | |||
| } | |||
| @@ -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)); | |||
| } | |||
| } | |||
| } | |||
| @@ -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(); | |||
| } | |||
| } | |||
| @@ -14,5 +14,11 @@ | |||
| <artifactId>sdk-base</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.jd.blockchain</groupId> | |||
| <artifactId>ledger-rpc</artifactId> | |||
| <version>${project.version}</version> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -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; | |||
| @@ -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; | |||