Service Invoker has been modified.
This commit is contained in:
parent
22adfe4688
commit
c4df5dc06f
|
@ -1,8 +1,10 @@
|
|||
package com.loafle.overflow.proxy;
|
||||
|
||||
import com.google.gson.internal.Primitives;
|
||||
import com.google.protobuf.ByteString;
|
||||
import org.codehaus.jackson.map.DeserializationConfig;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.codehaus.jackson.type.JavaType;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -111,7 +113,11 @@ public class ServiceInvoker {
|
|||
}
|
||||
|
||||
private Object getValue(Type parameterType, String json) throws IOException {
|
||||
return objectMapper.readValue(json, objectMapper.getTypeFactory().constructType(parameterType));
|
||||
JavaType targetType = objectMapper.getTypeFactory().constructType(parameterType);
|
||||
if (!Primitives.isPrimitive(parameterType) && !parameterType.getTypeName().equals(String.class.getName())) {
|
||||
return objectMapper.readValue(json, targetType);
|
||||
}
|
||||
return objectMapper.convertValue(json, targetType);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,6 +54,12 @@ public class ServiceInvokerTest {
|
|||
|
||||
serviceInvoker.invoke("MemberService", "read", params3);
|
||||
|
||||
List<ByteString> params4 = new ArrayList<>(2);
|
||||
params4.add(ByteString.copyFromUtf8("ddddddfsafsd"));
|
||||
params4.add(ByteString.copyFromUtf8("243234234234"));
|
||||
|
||||
serviceInvoker.invoke("MemberService", "signin", params4);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user