You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by hy...@apache.org on 2020/10/29 02:33:28 UTC
[dubbo-samples] branch master updated: Add webservice sample (#167)
This is an automated email from the ASF dual-hosted git repository.
hyunkun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new c7c3a95 Add webservice sample (#167)
c7c3a95 is described below
commit c7c3a95bc21149c66fe35afc2ce4cf2d6e3420dd
Author: tswstarplanet <ts...@apache.org>
AuthorDate: Thu Oct 29 10:32:56 2020 +0800
Add webservice sample (#167)
---
.../dubbo-samples-webservice-consumer/pom.xml | 133 ++++++++++++++++
.../samples/webservice/consumer/Application.java | 31 ++++
.../META-INF/dubbo/org.apache.dubbo.rpc.Protocol | 1 +
.../src/main/resources/dubbo.properties | 1 +
.../src/main/resources/log4j.properties | 16 ++
.../spring/dubbo-samples-webservice-consumer.xml | 29 ++++
.../dubbo-samples-webservice-interface/pom.xml | 31 ++++
.../dubbo/samples/webservice/DemoService.java | 21 +++
.../dubbo-samples-webservice-provider/pom.xml | 170 +++++++++++++++++++++
.../webservice/provider/impl/DemoServiceImpl.java | 26 ++++
.../src/main/resources/log4j.properties | 13 ++
.../src/main/resources/spring/spring.xml | 43 ++++++
.../src/main/webapp/WEB-INF/web.xml | 49 ++++++
.../src/main/webapp/index.jsp | 25 +++
java/dubbo-samples-webservice/pom.xml | 53 +++++++
java/pom.xml | 1 +
16 files changed, 643 insertions(+)
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/pom.xml b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/pom.xml
new file mode 100644
index 0000000..b9ffe64
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/pom.xml
@@ -0,0 +1,133 @@
+<?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">
+ <parent>
+ <artifactId>dubbo-samples-webservice</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-webservice-consumer</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <slf4j-log4j12.version>1.7.21</slf4j-log4j12.version>
+ <servlet-api.version>2.5</servlet-api.version>
+ <jsp-api.version>2.2</jsp-api.version>
+ <jstl.version>1.2</jstl.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <commons-lang3.version>3.4</commons-lang3.version>
+ <dubbo.version>2.7.7</dubbo.version>
+ <cxf.version>3.3.7</cxf.version>
+ <zookeeper.version>3.4.13</zookeeper.version>
+ <curator-recipes.version>4.0.1</curator-recipes.version>
+ <netty-all.version>4.1.25.Final</netty-all.version>
+ <jsonrpc4j.version>1.5.3</jsonrpc4j.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-webservice-interface</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>${zookeeper.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>slf4j-api</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-log4j12</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-recipes</artifactId>
+ <version>${curator-recipes.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-api</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.github.briandilley.jsonrpc4j</groupId>
+ <artifactId>jsonrpc4j</artifactId>
+ <version>${jsonrpc4j.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jackson-annotations</artifactId>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-api</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-simple</artifactId>
+ <version>${cxf.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>stax-ex</artifactId>
+ <groupId>org.jvnet.staxex</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>javax.xml.soap-api</artifactId>
+ <groupId>javax.xml.soap</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/java/org/apache/dubbo/samples/webservice/consumer/Application.java b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/java/org/apache/dubbo/samples/webservice/consumer/Application.java
new file mode 100644
index 0000000..a23e827
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/java/org/apache/dubbo/samples/webservice/consumer/Application.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed 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.dubbo.samples.webservice.consumer;
+
+import org.apache.dubbo.samples.webservice.DemoService;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Application {
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-samples-webservice-consumer.xml");
+ context.start();
+ DemoService demoService = context.getBean("demoService", DemoService.class);
+ String result = demoService.hello("world");
+ System.out.println(result);
+
+ }
+}
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Protocol b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Protocol
new file mode 100644
index 0000000..fbebc4d
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Protocol
@@ -0,0 +1 @@
+webservice=org.apache.dubbo.rpc.protocol.webservice.WebServiceProtocol
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/dubbo.properties b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..2af25a5
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=33333
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/log4j.properties b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/log4j.properties
new file mode 100644
index 0000000..49f7232
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,16 @@
+#配置根Logger 后面是若干个Appender
+log4j.rootLogger=DEBUG,A1,R
+#log4j.rootLogger=INFO,A1,R
+
+# ConsoleAppender 输出
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
+
+# File 输出 一天一个文件,输出路径可以定制,一般在根路径下
+log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.R.File=log.txt
+log4j.appender.R.MaxFileSize=500KB
+log4j.appender.R.MaxBackupIndex=10
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c] [%p] - %m%n
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/spring/dubbo-samples-webservice-consumer.xml b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/spring/dubbo-samples-webservice-consumer.xml
new file mode 100644
index 0000000..7831e43
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-consumer/src/main/resources/spring/dubbo-samples-webservice-consumer.xml
@@ -0,0 +1,29 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+
+ <dubbo:application name="demo-consumer"/>
+
+ <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+
+ <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.samples.webservice.DemoService"/>
+</beans>
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-interface/pom.xml b/java/dubbo-samples-webservice/dubbo-samples-webservice-interface/pom.xml
new file mode 100644
index 0000000..34ad0e8
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-interface/pom.xml
@@ -0,0 +1,31 @@
+<?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">
+ <parent>
+ <artifactId>dubbo-samples-webservice</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-webservice-interface</artifactId>
+
+
+</project>
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-interface/src/main/java/org/apache/dubbo/samples/webservice/DemoService.java b/java/dubbo-samples-webservice/dubbo-samples-webservice-interface/src/main/java/org/apache/dubbo/samples/webservice/DemoService.java
new file mode 100644
index 0000000..fb4964a
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-interface/src/main/java/org/apache/dubbo/samples/webservice/DemoService.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed 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.dubbo.samples.webservice;
+
+public interface DemoService {
+ String hello(String word);
+}
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/pom.xml b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/pom.xml
new file mode 100644
index 0000000..a9c360c
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/pom.xml
@@ -0,0 +1,170 @@
+<?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">
+ <parent>
+ <artifactId>dubbo-samples-webservice</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-webservice-provider</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+
+ <properties>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ <slf4j-log4j12.version>1.7.21</slf4j-log4j12.version>
+ <servlet-api.version>2.5</servlet-api.version>
+ <jsp-api.version>2.2</jsp-api.version>
+ <jstl.version>1.2</jstl.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <commons-lang3.version>3.4</commons-lang3.version>
+ <dubbo.version>2.7.7</dubbo.version>
+ <cxf.version>3.3.7</cxf.version>
+ <zookeeper.version>3.4.13</zookeeper.version>
+ <curator-recipes.version>4.0.1</curator-recipes.version>
+ <netty-all.version>4.1.25.Final</netty-all.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>${servlet-api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <version>${jsp-api.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <version>${jstl.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${spring.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-simple</artifactId>
+ <version>${cxf.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>stax-ex</artifactId>
+ <groupId>org.jvnet.staxex</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>javax.xml.soap-api</artifactId>
+ <groupId>javax.xml.soap</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>${zookeeper.version}</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>slf4j-api</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-log4j12</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-recipes</artifactId>
+ <version>${curator-recipes.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-api</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>${netty-all.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-webservice-interface</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>maven-springmvc</finalName>
+ <resources>
+ <resource>
+ <directory>${basedir}/src/main/java</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>9.3.10.v20160621</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/java/org/apache/dubbo/samples/webservice/provider/impl/DemoServiceImpl.java b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/java/org/apache/dubbo/samples/webservice/provider/impl/DemoServiceImpl.java
new file mode 100644
index 0000000..847c71c
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/java/org/apache/dubbo/samples/webservice/provider/impl/DemoServiceImpl.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed 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.dubbo.samples.webservice.provider.impl;
+
+import org.apache.dubbo.samples.webservice.DemoService;
+
+public class DemoServiceImpl implements DemoService {
+ @Override
+ public String hello(String word) {
+ return "Time: " + System.currentTimeMillis() + ", word: " + word;
+ }
+}
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/resources/log4j.properties b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/resources/log4j.properties
new file mode 100644
index 0000000..05c29d7
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/resources/log4j.properties
@@ -0,0 +1,13 @@
+
+log4j.rootLogger=DEBUG,A1,R
+
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss,SSS} [%c]-[%p] %m%n
+
+log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.R.File=log.txt
+log4j.appender.R.MaxFileSize=500KB
+log4j.appender.R.MaxBackupIndex=10
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c] [%p] - %m%n
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/resources/spring/spring.xml b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/resources/spring/spring.xml
new file mode 100644
index 0000000..d85eaec
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/resources/spring/spring.xml
@@ -0,0 +1,43 @@
+<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+ http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
+
+
+
+ <!-- 提供方应用信息,用于计算依赖关系 -->
+ <dubbo:application name="dubbo-webservice-app" />
+
+ <!-- 使用zookeeper注册中心暴露服务地址 -->
+ <dubbo:registry address="zookeeper://127.0.0.1:2181" />
+
+ <!-- 用webservice协议在8080端口暴露服务 -->
+ <dubbo:protocol name="webservice" port="8082" server="servlet" contextpath="dubbo_samples_webservice_provider_war/services"/>
+
+ <!-- <dubbo:protocol name="dubbo" port="20880" />-->
+
+ <!-- 声明需要暴露的服务接口 -->
+ <dubbo:service interface="org.apache.dubbo.samples.webservice.DemoService" ref="demoService" />
+
+ <!-- 和本地bean一样实现服务 -->
+ <bean id="demoService" class="org.apache.dubbo.samples.webservice.provider.impl.DemoServiceImpl" />
+</beans>
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/webapp/WEB-INF/web.xml b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..0f234f2
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,49 @@
+<?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.
+ -->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+
+ <display-name>dubbo-webservice</display-name>
+
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>classpath:spring/*.xml</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <servlet>
+ <servlet-name>dubbo</servlet-name>
+ <servlet-class>org.apache.dubbo.remoting.http.servlet.DispatcherServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>dubbo</servlet-name>
+ <url-pattern>/services/*</url-pattern>
+ </servlet-mapping>
+
+</web-app>
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/webapp/index.jsp b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/webapp/index.jsp
new file mode 100644
index 0000000..a18e4f8
--- /dev/null
+++ b/java/dubbo-samples-webservice/dubbo-samples-webservice-provider/src/main/webapp/index.jsp
@@ -0,0 +1,25 @@
+<!--
+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.
+-->
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<head>
+ <title>Title</title>
+</head>
+<body>
+Hello
+</body>
+</html>
\ No newline at end of file
diff --git a/java/dubbo-samples-webservice/pom.xml b/java/dubbo-samples-webservice/pom.xml
new file mode 100644
index 0000000..da55aed
--- /dev/null
+++ b/java/dubbo-samples-webservice/pom.xml
@@ -0,0 +1,53 @@
+<?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.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ <modules>
+ <module>dubbo-samples-webservice-interface</module>
+ <module>dubbo-samples-webservice-provider</module>
+ <module>dubbo-samples-webservice-consumer</module>
+ </modules>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <packaging>pom</packaging>
+ <artifactId>dubbo-samples-webservice</artifactId>
+
+ <properties>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven-compiler-plugin.version}</version>
+ <configuration>
+ <source>${source.level}</source>
+ <target>${target.level}</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/java/pom.xml b/java/pom.xml
index 253b103..c4e82ba 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -83,6 +83,7 @@
<module>dubbo-samples-ssl</module>
<module>dubbo-samples-perf</module>
<module>dubbo-samples-tengine</module>
+ <module>dubbo-samples-webservice</module>
</modules>
<repositories>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org