From 2d2abd2a2278c0cdc8883b1510ec5a568fb55ec5 Mon Sep 17 00:00:00 2001 From: kimi Date: Wed, 22 Feb 2012 08:03:23 +0000 Subject: [PATCH] =?UTF-8?q?DUBBO-130=20=E6=B7=BB=E5=8A=A0=E9=9B=86?= =?UTF-8?q?=E6=88=90=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=B5=8B=E8=AF=95=E5=9C=A8?= =?UTF-8?q?=E4=B8=A4=E5=8F=B0=E6=9C=BA=E5=99=A8=E4=B9=8B=E9=97=B4=E4=B8=80?= =?UTF-8?q?=E6=96=B9=E7=AA=81=E7=84=B6=E6=96=AD=E7=BD=91=E6=88=96=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E5=AE=95=E6=9C=BA=E5=90=8E=E5=BF=83=E8=B7=B3?= =?UTF-8?q?=E8=83=BD=E5=90=A6=E5=8F=91=E7=8E=B0=E5=B9=B6=E4=B8=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E9=97=AD=20channel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1014 1a56cb94-b969-4eaa-88fa-be21384802f2 --- .../heartbeat/HelloServiceConsumer.java | 38 +++++++++++++++++++ .../heartbeat/HelloServiceProvider.java | 33 ++++++++++++++++ .../remoting/heartbeat/api/HelloService.java | 26 +++++++++++++ .../examples/remoting/heartbeat/consumer.xml | 30 +++++++++++++++ .../heartbeat/impl/HelloServiceImpl.java | 29 ++++++++++++++ .../examples/remoting/heartbeat/provider.xml | 34 +++++++++++++++++ dubbo-examples/src/main/resources/log4j.xml | 27 +++++++++++++ 7 files changed, 217 insertions(+) create mode 100644 dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceConsumer.java create mode 100644 dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceProvider.java create mode 100644 dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/api/HelloService.java create mode 100644 dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/consumer.xml create mode 100644 dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/impl/HelloServiceImpl.java create mode 100644 dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/provider.xml create mode 100644 dubbo-examples/src/main/resources/log4j.xml diff --git a/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceConsumer.java b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceConsumer.java new file mode 100644 index 000000000..45943025c --- /dev/null +++ b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceConsumer.java @@ -0,0 +1,38 @@ +/* + * Copyright 1999-2012 Alibaba Group. + * + * 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 com.alibaba.dubbo.examples.remoting.heartbeat; + +import com.alibaba.dubbo.examples.remoting.heartbeat.api.HelloService; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @author kimi + */ +public class HelloServiceConsumer { + + public static void main(String[] args) throws Exception { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + HelloServiceConsumer.class.getPackage().getName().replace('.', '/') + "/consumer.xml"); + context.start(); + HelloService hello = (HelloService) context.getBean("helloService"); + for (int i = 0; i < Integer.MAX_VALUE; i++) { + System.out.println(hello.sayHello("kimi-" + i)); + Thread.sleep(10000); + } + } + +} diff --git a/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceProvider.java b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceProvider.java new file mode 100644 index 000000000..05a11d4ef --- /dev/null +++ b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/HelloServiceProvider.java @@ -0,0 +1,33 @@ +/* + * Copyright 1999-2012 Alibaba Group. + * + * 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 com.alibaba.dubbo.examples.remoting.heartbeat; + +import org.springframework.context.support.ClassPathXmlApplicationContext; + +/** + * @author kimi + */ +public class HelloServiceProvider { + + public static void main(String[] args) throws Exception { + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( + HelloServiceProvider.class.getPackage().getName().replace( '.', '/' ) + "/provider.xml" ); + context.start(); + System.in.read(); + } + +} diff --git a/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/api/HelloService.java b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/api/HelloService.java new file mode 100644 index 000000000..e2a96f8dd --- /dev/null +++ b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/api/HelloService.java @@ -0,0 +1,26 @@ +/* + * Copyright 1999-2012 Alibaba Group. + * + * 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 com.alibaba.dubbo.examples.remoting.heartbeat.api; + +/** + * @author kimi + */ +public interface HelloService { + + public String sayHello(String name); + +} diff --git a/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/consumer.xml b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/consumer.xml new file mode 100644 index 000000000..f812cee1c --- /dev/null +++ b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/consumer.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/impl/HelloServiceImpl.java b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/impl/HelloServiceImpl.java new file mode 100644 index 000000000..66d15b495 --- /dev/null +++ b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/impl/HelloServiceImpl.java @@ -0,0 +1,29 @@ +/* + * Copyright 1999-2012 Alibaba Group. + * + * 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 com.alibaba.dubbo.examples.remoting.heartbeat.impl; + +import com.alibaba.dubbo.examples.remoting.heartbeat.api.HelloService; + +/** + * @author kimi + */ +public class HelloServiceImpl implements HelloService { + + public String sayHello(String name) { + return new StringBuilder(32).append("Hello, ").append(name).append("!").toString(); + } +} diff --git a/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/provider.xml b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/provider.xml new file mode 100644 index 000000000..5fa03e11f --- /dev/null +++ b/dubbo-examples/src/main/java/com/alibaba/dubbo/examples/remoting/heartbeat/provider.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + diff --git a/dubbo-examples/src/main/resources/log4j.xml b/dubbo-examples/src/main/resources/log4j.xml new file mode 100644 index 000000000..69ed180b2 --- /dev/null +++ b/dubbo-examples/src/main/resources/log4j.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + -- GitLab