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 0000000000000000000000000000000000000000..45943025c3be7e52148816230785d82486cd09a5 --- /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 0000000000000000000000000000000000000000..05a11d4efcac14aef390babf3d7f3b4c3eeb241f --- /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 0000000000000000000000000000000000000000..e2a96f8ddd18ed3cdfa24756a6e8e80d3a14ea6f --- /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 0000000000000000000000000000000000000000..f812cee1ca3432f3a8bd211c69326d1ab1948bbd --- /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 0000000000000000000000000000000000000000..66d15b495f28819628f8f8f7475c093ab989d185 --- /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 0000000000000000000000000000000000000000..5fa03e11f2156bd4ba5550db95eb6439c48b12c1 --- /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 0000000000000000000000000000000000000000..69ed180b2307991456a611fad12f5ce2257cf542 --- /dev/null +++ b/dubbo-examples/src/main/resources/log4j.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + +