You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2019/06/21 07:09:29 UTC
[servicecomb-toolkit] 13/49: Support JAX-RS programming model
This is an automated email from the ASF dual-hosted git repository.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-toolkit.git
commit 724530468772e99748dc47def6beda76e2eddbcb
Author: MabinGo <bi...@huawei.com>
AuthorDate: Fri May 24 10:38:28 2019 +0800
Support JAX-RS programming model
Signed-off-by: MabinGo <bi...@huawei.com>
---
.../toolkit/codegen/RemoveImplSuffixLambda.java | 14 +--
.../toolkit/codegen/ServiceCombCodegen.java | 14 +--
.../src/main/resources/ServiceComb/README.mustache | 20 ----
.../ServiceComb/consumer/microservice.mustache | 17 ---
.../resources/ServiceComb/enumOuterClass.mustache | 1 -
.../libraries/JAX-RS/Application.mustache | 11 ++
.../ServiceComb/libraries/JAX-RS/api.mustache | 39 +++++++
.../ServiceComb/libraries/JAX-RS/api_test.mustache | 39 +++++++
.../libraries/JAX-RS/bodyParams.mustache | 1 +
.../libraries/JAX-RS/formParams.mustache | 2 +
.../libraries/JAX-RS/headerParams.mustache | 1 +
.../libraries/JAX-RS/pathParams.mustache | 1 +
.../ServiceComb/libraries/JAX-RS/pom.mustache | 126 +++++++++++++++++++++
.../libraries/JAX-RS/queryParams.mustache | 1 +
.../libraries/SpringMVC/Application.mustache | 17 ---
.../libraries/SpringMVC/api_test.mustache | 1 +
.../src/main/resources/ServiceComb/log4j2.mustache | 18 ---
.../ServiceComb/provider/microservice.mustache | 17 ---
.../servicecomb/toolkit/codegen/GeneratorTest.java | 1 +
.../toolkit/{ => common}/ContractsUtils.java | 2 +-
.../toolkit/{ => common}/ImmediateClassLoader.java | 2 +-
.../docgen/ContractsAsciidocGenerator.java | 4 +-
.../docgen/ContractsSwaggerUIGenerator.java | 2 +-
.../{ => toolkit}/docgen/DocGenerator.java | 2 +-
.../{ => toolkit}/docgen/DocGeneratorManager.java | 2 +-
...apache.servicecomb.toolkit.docgen.DocGenerator} | 4 +-
.../servicecomb/toolkit/cli/CodeGenerate.java | 4 +-
.../servicecomb/toolkit/cli/DocGenerate.java | 5 +-
.../src/main/resources/application.properties | 17 +++
.../apache/servicecomb/toolkit/cli/CliTest.java | 2 +-
.../toolkit/plugin/ContractGenerator.java | 2 +-
.../toolkit/plugin/GenerateContractsDocMojo.java | 2 +-
32 files changed, 268 insertions(+), 123 deletions(-)
diff --git a/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/RemoveImplSuffixLambda.java b/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/RemoveImplSuffixLambda.java
index 519a584..c322667 100644
--- a/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/RemoveImplSuffixLambda.java
+++ b/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/RemoveImplSuffixLambda.java
@@ -17,23 +17,21 @@
package org.apache.servicecomb.toolkit.codegen;
-import com.samskivert.mustache.Mustache;
-import com.samskivert.mustache.Template;
-
import java.io.IOException;
import java.io.Writer;
-public class RemoveImplSuffixLambda implements Mustache.Lambda {
+import com.samskivert.mustache.Mustache;
+import com.samskivert.mustache.Template;
+
+public class RemoveImplSuffixLambda implements Mustache.Lambda {
@Override
public void execute(Template.Fragment fragment, Writer writer) throws IOException {
String text = fragment.execute();
- if(text.endsWith("Impl")){
- text = text.substring(0,text.lastIndexOf("Impl"));
+ if (text.endsWith("Impl")) {
+ text = text.substring(0, text.lastIndexOf("Impl"));
}
writer.write(text);
-
}
-
}
diff --git a/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/ServiceCombCodegen.java b/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/ServiceCombCodegen.java
index 36efe5b..668db24 100755
--- a/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/ServiceCombCodegen.java
+++ b/code-generator/src/main/java/org/apache/servicecomb/toolkit/codegen/ServiceCombCodegen.java
@@ -37,6 +37,8 @@ public class ServiceCombCodegen extends AbstractJavaCodegen implements CodegenCo
private static final String POJO_LIBRARY = "POJO";
+ private static final String JAX_RS_LIBRARY = "JAX-RS";
+
private String mainClassPackage;
private String providerProject = "provider";
@@ -101,6 +103,7 @@ public class ServiceCombCodegen extends AbstractJavaCodegen implements CodegenCo
supportedLibraries.put(DEFAULT_LIBRARY, "ServiceComb Server application using the springboot programming model.");
supportedLibraries.put(POJO_LIBRARY, "ServiceComb Server application using the pojo programming model.");
+ supportedLibraries.put(JAX_RS_LIBRARY, "ServiceComb Server application using the jax-rs programming model.");
setLibrary(DEFAULT_LIBRARY);
@@ -129,8 +132,8 @@ public class ServiceCombCodegen extends AbstractJavaCodegen implements CodegenCo
}
if (pojoApiInterfaceTemplate.equals(templateName)) {
String suffix = apiTemplateFiles().get(templateName);
- String pojoApiInterfaceName = pojoApiInterfaceFolder() + File.separator + camelize(tag) + "Api" + suffix;
- additionalProperties.put("pojoApiInterfaceName",camelize(tag) + "Api");
+ String pojoApiInterfaceName = pojoApiInterfaceFolder() + File.separator + camelize(tag) + "Api" + suffix;
+ additionalProperties.put("pojoApiInterfaceName", camelize(tag) + "Api");
return pojoApiInterfaceName;
}
return super.apiFilename(templateName, tag);
@@ -201,11 +204,6 @@ public class ServiceCombCodegen extends AbstractJavaCodegen implements CodegenCo
"pom.xml")
);
- supportingFiles.add(new SupportingFile("README.mustache",
- providerProject,
- "README.md")
- );
-
supportingFiles.add(new SupportingFile("Application.mustache",
mainClassFolder(providerProject),
"Application.java")
@@ -264,7 +262,7 @@ public class ServiceCombCodegen extends AbstractJavaCodegen implements CodegenCo
return apiName;
}
- if(POJO_LIBRARY.equals(getLibrary())){
+ if (POJO_LIBRARY.equals(getLibrary())) {
return initialCaps(name) + "ApiImpl";
}
diff --git a/code-generator/src/main/resources/ServiceComb/README.mustache b/code-generator/src/main/resources/ServiceComb/README.mustache
deleted file mode 100755
index 2258a49..0000000
--- a/code-generator/src/main/resources/ServiceComb/README.mustache
+++ /dev/null
@@ -1,20 +0,0 @@
-## Welcome to use ServiceComb Java Chassis
-This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-springmvc-archetype*, it use **springmvc provider** to develop service producer.
-
-### More works can be done further:
-1. Modify "HelloImpl", add your business service logic, or create some new producers to provide your services. More details can be found : http://servicecomb.apache.org/users/develop-with-springmvc/
-2. Modify "microservice.yaml", change APPLICATION_ID, service_description.name, version, and service center address, endpoints publish address etc. More details can be found : http://servicecomb.apache.org/users/service-definition/
-3. Modify setting value of "mainClass" in pom.xml for package.
-
-### Package your service
-Under project(module) root folder, run
-```bash
-mvn package
-```
-Then you can get outputs in target folder:
-- lib : contains all dependencies jars
-- xxxxxx-{version}.jar
-```bash
-java -jar xxxxxx-{version}.jar
-```
-*Notice: If you need to modify config setting in "microservice.yaml" like service center address but don't want repackage the executable jar, **you can direct place a new "microservice.yaml" file in same folder, then settings will be overridden.***
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/consumer/microservice.mustache b/code-generator/src/main/resources/ServiceComb/consumer/microservice.mustache
index 72d38b6..113cb37 100755
--- a/code-generator/src/main/resources/ServiceComb/consumer/microservice.mustache
+++ b/code-generator/src/main/resources/ServiceComb/consumer/microservice.mustache
@@ -1,20 +1,3 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
#Indicates an application name
APPLICATION_ID: {{applicationId}}
service_description:
diff --git a/code-generator/src/main/resources/ServiceComb/enumOuterClass.mustache b/code-generator/src/main/resources/ServiceComb/enumOuterClass.mustache
index a5f0034..6666a6a 100755
--- a/code-generator/src/main/resources/ServiceComb/enumOuterClass.mustache
+++ b/code-generator/src/main/resources/ServiceComb/enumOuterClass.mustache
@@ -1,4 +1,3 @@
-
/**
* {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}
*/
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/Application.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/Application.mustache
new file mode 100755
index 0000000..fda8d43
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/Application.mustache
@@ -0,0 +1,11 @@
+package {{mainClassPackage}};
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+
+public class Application {
+
+ public static void main(String[] args) throws Exception {
+ System.setProperty("local.registry.file", "notExistJustForceLocal");
+ BeanUtils.init();
+ }
+}
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/api.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/api.mustache
new file mode 100755
index 0000000..750d5ba
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/api.mustache
@@ -0,0 +1,39 @@
+package {{package}};
+
+{{#models}}import {{modelPackage}}.*;{{/models}}
+import io.swagger.annotations.ApiParam;
+
+{{#imports}}import {{import}};
+{{/imports}}
+
+import java.util.Map;
+import java.util.List;
+
+import java.io.InputStream;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.Part;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.*;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+
+@RestSchema(schemaId = "{{#camelcase}}{{classname}}{{/camelcase}}")
+@Path("/")
+{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+{{#operations}}
+public class {{classname}} {
+
+{{#operation}}
+ @Path("{{{path}}}")
+ @{{httpMethod}}
+ {{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
+ {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
+ public {{>returnTypes}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
+ return null;
+ }
+{{/operation}}
+}
+{{/operations}}
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/api_test.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/api_test.mustache
new file mode 100755
index 0000000..8f93bb4
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/api_test.mustache
@@ -0,0 +1,39 @@
+package {{package}};
+
+{{#imports}}import {{import}};
+{{/imports}}
+import java.util.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class {{classname}}Test {
+@Autowired
+private {{classname}} api;
+{{#operations}}
+ {{#operation}}
+ @Test
+ public void {{operationId}}Test() throws Exception {
+ {{#allParams}}
+ {{^isFile}}
+ {{{dataType}}} {{paramName}} = {{{example}}};
+ {{/isFile}}
+ {{#isFile}}
+ org.springframework.web.multipart.MultipartFile {{paramName}} = null;
+ {{/isFile}}
+ {{/allParams}}
+ ResponseEntity<{{>returnTypes}}> responseEntity = api.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+ assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
+ }
+ {{/operation}}
+{{/operations}}
+}
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/bodyParams.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/bodyParams.mustache
new file mode 100755
index 0000000..bb1d6ff
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/bodyParams.mustache
@@ -0,0 +1 @@
+{{#isBodyParam}} {{{dataType}}} {{paramName}}{{/isBodyParam}}
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/formParams.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/formParams.mustache
new file mode 100755
index 0000000..5a4ebf2
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/formParams.mustache
@@ -0,0 +1,2 @@
+{{#isFormParam}}{{#notFile}} {{#vendorExtensions.x-multipart}}@FormDataParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{^vendorExtensions.x-multipart}} {{#defaultValue}} @DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @FormParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/vendorExtensions.x-multipart}}{{/notFile}}{{#isFile}}
+ Part {{paramName}}{{/isFile}}{{/isFormParam}}
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/headerParams.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/headerParams.mustache
new file mode 100755
index 0000000..25d690c
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/headerParams.mustache
@@ -0,0 +1 @@
+{{#isHeaderParam}}@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/pathParams.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/pathParams.mustache
new file mode 100755
index 0000000..10c55d6
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/pathParams.mustache
@@ -0,0 +1 @@
+{{#isPathParam}}@PathParam("{{paramName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/pom.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/pom.mustache
new file mode 100755
index 0000000..35ec7b1
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/pom.mustache
@@ -0,0 +1,126 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <artifactId>{{artifactId}}</artifactId>
+ <groupId>{{groupId}}</groupId>
+ <version>{{artifactVersion}}</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>provider</artifactId>
+ <packaging>jar</packaging>
+ <name>{{artifactId}}</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <java-chassis.version>1.2.0</java-chassis.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>java-chassis-dependencies</artifactId>
+ <version>${java-chassis.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>{{groupId}}</groupId>
+ <artifactId>model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>handler-bizkeeper</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>handler-loadbalance</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>handler-flowcontrol-qps</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>transport-highway</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>transport-rest-vertx</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>provider-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!--for package and deploy-->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.6</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>lib/</classpathPrefix>
+ <!--change to your main class-->
+ <mainClass>${package}.Application</mainClass>
+ </manifest>
+ <manifestEntries>
+ <Class-Path>. </Class-Path>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/queryParams.mustache b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/queryParams.mustache
new file mode 100755
index 0000000..458b8de
--- /dev/null
+++ b/code-generator/src/main/resources/ServiceComb/libraries/JAX-RS/queryParams.mustache
@@ -0,0 +1 @@
+{{#isQueryParam}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
\ No newline at end of file
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/Application.mustache b/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/Application.mustache
index aef3762..fda8d43 100755
--- a/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/Application.mustache
+++ b/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/Application.mustache
@@ -1,20 +1,3 @@
-/*
- * 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 {{mainClassPackage}};
import org.apache.servicecomb.foundation.common.utils.BeanUtils;
diff --git a/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/api_test.mustache b/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/api_test.mustache
index 8d2d3a2..3a7bed4 100755
--- a/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/api_test.mustache
+++ b/code-generator/src/main/resources/ServiceComb/libraries/SpringMVC/api_test.mustache
@@ -1,4 +1,5 @@
package {{package}};
+
{{#imports}}import {{import}};
{{/imports}}
import java.util.*;
diff --git a/code-generator/src/main/resources/ServiceComb/log4j2.mustache b/code-generator/src/main/resources/ServiceComb/log4j2.mustache
index e43e15b..8d29bbd 100755
--- a/code-generator/src/main/resources/ServiceComb/log4j2.mustache
+++ b/code-generator/src/main/resources/ServiceComb/log4j2.mustache
@@ -1,21 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-
<!--this is sample configuration, please modify as your wish-->
<configuration>
<Properties>
diff --git a/code-generator/src/main/resources/ServiceComb/provider/microservice.mustache b/code-generator/src/main/resources/ServiceComb/provider/microservice.mustache
index fba2e77..6846c4a 100755
--- a/code-generator/src/main/resources/ServiceComb/provider/microservice.mustache
+++ b/code-generator/src/main/resources/ServiceComb/provider/microservice.mustache
@@ -1,20 +1,3 @@
-## ---------------------------------------------------------------------------
-## 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.
-## ---------------------------------------------------------------------------
-
#Indicates an application name
APPLICATION_ID: {{applicationId}}
service_description:
diff --git a/code-generator/src/test/java/org/apache/servicecomb/toolkit/codegen/GeneratorTest.java b/code-generator/src/test/java/org/apache/servicecomb/toolkit/codegen/GeneratorTest.java
index 3156fae..08f5ae3 100755
--- a/code-generator/src/test/java/org/apache/servicecomb/toolkit/codegen/GeneratorTest.java
+++ b/code-generator/src/test/java/org/apache/servicecomb/toolkit/codegen/GeneratorTest.java
@@ -39,6 +39,7 @@ public class GeneratorTest {
generateCode("SpringMVC");
generateCode("POJO");
+ generateCode("JAX-RS");
}
private void generateCode(String programmingModel) throws IOException, URISyntaxException {
diff --git a/common/src/main/java/org/apache/servicecomb/toolkit/ContractsUtils.java b/common/src/main/java/org/apache/servicecomb/toolkit/common/ContractsUtils.java
similarity index 99%
rename from common/src/main/java/org/apache/servicecomb/toolkit/ContractsUtils.java
rename to common/src/main/java/org/apache/servicecomb/toolkit/common/ContractsUtils.java
index 032e458..01143f0 100755
--- a/common/src/main/java/org/apache/servicecomb/toolkit/ContractsUtils.java
+++ b/common/src/main/java/org/apache/servicecomb/toolkit/common/ContractsUtils.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.servicecomb.toolkit;
+package org.apache.servicecomb.toolkit.common;
import java.io.File;
import java.io.IOException;
diff --git a/common/src/main/java/org/apache/servicecomb/toolkit/ImmediateClassLoader.java b/common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
similarity index 97%
rename from common/src/main/java/org/apache/servicecomb/toolkit/ImmediateClassLoader.java
rename to common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
index 421aa1a..f03314a 100755
--- a/common/src/main/java/org/apache/servicecomb/toolkit/ImmediateClassLoader.java
+++ b/common/src/main/java/org/apache/servicecomb/toolkit/common/ImmediateClassLoader.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.servicecomb.toolkit;
+package org.apache.servicecomb.toolkit.common;
import java.io.File;
import java.net.URL;
diff --git a/doc-generator/src/main/java/org/apache/servicecomb/docgen/ContractsAsciidocGenerator.java b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsAsciidocGenerator.java
similarity index 96%
rename from doc-generator/src/main/java/org/apache/servicecomb/docgen/ContractsAsciidocGenerator.java
rename to doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsAsciidocGenerator.java
index 1e28116..a653ee4 100755
--- a/doc-generator/src/main/java/org/apache/servicecomb/docgen/ContractsAsciidocGenerator.java
+++ b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsAsciidocGenerator.java
@@ -15,12 +15,10 @@
* limitations under the License.
*/
-package org.apache.servicecomb.docgen;
+package org.apache.servicecomb.toolkit.docgen;
import java.io.IOException;
import java.nio.file.Files;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
diff --git a/doc-generator/src/main/java/org/apache/servicecomb/docgen/ContractsSwaggerUIGenerator.java b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
similarity index 98%
rename from doc-generator/src/main/java/org/apache/servicecomb/docgen/ContractsSwaggerUIGenerator.java
rename to doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
index 2f154b5..26a0aa1 100755
--- a/doc-generator/src/main/java/org/apache/servicecomb/docgen/ContractsSwaggerUIGenerator.java
+++ b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/ContractsSwaggerUIGenerator.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.servicecomb.docgen;
+package org.apache.servicecomb.toolkit.docgen;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
diff --git a/doc-generator/src/main/java/org/apache/servicecomb/docgen/DocGenerator.java b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/DocGenerator.java
similarity index 95%
rename from doc-generator/src/main/java/org/apache/servicecomb/docgen/DocGenerator.java
rename to doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/DocGenerator.java
index 6381e5e..6fb053a 100755
--- a/doc-generator/src/main/java/org/apache/servicecomb/docgen/DocGenerator.java
+++ b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/DocGenerator.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.servicecomb.docgen;
+package org.apache.servicecomb.toolkit.docgen;
import io.swagger.models.Swagger;
diff --git a/doc-generator/src/main/java/org/apache/servicecomb/docgen/DocGeneratorManager.java b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/DocGeneratorManager.java
similarity index 97%
rename from doc-generator/src/main/java/org/apache/servicecomb/docgen/DocGeneratorManager.java
rename to doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/DocGeneratorManager.java
index 17566b8..a2b6bc3 100755
--- a/doc-generator/src/main/java/org/apache/servicecomb/docgen/DocGeneratorManager.java
+++ b/doc-generator/src/main/java/org/apache/servicecomb/toolkit/docgen/DocGeneratorManager.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.servicecomb.docgen;
+package org.apache.servicecomb.toolkit.docgen;
import java.util.ServiceLoader;
import java.util.concurrent.CopyOnWriteArrayList;
diff --git a/doc-generator/src/main/resources/META-INF/services/org.apache.servicecomb.docgen.DocGenerator b/doc-generator/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.docgen.DocGenerator
similarity index 85%
rename from doc-generator/src/main/resources/META-INF/services/org.apache.servicecomb.docgen.DocGenerator
rename to doc-generator/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.docgen.DocGenerator
index aa6fb85..5b1bb73 100755
--- a/doc-generator/src/main/resources/META-INF/services/org.apache.servicecomb.docgen.DocGenerator
+++ b/doc-generator/src/main/resources/META-INF/services/org.apache.servicecomb.toolkit.docgen.DocGenerator
@@ -15,5 +15,5 @@
# limitations under the License.
#
-org.apache.servicecomb.docgen.ContractsAsciidocGenerator
-org.apache.servicecomb.docgen.ContractsSwaggerUIGenerator
\ No newline at end of file
+org.apache.servicecomb.toolkit.docgen.ContractsAsciidocGenerator
+org.apache.servicecomb.toolkit.docgen.ContractsSwaggerUIGenerator
\ No newline at end of file
diff --git a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
index 2e5da64..4034812 100755
--- a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
+++ b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/CodeGenerate.java
@@ -42,7 +42,7 @@ public class CodeGenerate implements Runnable {
description = "programming model, as SpringMVC, POJO or JAX-RS")
private String programmingModel;
- @Option(name = {"-m", "--microservice-framework"}, title = "language",
+ @Option(name = {"-m", "--microservice-framework"}, title = "framework",
description = "microservice-framework")
private String framework = "ServiceComb";
@@ -59,7 +59,7 @@ public class CodeGenerate implements Runnable {
private String groupId;
@Option(name = {"--artifact-id"}, title = "artifact id",
- description = "artifact version in generated microservice project")
+ description = "artifact id in generated microservice project")
private String artifactId;
@Option(name = {"--artifact-version"}, title = "artifact version",
diff --git a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java
index 755abcf..85fc0e6 100755
--- a/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java
+++ b/toolkit-cli/src/main/java/org/apache/servicecomb/toolkit/cli/DocGenerate.java
@@ -26,7 +26,7 @@ import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
-import org.apache.servicecomb.docgen.DocGeneratorManager;
+import org.apache.servicecomb.toolkit.docgen.DocGeneratorManager;
import org.apache.servicecomb.swagger.SwaggerUtils;
import io.airlift.airline.Command;
@@ -69,7 +69,8 @@ public class DocGenerate implements Runnable {
} else {
DocGeneratorManager.generate(SwaggerUtils.parseSwagger(new File(specFile).toURI().toURL()),
- output + File.separator + new File(specFile).getName().substring(0, new File(specFile).getName().indexOf(".")),
+ output + File.separator + new File(specFile).getName()
+ .substring(0, new File(specFile).getName().indexOf(".")),
format);
}
} catch (IOException e) {
diff --git a/toolkit-cli/src/main/resources/application.properties b/toolkit-cli/src/main/resources/application.properties
index e5683df..a278788 100755
--- a/toolkit-cli/src/main/resources/application.properties
+++ b/toolkit-cli/src/main/resources/application.properties
@@ -1 +1,18 @@
+#
+# 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.
+#
+
version=${project.version}
\ No newline at end of file
diff --git a/toolkit-cli/src/test/java/org/apache/servicecomb/toolkit/cli/CliTest.java b/toolkit-cli/src/test/java/org/apache/servicecomb/toolkit/cli/CliTest.java
index f8ef465..b2a7664 100755
--- a/toolkit-cli/src/test/java/org/apache/servicecomb/toolkit/cli/CliTest.java
+++ b/toolkit-cli/src/test/java/org/apache/servicecomb/toolkit/cli/CliTest.java
@@ -31,7 +31,7 @@ public class CliTest {
@Test
public void generateServiceCombCodeFromSingleContract() throws IOException {
- String[] programModels = new String[] {"SpringMVC","POJO"};
+ String[] programModels = new String[] {"SpringMVC", "POJO", "JAX-RS"};
Path tempDir = Files.createTempDirectory(null);
Arrays.stream(programModels).forEach(model -> {
try {
diff --git a/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/ContractGenerator.java b/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/ContractGenerator.java
index 85bce32..128dcaa 100755
--- a/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/ContractGenerator.java
+++ b/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/ContractGenerator.java
@@ -24,7 +24,7 @@ import java.util.List;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.project.MavenProject;
-import org.apache.servicecomb.toolkit.ContractsUtils;
+import org.apache.servicecomb.toolkit.common.ContractsUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/GenerateContractsDocMojo.java b/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/GenerateContractsDocMojo.java
index 200d177..c36cd3a 100755
--- a/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/GenerateContractsDocMojo.java
+++ b/toolkit-maven-plugin/src/main/java/org/apache/servicecomb/toolkit/plugin/GenerateContractsDocMojo.java
@@ -35,7 +35,7 @@ import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
-import org.apache.servicecomb.docgen.DocGeneratorManager;
+import org.apache.servicecomb.toolkit.docgen.DocGeneratorManager;
import org.apache.servicecomb.swagger.SwaggerUtils;
@Mojo(name = "generateDoc", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE)