This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-samples.git
The following commit(s) were added to refs/heads/master by this push:
new f48a57b add more examples to show CONSUMER/PROVIDER using different
model (#36)
f48a57b is described below
commit f48a57b43e1516e7d42b11e28210a5b3b747a1c9
Author: bao liu <[email protected]>
AuthorDate: Fri Dec 6 16:53:14 2019 +0800
add more examples to show CONSUMER/PROVIDER using different model (#36)
* fix spring boot application usage problem
* add more examples to show CONSUMER/PROVIDER using different model
* remove unused code
---
.../samples/common/schema/Assertion.java | 35 +++++++++++
.../{microservice.yaml => application.yml} | 5 ++
.../springmvc/consumer/SpringmvcBasicClient.java | 48 +++++++++++++++
.../consumer/SpringmvcBasicRequestModel.java | 34 ++++++++++
.../consumer/SpringmvcBasicResponseModel.java | 34 ++++++++++
.../springmvc/consumer/SpringmvcBasicService.java | 26 ++++++++
.../springmvc/consumer/SpringmvcConsumerMain.java | 69 ++-------------------
...ConsumerMain.java => SpringmvcHelloClient.java} | 30 ++++++---
.../main/resources/microservices/hello/hello.yaml | 72 ----------------------
...cHelloImpl.java => SpringmvcBasicEndpoint.java} | 25 +++-----
.../provider/SpringmvcBasicRequestModel.java | 39 ++++++++++++
.../provider/SpringmvcBasicResponseModel.java | 39 ++++++++++++
...cHelloImpl.java => SpringmvcHelloEndpoint.java} | 2 +-
.../main/resources/microservices/hello/hello.yaml | 72 ----------------------
14 files changed, 296 insertions(+), 234 deletions(-)
diff --git
a/java-chassis-samples/common-schema/src/main/java/org/apache/servicecomb/samples/common/schema/Assertion.java
b/java-chassis-samples/common-schema/src/main/java/org/apache/servicecomb/samples/common/schema/Assertion.java
new file mode 100644
index 0000000..efc71f9
--- /dev/null
+++
b/java-chassis-samples/common-schema/src/main/java/org/apache/servicecomb/samples/common/schema/Assertion.java
@@ -0,0 +1,35 @@
+/*
+ * 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.samples.common.schema;
+
+public final class Assertion {
+ private Assertion() {
+
+ }
+
+ public static void assertEquals(String expected, String actual) {
+ if (expected == null) {
+ if (actual != null) {
+ throw new IllegalStateException("assert error. expected [" + expected
+ "], but [" + actual + "]");
+ }
+ } else {
+ if (!expected.equals(actual)) {
+ throw new IllegalStateException("assert error. expected [" + expected
+ "], but [" + actual + "]");
+ }
+ }
+ }
+}
diff --git
a/java-chassis-samples/metrics-extend-healthcheck/src/main/resources/microservice.yaml
b/java-chassis-samples/metrics-extend-healthcheck/src/main/resources/application.yml
similarity index 94%
rename from
java-chassis-samples/metrics-extend-healthcheck/src/main/resources/microservice.yaml
rename to
java-chassis-samples/metrics-extend-healthcheck/src/main/resources/application.yml
index cb1bf60..134f0f1 100644
---
a/java-chassis-samples/metrics-extend-healthcheck/src/main/resources/microservice.yaml
+++
b/java-chassis-samples/metrics-extend-healthcheck/src/main/resources/application.yml
@@ -16,8 +16,13 @@
## limitations under the License.
## ---------------------------------------------------------------------------
+# spring boot serttings
+server:
+ port: 7777
+
# all interconnected microservices must belong to an application wth the same
ID
APPLICATION_ID: metrics
+
service_description:
# name of the declaring microservice
name: metricsHealthCheckDemo
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicClient.java
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicClient.java
new file mode 100644
index 0000000..ae71ce1
--- /dev/null
+++
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicClient.java
@@ -0,0 +1,48 @@
+/*
+ * 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.samples.springmvc.consumer;
+
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.samples.common.schema.Assertion;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@Component("SpringmvcBasicClient")
+public class SpringmvcBasicClient {
+ private RestTemplate restTemplateInvoker = RestTemplateBuilder.create();
+
+ @RpcReference(microserviceName = "springmvc", schemaId =
"SpringmvcBasicEndpoint")
+ private SpringmvcBasicService rpcInoker;
+
+ public void run() {
+ SpringmvcBasicRequestModel requestModel = new SpringmvcBasicRequestModel();
+ requestModel.setName("Hello World");
+ SpringmvcBasicResponseModel responseModel;
+
+ // Invoke a spring mvc provider using RPC
+ responseModel = rpcInoker.sayHello(requestModel);
+ Assertion.assertEquals("Hello World", responseModel.getResultMessage());
+
+ // TODO : this test case should work in 2.0, currently not implemented
+// // Invoke a spring mvc provider using RestTemplate
+// responseModel = restTemplateInvoker
+// .postForObject("cse://springmvc/springmvc/basic/postObject",
responseModel, SpringmvcBasicResponseModel.class);
+// Assertion.assertEquals("Hello World", responseModel.getResultMessage());
+ }
+}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicRequestModel.java
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicRequestModel.java
new file mode 100644
index 0000000..2103232
--- /dev/null
+++
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicRequestModel.java
@@ -0,0 +1,34 @@
+/*
+ * 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.samples.springmvc.consumer;
+
+/**
+ * Consumer model can be different than provider model(package, class name,
fields, etc). This feature is quite useful in microservices and devops where
+ * every developers can work independently at his own work.
+ */
+public class SpringmvcBasicRequestModel {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicResponseModel.java
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicResponseModel.java
new file mode 100644
index 0000000..c98f8f2
--- /dev/null
+++
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicResponseModel.java
@@ -0,0 +1,34 @@
+/*
+ * 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.samples.springmvc.consumer;
+
+/**
+ * Consumer model can be different than provider model(package, class name,
fields, etc). This feature is quite useful in microservices and devops where
+ * every developers can work independently at his own work.
+ */
+public class SpringmvcBasicResponseModel {
+ private String resultMessage;
+
+ public String getResultMessage() {
+ return resultMessage;
+ }
+
+ public void setResultMessage(String resultMessage) {
+ this.resultMessage = resultMessage;
+ }
+}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicService.java
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicService.java
new file mode 100644
index 0000000..adf53fa
--- /dev/null
+++
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcBasicService.java
@@ -0,0 +1,26 @@
+/*
+ * 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.samples.springmvc.consumer;
+
+/**
+ * Consumer interface can be different than provider interface. This feature
is quite useful in microservices and devops where
+ * every developers can work independently at his own work.
+ */
+public interface SpringmvcBasicService {
+ SpringmvcBasicResponseModel sayHello(SpringmvcBasicRequestModel
requestModel);
+}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
index ef7ed95..38b899f 100644
---
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
+++
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
@@ -17,75 +17,18 @@
package org.apache.servicecomb.samples.springmvc.consumer;
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
-import org.apache.servicecomb.provider.pojo.RpcReference;
-import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
-import
org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate;
-import org.apache.servicecomb.samples.common.schema.Hello;
-import org.apache.servicecomb.samples.common.schema.models.Person;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
-import org.springframework.util.concurrent.ListenableFuture;
-import org.springframework.util.concurrent.ListenableFutureCallback;
-import org.springframework.web.client.RestTemplate;
-@Component
public class SpringmvcConsumerMain {
- private static final Logger LOG =
LoggerFactory.getLogger(SpringmvcConsumerMain.class);
-
- private static RestTemplate restTemplate = RestTemplateBuilder.create();
-
- @RpcReference(microserviceName = "springmvc", schemaId = "springmvcHello")
- private static Hello hello;
-
public static void main(String[] args) throws Exception {
BeanUtils.init();
- Person person = new Person();
- person.setName("ServiceComb/Java Chassis");
-
- // RestTemplate Consumer or POJO Consumer. You can choose whatever you like
- // RestTemplate Consumer
- String sayHiResult =
-
restTemplate.postForObject("cse://springmvc/springmvchello/sayhi?name=Java
Chassis", null, String.class);
- String sayHiDefaultResult =
- restTemplate.postForObject("cse://springmvc/springmvchello/sayhi",
null, String.class);
- String sayHelloResult =
restTemplate.postForObject("cse://springmvc/springmvchello/sayhello", person,
String.class);
- System.out.println("RestTemplate Consumer or POJO Consumer. You can
choose whatever you like.");
- System.out.println("RestTemplate consumer sayhi services: " + sayHiResult);
- System.out.println("RestTemplate consumer sayHiDefault services: " +
sayHiDefaultResult);
- System.out.println("RestTemplate consumer sayhello services: " +
sayHelloResult);
-
- // POJO Consumer
- System.out.println("POJO consumer sayhi services: " + hello.sayHi("Java
Chassis"));
- System.out.println("POJO consumer sayhello services: " +
hello.sayHello(person));
-
- //AsyncRestTemplate Consumer
- CseAsyncRestTemplate cseAsyncRestTemplate = new CseAsyncRestTemplate();
- ListenableFuture<ResponseEntity<String>> responseEntityListenableFuture =
cseAsyncRestTemplate
- .postForEntity("cse://springmvc/springmvchello/sayhi?name=Java
Chassis", null, String.class);
- ResponseEntity<String> responseEntity =
responseEntityListenableFuture.get();
- System.out.println("AsyncRestTemplate Consumer sayHi services: " +
responseEntity.getBody());
- HttpEntity<Person> entity = new HttpEntity<>(person);
- ListenableFuture<ResponseEntity<String>> listenableFuture =
cseAsyncRestTemplate
- .exchange("cse://springmvc/springmvchello/sayhello", HttpMethod.POST,
entity, String.class);
- // ResponseEntity<String> responseEntity1 = listenableFuture.get();
- // System.out.println("AsyncRestTemplate Consumer sayHello services: "
+ responseEntity1.getBody());
+ SpringmvcBasicClient springmvcBasicClient =
BeanUtils.getBean("SpringmvcBasicClient");
+ SpringmvcHelloClient springmvcHelloClient =
BeanUtils.getBean("SpringmvcHelloClient");
- listenableFuture.addCallback(
- new ListenableFutureCallback<ResponseEntity<String>>() {
- @Override
- public void onFailure(Throwable ex) {
- LOG.error("AsyncResTemplate Consumer catched exception when
sayHello, ", ex);
- }
+ long begin = System.currentTimeMillis();
+ springmvcHelloClient.run();
+ springmvcBasicClient.run();
- @Override
- public void onSuccess(ResponseEntity<String> result) {
- System.out.println("AsyncRestTemplate Consumer sayHello services:
" + result.getBody());
- }
- });
+ System.out.println("Spring MVC Consumer execute successfully." +
(System.currentTimeMillis() - begin) );
}
}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcHelloClient.java
similarity index 82%
copy from
java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
copy to
java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcHelloClient.java
index ef7ed95..4acabc2 100644
---
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcConsumerMain.java
+++
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/java/org/apache/servicecomb/samples/springmvc/consumer/SpringmvcHelloClient.java
@@ -14,12 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.apache.servicecomb.samples.springmvc.consumer;
-import org.apache.servicecomb.foundation.common.utils.BeanUtils;
import org.apache.servicecomb.provider.pojo.RpcReference;
import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
import
org.apache.servicecomb.provider.springmvc.reference.async.CseAsyncRestTemplate;
+import org.apache.servicecomb.samples.common.schema.Assertion;
import org.apache.servicecomb.samples.common.schema.Hello;
import org.apache.servicecomb.samples.common.schema.models.Person;
import org.slf4j.Logger;
@@ -32,17 +33,16 @@ import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.web.client.RestTemplate;
-@Component
-public class SpringmvcConsumerMain {
- private static final Logger LOG =
LoggerFactory.getLogger(SpringmvcConsumerMain.class);
+@Component("SpringmvcHelloClient")
+public class SpringmvcHelloClient {
+ private static final Logger LOG =
LoggerFactory.getLogger(SpringmvcHelloClient.class);
private static RestTemplate restTemplate = RestTemplateBuilder.create();
@RpcReference(microserviceName = "springmvc", schemaId = "springmvcHello")
private static Hello hello;
- public static void main(String[] args) throws Exception {
- BeanUtils.init();
+ public void run() throws Exception {
Person person = new Person();
person.setName("ServiceComb/Java Chassis");
@@ -50,30 +50,40 @@ public class SpringmvcConsumerMain {
// RestTemplate Consumer
String sayHiResult =
restTemplate.postForObject("cse://springmvc/springmvchello/sayhi?name=Java
Chassis", null, String.class);
+ Assertion.assertEquals("Hello Java Chassis", sayHiResult);
+
String sayHiDefaultResult =
restTemplate.postForObject("cse://springmvc/springmvchello/sayhi",
null, String.class);
+ Assertion.assertEquals("Hello test", sayHiDefaultResult);
+
String sayHelloResult =
restTemplate.postForObject("cse://springmvc/springmvchello/sayhello", person,
String.class);
+ Assertion.assertEquals("Hello person ServiceComb/Java Chassis",
sayHelloResult);
+
System.out.println("RestTemplate Consumer or POJO Consumer. You can
choose whatever you like.");
System.out.println("RestTemplate consumer sayhi services: " + sayHiResult);
System.out.println("RestTemplate consumer sayHiDefault services: " +
sayHiDefaultResult);
System.out.println("RestTemplate consumer sayhello services: " +
sayHelloResult);
// POJO Consumer
- System.out.println("POJO consumer sayhi services: " + hello.sayHi("Java
Chassis"));
- System.out.println("POJO consumer sayhello services: " +
hello.sayHello(person));
+ String pojoSayHi = hello.sayHi("Java Chassis");
+ Assertion.assertEquals("Hello Java Chassis", pojoSayHi);
+ String pojoSayHello = hello.sayHello(person);
+ Assertion.assertEquals("Hello person ServiceComb/Java Chassis",
pojoSayHello);
+
+ System.out.println("POJO consumer sayhi services: " + pojoSayHi);
+ System.out.println("POJO consumer sayhello services: " + pojoSayHello);
//AsyncRestTemplate Consumer
CseAsyncRestTemplate cseAsyncRestTemplate = new CseAsyncRestTemplate();
ListenableFuture<ResponseEntity<String>> responseEntityListenableFuture =
cseAsyncRestTemplate
.postForEntity("cse://springmvc/springmvchello/sayhi?name=Java
Chassis", null, String.class);
ResponseEntity<String> responseEntity =
responseEntityListenableFuture.get();
+ Assertion.assertEquals("Hello Java Chassis", responseEntity.getBody());
System.out.println("AsyncRestTemplate Consumer sayHi services: " +
responseEntity.getBody());
HttpEntity<Person> entity = new HttpEntity<>(person);
ListenableFuture<ResponseEntity<String>> listenableFuture =
cseAsyncRestTemplate
.exchange("cse://springmvc/springmvchello/sayhello", HttpMethod.POST,
entity, String.class);
- // ResponseEntity<String> responseEntity1 = listenableFuture.get();
- // System.out.println("AsyncRestTemplate Consumer sayHello services: "
+ responseEntity1.getBody());
listenableFuture.addCallback(
new ListenableFutureCallback<ResponseEntity<String>>() {
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/resources/microservices/hello/hello.yaml
b/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/resources/microservices/hello/hello.yaml
deleted file mode 100644
index 76007e9..0000000
---
a/java-chassis-samples/springmvc-sample/springmvc-consumer/src/main/resources/microservices/hello/hello.yaml
+++ /dev/null
@@ -1,72 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
-swagger: '2.0'
-info:
- title: hello
- version: 1.0.0
- x-java-interface: org.apache.servicecomb.samples.springmvc.Hello
-basePath: /pojo/rest/hello
-produces:
- - application/json
-
-paths:
- /sayhi:
- post:
- operationId: sayHi
- parameters:
- - name: name
- in: body
- required: true
- schema:
- type: string
- responses:
- 200:
- description: 正确返回
- schema:
- type: string
- default:
- description: 默认返回
- schema:
- type: string
- /sayhello:
- post:
- operationId: sayHello
- parameters:
- - name: person
- in: body
- required: true
- schema:
- $ref: "#/definitions/Person"
- responses:
- 200:
- description: 正确返回
- schema:
- type: string
- default:
- description: 默认返回
- schema:
- type: string
-definitions:
- Person:
- type: "object"
- properties:
- name:
- type: "string"
- description: "person name"
- xml:
- name: "Person"
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicEndpoint.java
similarity index 64%
copy from
java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
copy to
java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicEndpoint.java
index c8d8087..35cb47c 100644
---
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
+++
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicEndpoint.java
@@ -17,29 +17,22 @@
package org.apache.servicecomb.samples.springmvc.provider;
-
import javax.ws.rs.core.MediaType;
import org.apache.servicecomb.provider.rest.common.RestSchema;
-import org.apache.servicecomb.samples.common.schema.Hello;
import org.apache.servicecomb.samples.common.schema.models.Person;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-@RestSchema(schemaId = "springmvcHello")
-@RequestMapping(path = "/springmvchello", produces =
MediaType.APPLICATION_JSON)
-public class SpringmvcHelloImpl implements Hello {
- @Override
- @RequestMapping(path = "/sayhi", method = RequestMethod.POST)
- public String sayHi(@RequestParam(name = "name", defaultValue = "test")
String name) {
- return "Hello " + name;
- }
- @Override
- @RequestMapping(path = "/sayhello", method = RequestMethod.POST)
- public String sayHello(@RequestBody Person person) {
- return "Hello person " + person.getName();
+@RestSchema(schemaId = "SpringmvcBasicEndpoint")
+@RequestMapping(path = "/springmvc/basic", produces =
MediaType.APPLICATION_JSON)
+public class SpringmvcBasicEndpoint {
+ @RequestMapping(path = "/postObject", method = RequestMethod.POST)
+ public SpringmvcBasicResponseModel sayHello(@RequestBody
SpringmvcBasicRequestModel requestModel) {
+ SpringmvcBasicResponseModel model = new SpringmvcBasicResponseModel();
+ model.setResponseId(requestModel.getRequestId());
+ model.setResultMessage(requestModel.getName());
+ return model;
}
}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicRequestModel.java
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicRequestModel.java
new file mode 100644
index 0000000..269b325
--- /dev/null
+++
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicRequestModel.java
@@ -0,0 +1,39 @@
+/*
+ * 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.samples.springmvc.provider;
+
+public class SpringmvcBasicRequestModel {
+ private int requestId;
+ private String name;
+
+ public int getRequestId() {
+ return requestId;
+ }
+
+ public void setRequestId(int requestId) {
+ this.requestId = requestId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicResponseModel.java
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicResponseModel.java
new file mode 100644
index 0000000..1e97e8c
--- /dev/null
+++
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcBasicResponseModel.java
@@ -0,0 +1,39 @@
+/*
+ * 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.samples.springmvc.provider;
+
+public class SpringmvcBasicResponseModel {
+ private int responseId;
+ private String resultMessage;
+
+ public int getResponseId() {
+ return responseId;
+ }
+
+ public void setResponseId(int responseId) {
+ this.responseId = responseId;
+ }
+
+ public String getResultMessage() {
+ return resultMessage;
+ }
+
+ public void setResultMessage(String resultMessage) {
+ this.resultMessage = resultMessage;
+ }
+}
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloEndpoint.java
similarity index 97%
rename from
java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
rename to
java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloEndpoint.java
index c8d8087..7f205f1 100644
---
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloImpl.java
+++
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/java/org/apache/servicecomb/samples/springmvc/provider/SpringmvcHelloEndpoint.java
@@ -30,7 +30,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@RestSchema(schemaId = "springmvcHello")
@RequestMapping(path = "/springmvchello", produces =
MediaType.APPLICATION_JSON)
-public class SpringmvcHelloImpl implements Hello {
+public class SpringmvcHelloEndpoint implements Hello {
@Override
@RequestMapping(path = "/sayhi", method = RequestMethod.POST)
public String sayHi(@RequestParam(name = "name", defaultValue = "test")
String name) {
diff --git
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/resources/microservices/hello/hello.yaml
b/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/resources/microservices/hello/hello.yaml
deleted file mode 100644
index 76007e9..0000000
---
a/java-chassis-samples/springmvc-sample/springmvc-provider/src/main/resources/microservices/hello/hello.yaml
+++ /dev/null
@@ -1,72 +0,0 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
-swagger: '2.0'
-info:
- title: hello
- version: 1.0.0
- x-java-interface: org.apache.servicecomb.samples.springmvc.Hello
-basePath: /pojo/rest/hello
-produces:
- - application/json
-
-paths:
- /sayhi:
- post:
- operationId: sayHi
- parameters:
- - name: name
- in: body
- required: true
- schema:
- type: string
- responses:
- 200:
- description: 正确返回
- schema:
- type: string
- default:
- description: 默认返回
- schema:
- type: string
- /sayhello:
- post:
- operationId: sayHello
- parameters:
- - name: person
- in: body
- required: true
- schema:
- $ref: "#/definitions/Person"
- responses:
- 200:
- description: 正确返回
- schema:
- type: string
- default:
- description: 默认返回
- schema:
- type: string
-definitions:
- Person:
- type: "object"
- properties:
- name:
- type: "string"
- description: "person name"
- xml:
- name: "Person"