[
https://issues.apache.org/jira/browse/SCB-946?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16714645#comment-16714645
]
ASF GitHub Bot commented on SCB-946:
liubao68 closed pull request #1025: [SCB-946] serialize/deseriaze
List>/List>/Map>/Map>
URL: https://github.com/apache/servicecomb-java-chassis/pull/1025
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
index 860a9f6f0..0af2afb88 100644
---
a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
+++
b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/ProtoMapper.java
@@ -20,7 +20,9 @@
import java.util.Map;
import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
+import
org.apache.servicecomb.foundation.protobuf.internal.RootPropertyWrapDeserializer;
import
org.apache.servicecomb.foundation.protobuf.internal.bean.BeanDescriptorManager;
+import
org.apache.servicecomb.foundation.protobuf.internal.bean.PropertyWrapper;
import
org.apache.servicecomb.foundation.protobuf.internal.schema.deserializer.DeserializerSchemaManager;
import
org.apache.servicecomb.foundation.protobuf.internal.schema.serializer.SerializerSchemaManager;
@@ -105,4 +107,17 @@ public RootDeserializer createRootDeserializer(JavaType
javaType, String shortMe
public RootDeserializer createRootDeserializer(JavaType javaType, Message
message) {
return deserializerSchemaManager.createRootDeserializer(javaType, message);
}
+
+ public RootDeserializer createPropertyRootDeserializer(String
shortWrapMessageName, Type propertyType) {
+Message message = proto.getMessage(shortWrapMessageName);
+if (!deserializerSchemaManager.isWrapProperty(message)) {
+ return createRootDeserializer(propertyType, shortWrapMessageName);
+}
+
+JavaType propertyWrapJavaType =
TypeFactory.defaultInstance().constructParametricType(
+PropertyWrapper.class,
+TypeFactory.defaultInstance().constructType(propertyType));
+RootDeserializer rootDeserializer =
createRootDeserializer(propertyWrapJavaType, message);
+return new RootPropertyWrapDeserializer(rootDeserializer);
+ }
}
diff --git
a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/ProtoConst.java
b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/ProtoConst.java
index 53ec0c2f6..72f376490 100644
---
a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/ProtoConst.java
+++
b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/ProtoConst.java
@@ -30,6 +30,8 @@
private ProtoConst() {
}
+ public static String ANNOTATION_WRAP_PROPERTY = "@WrapProperty";
+
public static String OP_HINT = " scb:";
public static String PACK_SCHEMA = "type.googleapis.com/";
diff --git
a/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/RootPropertyWrapDeserializer.java
b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/RootPropertyWrapDeserializer.java
new file mode 100644
index 0..ab646993e
--- /dev/null
+++
b/foundations/foundation-protobuf/src/main/java/org/apache/servicecomb/foundation/protobuf/internal/RootPropertyWrapDeserializer.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicecomb.foundation.protobuf.internal;
+
+import java.io.IOException;
+
+import org.apache.servicecomb.foundation.protobuf.RootDeserializer;
+import
org.apache.servicecomb.fou