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/04/28 01:37:58 UTC
[incubator-servicecomb-java-chassis] branch master updated: SCB-440
add pojo archetype implement
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
The following commit(s) were added to refs/heads/master by this push:
new d5d1788 SCB-440 add pojo archetype implement
d5d1788 is described below
commit d5d1788fa8af733dc308c51548e03d1c81abd896
Author: zhengyangyong <ya...@huawei.com>
AuthorDate: Tue Apr 24 09:11:02 2018 +0800
SCB-440 add pojo archetype implement
Signed-off-by: zhengyangyong <ya...@huawei.com>
---
archetypes/business-service-pojo/README.md | 20 ++++
archetypes/business-service-pojo/pom.xml | 111 +++++++++++++++++++++
.../apache/servicecomb/archetypes/Application.java | 28 ++++++
.../org/apache/servicecomb/archetypes/Hello.java | 22 ++++
.../servicecomb/archetypes/HelloConsumer.java | 35 +++++++
.../servicecomb/archetypes/HelloEndpoint.java | 28 ++++++
.../resources/META-INF/spring/provider.bean.xml | 26 +++++
.../src/main/resources/microservice.yaml | 43 ++++++++
8 files changed, 313 insertions(+)
diff --git a/archetypes/business-service-pojo/README.md b/archetypes/business-service-pojo/README.md
new file mode 100644
index 0000000..e6b7a48
--- /dev/null
+++ b/archetypes/business-service-pojo/README.md
@@ -0,0 +1,20 @@
+## Welcome to use ServiceComb Java Chassis
+This project(module) is generate by *org.apache.servicecomb.archetypes:business-service-pojo-archetype*, it use **pojo 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-transparent-rpc/
+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-pojo/pom.xml b/archetypes/business-service-pojo/pom.xml
new file mode 100644
index 0000000..6dfe54c
--- /dev/null
+++ b/archetypes/business-service-pojo/pom.xml
@@ -0,0 +1,111 @@
+<?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.
+ -->
+
+<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">
+ <groupId>org.apache.servicecomb.archetypes</groupId>
+ <artifactId>business-service-pojo</artifactId>
+ <modelVersion>4.0.0</modelVersion>
+ <version>1.0.0-m2-SNAPSHOT</version>
+
+ <properties>
+ <java-chassis.version>1.0.0-m2-SNAPSHOT</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>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-pojo</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</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>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Application.java b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Application.java
new file mode 100644
index 0000000..fd4ba24
--- /dev/null
+++ b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Application.java
@@ -0,0 +1,28 @@
+/*
+ * 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.archetypes;
+
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.foundation.common.utils.Log4jUtils;
+
+public class Application {
+ public static void main(String[] args) throws Exception {
+ Log4jUtils.init();
+ BeanUtils.init();
+ }
+}
\ No newline at end of file
diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Hello.java b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Hello.java
new file mode 100644
index 0000000..301d40e
--- /dev/null
+++ b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/Hello.java
@@ -0,0 +1,22 @@
+/*
+ * 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.archetypes;
+
+public interface Hello {
+ String hello();
+}
\ No newline at end of file
diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.java
new file mode 100644
index 0000000..6e7e742
--- /dev/null
+++ b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloConsumer.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.archetypes;
+
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.springframework.stereotype.Component;
+
+@Component
+public class HelloConsumer {
+ @RpcReference(microserviceName = "business-service", schemaId = "helloEndpoint")
+ private Hello hello;
+
+ public Hello getHello() {
+ return hello;
+ }
+
+ public void invokeHello() {
+ getHello().hello();
+ }
+}
\ No newline at end of file
diff --git a/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java
new file mode 100644
index 0000000..3039921
--- /dev/null
+++ b/archetypes/business-service-pojo/src/main/java/org/apache/servicecomb/archetypes/HelloEndpoint.java
@@ -0,0 +1,28 @@
+/*
+ * 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.archetypes;
+
+import org.apache.servicecomb.provider.pojo.RpcSchema;
+
+@RpcSchema(schemaId = "helloEndpoint")
+public class HelloEndpoint implements Hello {
+
+ public String hello() {
+ return "Hello World!";
+ }
+}
\ No newline at end of file
diff --git a/archetypes/business-service-pojo/src/main/resources/META-INF/spring/provider.bean.xml b/archetypes/business-service-pojo/src/main/resources/META-INF/spring/provider.bean.xml
new file mode 100644
index 0000000..06e30f8
--- /dev/null
+++ b/archetypes/business-service-pojo/src/main/resources/META-INF/spring/provider.bean.xml
@@ -0,0 +1,26 @@
+<?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.
+ -->
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ 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">
+
+ <context:component-scan base-package="org.apache.servicecomb.archetypes"/>
+</beans>
\ No newline at end of file
diff --git a/archetypes/business-service-pojo/src/main/resources/microservice.yaml b/archetypes/business-service-pojo/src/main/resources/microservice.yaml
new file mode 100644
index 0000000..ddf5f39
--- /dev/null
+++ b/archetypes/business-service-pojo/src/main/resources/microservice.yaml
@@ -0,0 +1,43 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#More details can be found :
+# 1.http://servicecomb.incubator.apache.org/users/service-definition/
+# 2.http://servicecomb.incubator.apache.org/users/service-configurations/
+# 3.http://servicecomb.incubator.apache.org/users/communicate-protocol/
+
+#Indicates an application name
+APPLICATION_ID: business
+service_description:
+#Indicates a microservice name
+#The microservice name should be unique within an application.
+#The name can contain digits, uppercase and lowercase letters, hyphens(-), underscores(_), and periods(.); and can neither start nor end with punctuations.
+#The naming rule is as follows: ^[a-zA-Z0-9]+$|^[a-zA-Z0-9][a-zA-Z0-9_-.]*[a-zA-Z0-9]$.
+ name: business-service
+#Indicates a service version
+ version: 1.0.0
+cse:
+ service:
+ #Specifies the service center IP address.
+ registry:
+ address: http://127.0.0.1:30100
+ #Specifies the rest transport listening IP address.
+ rest:
+ address: 0.0.0.0:8080
+ #Specifies the highway transport listening IP address.
+ highway:
+ address: 0.0.0.0:7070
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
liubao@apache.org.