Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/alibaba/dubbo
Browse files Browse the repository at this point in the history
  • Loading branch information
liangfei0201 committed Jul 26, 2012
2 parents 526d684 + 8ab4945 commit 33dad08
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void testGenericSerializationJava() throws Exception {
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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
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);
}
} 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 ")
Expand All @@ -94,7 +94,7 @@ public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
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) {
Expand All @@ -112,7 +112,4 @@ public Result invoke(Invoker<?> invoker, Invocation inv) throws RpcException {
return invoker.invoke(inv);
}

private String getSerializationExtension(String generic) {
return "nativejava";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private void error(String type) throws RpcException {
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 ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static boolean isGeneric(String generic) {
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) {
Expand All @@ -46,6 +46,6 @@ public static boolean isDefaultGenericSerialization(String generic) {

public static boolean isJavaGenericSerialization(String generic) {
return isGeneric(generic)
&& Constants.GENERIC_SERIALIZATION_JAVA.equalsIgnoreCase(generic);
&& Constants.GENERIC_SERIALIZATION_NATIVE_JAVA.equalsIgnoreCase(generic);
}
}

0 comments on commit 33dad08

Please sign in to comment.