[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-14 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r195350417
 
 

 ##
 File path: 
demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CodeFirstRestTemplate.java
 ##
 @@ -123,6 +128,21 @@ private void testCodeFirstTextPlain(RestTemplate 
template, String cseUrlPrefix)
 TestMgr.check(body, result);
   }
 
+  private void testCodeFirstAppXml(RestTemplate template, String cseUrlPrefix) 
{
+JAXBPerson person = new JAXBPerson("jake", 22, "it", "60kg");
+person.setJob(new JAXBJob("developer", "coding"));
+HttpHeaders headers = new HttpHeaders();
+headers.add("Accept", MediaType.APPLICATION_XML_VALUE);
+headers.add("Content-Type", MediaType.APPLICATION_XML_VALUE);
 
 Review comment:
   yes, now servicecomb processing client requests only use application/xml, 
don't support extend, that means whatever i set in ContentType, it all will be 
cover to application/xml before send to server, and server will default use 
json to do decode.
   so the xml produceprocessor actually effective in response, when response, 
provider use xml encode and consumer use xml docode


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-13 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r195011789
 
 

 ##
 File path: 
demo/demo-schema/src/main/java/org/apache/servicecomb/demo/produceprocessor/ProduceJsonProcessor.java
 ##
 @@ -0,0 +1,51 @@
+/*
+ * 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.demo.produceprocessor;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.common.rest.codec.RestObjectMapper;
+import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+public class ProduceJsonProcessor implements ProduceProcessor {
 
 Review comment:
   delete this, use override ProduceAppXmlProcessor instead, but can't gives 
wrong output,because we  need return correct result in springmvc demo ,the 
content is not change, we can validate it by judge whether getOrder return -1


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-13 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r195011789
 
 

 ##
 File path: 
demo/demo-schema/src/main/java/org/apache/servicecomb/demo/produceprocessor/ProduceJsonProcessor.java
 ##
 @@ -0,0 +1,51 @@
+/*
+ * 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.demo.produceprocessor;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.common.rest.codec.RestObjectMapper;
+import org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+public class ProduceJsonProcessor implements ProduceProcessor {
 
 Review comment:
   delete this, use override ProduceAppXmlProcessor instead, but can't gives 
wrong output,because we  need return correct result in springmvc demo ,we can 
validate it by judge whether getOrder return -1


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-13 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r195010122
 
 

 ##
 File path: 
demo/demo-schema/src/main/java/org/apache/servicecomb/demo/produceprocessor/ProduceAppXmlProcessor.java
 ##
 @@ -0,0 +1,35 @@
+package org.apache.servicecomb.demo.produceprocessor;
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-13 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r195010005
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,38 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final List produceProcessor = 
SPIServiceUtils.getAllService(ProduceProcessor.class);
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-13 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r195010068
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,38 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final List produceProcessor = 
SPIServiceUtils.getAllService(ProduceProcessor.class);
+
   private static final String NAME = "produce processor mgr";
 
   public static final String DEFAULT_TYPE = MediaType.APPLICATION_JSON;
 
   public static final ProduceProcessorManager INSTANCE = new 
ProduceProcessorManager();
 
-  public static final ProduceProcessor JSON_PROCESSOR = new 
ProduceJsonProcessor();
+  public static final ProduceProcessor JSON_PROCESSOR = 
SPIServiceUtils.getTargetService(ProduceProcessor.class, 
ProduceJsonProcessor.class);
 
-  public static final ProduceProcessor PLAIN_PROCESSOR = new 
ProduceTextPlainProcessor();
+  public static final ProduceProcessor PLAIN_PROCESSOR = 
SPIServiceUtils.getTargetService(ProduceProcessor.class, 
ProduceTextPlainProcessor.class);
 
   public static final ProduceProcessor DEFAULT_PROCESSOR = JSON_PROCESSOR;
 
   private ProduceProcessorManager() {
 super(NAME);
+Map map = new ConcurrentHashMap<>();
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-11 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r194431082
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,29 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.List;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final List produceProcessor = 
SPIServiceUtils.getAllService(ProduceProcessor.class);
+
   private static final String NAME = "produce processor mgr";
 
   public static final String DEFAULT_TYPE = MediaType.APPLICATION_JSON;
 
   public static final ProduceProcessorManager INSTANCE = new 
ProduceProcessorManager();
 
-  public static final ProduceProcessor JSON_PROCESSOR = new 
ProduceJsonProcessor();
+  public static final ProduceProcessor JSON_PROCESSOR = 
SPIServiceUtils.getTargetService(ProduceProcessor.class, 
ProduceJsonProcessor.class);
 
-  public static final ProduceProcessor PLAIN_PROCESSOR = new 
ProduceTextPlainProcessor();
+  public static final ProduceProcessor PLAIN_PROCESSOR = 
SPIServiceUtils.getTargetService(ProduceProcessor.class, 
ProduceTextPlainProcessor.class);
 
   public static final ProduceProcessor DEFAULT_PROCESSOR = JSON_PROCESSOR;
 
   private ProduceProcessorManager() {
 super(NAME);
+produceProcessor.forEach(processor -> register(processor.getName(), 
processor));
 
 Review comment:
   done, override jsonprocessor,getOrder return -1, and successful


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-07 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r193731478
 
 

 ##
 File path: 
common/common-rest/src/main/resources/META-INF/services/org.apache.servicecomb.common.rest.codec.produce.ProduceProcessor
 ##
 @@ -0,0 +1,19 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.common.rest.codec.produce.ProduceJsonProcessor
 
 Review comment:
   i'm working on this


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-07 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r193684923
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,43 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.ServiceLoader;
+
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProduceProcessorManager.class);
+
+  private static final ServiceLoader produceProcessor = 
ServiceLoader.load(ProduceProcessor.class);
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-07 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r193684864
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceJsonProcessor.java
 ##
 @@ -46,6 +46,6 @@ public Object doDecodeResponse(InputStream input, JavaType 
type) throws Exceptio
   @Override
   public int getOrder() {
 // TODO Auto-generated method stub
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-06 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r193618985
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,43 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.ServiceLoader;
+
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProduceProcessorManager.class);
+
+  private static final ServiceLoader produceProcessor = 
ServiceLoader.load(ProduceProcessor.class);
+
   private static final String NAME = "produce processor mgr";
 
   public static final String DEFAULT_TYPE = MediaType.APPLICATION_JSON;
 
   public static final ProduceProcessorManager INSTANCE = new 
ProduceProcessorManager();
 
-  public static final ProduceProcessor JSON_PROCESSOR = new 
ProduceJsonProcessor();
+  public static final ProduceProcessor JSON_PROCESSOR = 
chooseProduceProcessor(MediaType.APPLICATION_JSON);
 
-  public static final ProduceProcessor PLAIN_PROCESSOR = new 
ProduceTextPlainProcessor();
+  public static final ProduceProcessor PLAIN_PROCESSOR = 
chooseProduceProcessor(MediaType.TEXT_PLAIN);
 
   public static final ProduceProcessor DEFAULT_PROCESSOR = JSON_PROCESSOR;
 
   private ProduceProcessorManager() {
 super(NAME);
+produceProcessor.forEach(processor -> register(processor.getName(), 
processor));
+  }
+
+  public static ProduceProcessor chooseProduceProcessor(String type) {
+for (ProduceProcessor processor : produceProcessor) {
+  if (type.equals(processor.getName()))
+return processor;
+}
+LOGGER.warn("Getting the current produceProcessor type {} failed, use 
default produceProcessor: application/json",
+type);
+return new ProduceJsonProcessor();
 
 Review comment:
   now use SPIServiceUtils,if not get, it will return null
   
![image](https://user-images.githubusercontent.com/30716999/41077353-c266d6d6-6a48-11e8-8324-c8c2a6a3f62e.png)
   


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-06-06 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r193618594
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,43 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.ServiceLoader;
+
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProduceProcessorManager.class);
+
+  private static final ServiceLoader produceProcessor = 
ServiceLoader.load(ProduceProcessor.class);
 
 Review comment:
   done, there is still one question: what number should json and text/plain 
return when getOrder, i use 10 and 11 now


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] weichao666 commented on a change in pull request #741: [SCB-625] ProduceProcessor use SPI to support extends

2018-05-31 Thread GitBox
weichao666 commented on a change in pull request #741: [SCB-625] 
ProduceProcessor use SPI to support extends
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/741#discussion_r192085651
 
 

 ##
 File path: 
common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceProcessorManager.java
 ##
 @@ -17,24 +17,43 @@
 
 package org.apache.servicecomb.common.rest.codec.produce;
 
+import java.util.ServiceLoader;
+
 import javax.ws.rs.core.MediaType;
 
 import org.apache.servicecomb.foundation.common.RegisterManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public final class ProduceProcessorManager extends RegisterManager {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(ProduceProcessorManager.class);
+
+  private static final ServiceLoader produceProcessor = 
ServiceLoader.load(ProduceProcessor.class);
+
   private static final String NAME = "produce processor mgr";
 
   public static final String DEFAULT_TYPE = MediaType.APPLICATION_JSON;
 
   public static final ProduceProcessorManager INSTANCE = new 
ProduceProcessorManager();
 
-  public static final ProduceProcessor JSON_PROCESSOR = new 
ProduceJsonProcessor();
+  public static final ProduceProcessor JSON_PROCESSOR = 
chooseProduceProcessor(MediaType.APPLICATION_JSON);
 
-  public static final ProduceProcessor PLAIN_PROCESSOR = new 
ProduceTextPlainProcessor();
+  public static final ProduceProcessor PLAIN_PROCESSOR = 
chooseProduceProcessor(MediaType.TEXT_PLAIN);
 
   public static final ProduceProcessor DEFAULT_PROCESSOR = JSON_PROCESSOR;
 
   private ProduceProcessorManager() {
 super(NAME);
+produceProcessor.forEach(processor -> register(processor.getName(), 
processor));
+  }
+
+  public static ProduceProcessor chooseProduceProcessor(String type) {
+for (ProduceProcessor processor : produceProcessor) {
+  if (type.equals(processor.getName()))
+return processor;
+}
+LOGGER.error("Getting the current produceProcessor type {} failed, use 
default produceProcessor: application/json",
+type);
+return new ProduceJsonProcessor();
 
 Review comment:
   done


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services