DUBBO-518 字节流泛化调用使用native java序列化
This commit is contained in:
parent
1e93800f8f
commit
8ab49456f6
|
|
@ -574,7 +574,7 @@ public class Constants {
|
|||
|
||||
public static final String EXECUTOR_SERVICE_COMPONENT_KEY = ExecutorService.class.getName();
|
||||
|
||||
public static final String GENERIC_SERIALIZATION_JAVA = "java";
|
||||
public static final String GENERIC_SERIALIZATION_NATIVE_JAVA = "nativejava";
|
||||
|
||||
public static final String GENERIC_SERIALIZATION_DEFAULT = "true";
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class GenericServiceTest {
|
|||
reference.setApplication(new ApplicationConfig("generic-consumer"));
|
||||
reference.setInterface(DemoService.class);
|
||||
reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
|
||||
reference.setGeneric(Constants.GENERIC_SERIALIZATION_JAVA);
|
||||
reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA);
|
||||
GenericService genericService = reference.get();
|
||||
try {
|
||||
String name = "kimi";
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class GenericFilter implements Filter {
|
|||
try {
|
||||
UnsafeByteArrayInputStream is = new UnsafeByteArrayInputStream((byte[])args[i]);
|
||||
args[i] = ExtensionLoader.getExtensionLoader(Serialization.class)
|
||||
.getExtension(getSerializationExtension(Constants.GENERIC_SERIALIZATION_JAVA))
|
||||
.getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
|
||||
.deserialize(null, is).readObject();
|
||||
} catch (Exception e) {
|
||||
throw new RpcException("Deserialize argument [" + (i + 1) + "] failed.", e);
|
||||
|
|
@ -77,7 +77,7 @@ public class GenericFilter implements Filter {
|
|||
} else {
|
||||
throw new RpcException(
|
||||
new StringBuilder(32).append("Generic serialization [")
|
||||
.append(Constants.GENERIC_SERIALIZATION_JAVA)
|
||||
.append(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
|
||||
.append("] only support message type ")
|
||||
.append(byte[].class)
|
||||
.append(" and your message type is ")
|
||||
|
|
@ -94,7 +94,7 @@ public class GenericFilter implements Filter {
|
|||
try {
|
||||
UnsafeByteArrayOutputStream os = new UnsafeByteArrayOutputStream(512);
|
||||
ExtensionLoader.getExtensionLoader(Serialization.class)
|
||||
.getExtension(getSerializationExtension(Constants.GENERIC_SERIALIZATION_JAVA))
|
||||
.getExtension(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
|
||||
.serialize(null, os).writeObject(result.getValue());
|
||||
return new RpcResult(os.toByteArray());
|
||||
} catch (IOException e) {
|
||||
|
|
@ -112,7 +112,4 @@ public class GenericFilter implements Filter {
|
|||
return invoker.invoke(inv);
|
||||
}
|
||||
|
||||
private String getSerializationExtension(String generic) {
|
||||
return "nativejava";
|
||||
}
|
||||
}
|
||||
|
|
@ -142,7 +142,7 @@ public class GenericImplFilter implements Filter {
|
|||
throw new RpcException(
|
||||
new StringBuilder(32)
|
||||
.append("Generic serialization [")
|
||||
.append(Constants.GENERIC_SERIALIZATION_JAVA)
|
||||
.append(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA)
|
||||
.append("] only support message type ")
|
||||
.append(byte[].class)
|
||||
.append(" and your message type is ")
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class ProtocolUtils {
|
|||
return generic != null
|
||||
&& !"".equals(generic)
|
||||
&& (Constants.GENERIC_SERIALIZATION_DEFAULT.equalsIgnoreCase(generic) /* 正常的泛化调用 */
|
||||
|| Constants.GENERIC_SERIALIZATION_JAVA.equalsIgnoreCase(generic)); /* 支持java序列化的流式泛化调用 */
|
||||
|| Constants.GENERIC_SERIALIZATION_NATIVE_JAVA.equalsIgnoreCase(generic)); /* 支持java序列化的流式泛化调用 */
|
||||
}
|
||||
|
||||
public static boolean isDefaultGenericSerialization(String generic) {
|
||||
|
|
@ -46,6 +46,6 @@ public class ProtocolUtils {
|
|||
|
||||
public static boolean isJavaGenericSerialization(String generic) {
|
||||
return isGeneric(generic)
|
||||
&& Constants.GENERIC_SERIALIZATION_JAVA.equalsIgnoreCase(generic);
|
||||
&& Constants.GENERIC_SERIALIZATION_NATIVE_JAVA.equalsIgnoreCase(generic);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue