You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/05/03 06:20:55 UTC

[incubator-servicecomb-java-chassis] 02/09: SCB-527 adjust jaxrs structure

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/incubator-servicecomb-java-chassis.git

commit 461fb2daf0127729263238b244e96eb97ebc628a
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Sat Apr 28 11:33:52 2018 +0800

    SCB-527 adjust jaxrs structure
    
    Signed-off-by: zhengyangyong <ya...@huawei.com>
---
 archetypes/business-service-jaxrs/pom.xml          | 111 +++++----------------
 .../META-INF/maven/archetype-metadata.xml          |  26 +++++
 .../main/resources/archetype-resources/README.md   |  20 ++++
 .../main/resources/archetype-resources}/pom.xml    |   9 +-
 .../src/main/java}/Application.java                |   2 +-
 .../src/main/java}/HelloConsumer.java              |   2 +-
 .../src/main/java}/HelloImpl.java                  |   2 +-
 .../resources}/META-INF/spring/provider.bean.xml   |   4 +-
 .../src/main/resources}/microservice.yaml          |   0
 archetypes/pom.xml                                 |   2 +-
 10 files changed, 79 insertions(+), 99 deletions(-)

diff --git a/archetypes/business-service-jaxrs/pom.xml b/archetypes/business-service-jaxrs/pom.xml
index 4572577..7eb6e11 100644
--- a/archetypes/business-service-jaxrs/pom.xml
+++ b/archetypes/business-service-jaxrs/pom.xml
@@ -20,103 +20,42 @@
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <parent>
-    <groupId>org.apache.servicecomb.archetypes</groupId>
+    <groupId>org.apache.servicecomb</groupId>
     <artifactId>archetypes</artifactId>
     <version>1.0.0-m2-SNAPSHOT</version>
   </parent>
 
+  <groupId>org.apache.servicecomb.archetypes</groupId>
   <name>Java Chassis::Archetypes::JAXRS</name>
   <artifactId>business-service-jaxrs-archetype</artifactId>
+  <packaging>maven-archetype</packaging>
   <modelVersion>4.0.0</modelVersion>
 
   <properties>
-    <java-chassis.version>1.0.0-m2-SNAPSHOT</java-chassis.version>
+    <maven-archetype-packaging-version>2.3</maven-archetype-packaging-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>
-    <!--for provider-->
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>transport-rest-vertx</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>transport-highway</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>provider-jaxrs</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-log4j12</artifactId>
-    </dependency>
-
-    <!--for consumer-->
-    <dependency>
-      <groupId>org.apache.servicecomb</groupId>
-      <artifactId>provider-springmvc</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>${your-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>
+    <extensions>
+      <extension>
+        <groupId>org.apache.maven.archetype</groupId>
+        <artifactId>archetype-packaging</artifactId>
+        <version>${maven-archetype-packaging-version}</version>
+      </extension>
+    </extensions>
+
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>false</filtering>
+      </resource>
+      <resource>
+        <directory>src/main/resources-filtered</directory>
+        <filtering>true</filtering>
+        <includes>
+          <include>**/archetype-metadata.xml</include>
+        </includes>
+      </resource>
+    </resources>
   </build>
 </project>
\ No newline at end of file
diff --git a/archetypes/business-service-jaxrs/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml b/archetypes/business-service-jaxrs/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..dc3c3db
--- /dev/null
+++ b/archetypes/business-service-jaxrs/src/main/resources-filtered/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,26 @@
+<archetype-descriptor
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd"
+  name="camel-archetype-java"
+  xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <fileSets>
+    <fileSet filtered="true" packaged="true" encoding="UTF-8">
+      <directory>src/main/java</directory>
+      <includes>
+        <include>**/*.java</include>
+      </includes>
+    </fileSet>
+    <fileSet filtered="true" encoding="UTF-8">
+      <directory>src/main/resources</directory>
+      <includes>
+        <include>**/*</include>
+      </includes>
+    </fileSet>
+    <fileSet encoding="UTF-8">
+      <directory></directory>
+      <includes>
+        <include>README.md</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</archetype-descriptor>
\ No newline at end of file
diff --git a/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/README.md b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/README.md
new file mode 100644
index 0000000..43c1dac
--- /dev/null
+++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/README.md
@@ -0,0 +1,20 @@
+## Welcome to use ServiceComb Java Chassis
+This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-jaxrs-archetype*, it use **jaxrs provider** to develop service endpoint.  
+
+### More works can be done further:
+1. Modify "HelloEndpoint", add your business service logic, or create some new endpoints to provide your services. More details can be found : http://servicecomb.incubator.apache.org/users/develop-with-jax-rs/
+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.incubator.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/archetypes/business-service-jaxrs/pom.xml b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/pom.xml
similarity index 94%
copy from archetypes/business-service-jaxrs/pom.xml
copy to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/pom.xml
index 4572577..5b9cbcd 100644
--- a/archetypes/business-service-jaxrs/pom.xml
+++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/pom.xml
@@ -19,14 +19,9 @@
 <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/xsd/maven-4.0.0.xsd">
-  <parent>
-    <groupId>org.apache.servicecomb.archetypes</groupId>
-    <artifactId>archetypes</artifactId>
-    <version>1.0.0-m2-SNAPSHOT</version>
-  </parent>
-
-  <name>Java Chassis::Archetypes::JAXRS</name>
+  <groupId>org.apache.servicecomb.archetypes</groupId>
   <artifactId>business-service-jaxrs-archetype</artifactId>
+  <version>1.0.0-m2-SNAPSHOT</version>
   <modelVersion>4.0.0</modelVersion>
 
   <properties>
diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/Application.java b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/Application.java
similarity index 96%
rename from archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/Application.java
rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/Application.java
index f803efc..9371b4e 100644
--- a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/Application.java
+++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/Application.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.archetypes;
+package ${groupId};
 
 import org.apache.servicecomb.foundation.common.utils.BeanUtils;
 import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java
similarity index 96%
rename from archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java
rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java
index 26c6205..f89adf8 100644
--- a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java
+++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloConsumer.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.archetypes;
+package ${groupId};
 
 import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
 import org.springframework.web.client.RestTemplate;
diff --git a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloImpl.java b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloImpl.java
similarity index 96%
rename from archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloImpl.java
rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloImpl.java
index 3891919..25bc12f 100644
--- a/archetypes/business-service-jaxrs/src/main/java/org/apache/servicecomb/archetypes/HelloImpl.java
+++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/java/HelloImpl.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.archetypes;
+package ${groupId};
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
diff --git a/archetypes/business-service-jaxrs/src/main/resources/META-INF/spring/provider.bean.xml b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml
similarity index 91%
rename from archetypes/business-service-jaxrs/src/main/resources/META-INF/spring/provider.bean.xml
rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml
index 43399a5..34a688d 100644
--- a/archetypes/business-service-jaxrs/src/main/resources/META-INF/spring/provider.bean.xml
+++ b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/META-INF/spring/provider.bean.xml
@@ -22,6 +22,6 @@
   xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
 		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
 
-  <!--change to your endpoint package-->
-  <context:component-scan base-package="org.apache.servicecomb.archetypes"/>
+  <!--change to your schema(impl) bean package-->
+  <context:component-scan base-package="${groupId}"/>
 </beans>
diff --git a/archetypes/business-service-jaxrs/src/main/resources/microservice.yaml b/archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/microservice.yaml
similarity index 100%
rename from archetypes/business-service-jaxrs/src/main/resources/microservice.yaml
rename to archetypes/business-service-jaxrs/src/main/resources/archetype-resources/src/main/resources/microservice.yaml
diff --git a/archetypes/pom.xml b/archetypes/pom.xml
index 64ce847..918dd5a 100644
--- a/archetypes/pom.xml
+++ b/archetypes/pom.xml
@@ -24,7 +24,7 @@
     <version>1.0.0-m2-SNAPSHOT</version>
     <relativePath>../parent</relativePath>
   </parent>
-  <groupId>org.apache.servicecomb.archetypes</groupId>
+
   <artifactId>archetypes</artifactId>
   <name>Java Chassis::Archetypes</name>
   <packaging>pom</packaging>

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.