diff --git a/whatsmars-dubbo/whatsmars-dubbo-consumer/src/test/java/org/hongxi/whatsmars/dubbo/demo/consumer/Consumer.java b/whatsmars-dubbo/whatsmars-dubbo-consumer/src/test/java/org/hongxi/whatsmars/dubbo/demo/consumer/Consumer.java new file mode 100644 index 0000000000000000000000000000000000000000..90b67cf44e9cec8ef484b7c036701b17494fa5d7 --- /dev/null +++ b/whatsmars-dubbo/whatsmars-dubbo-consumer/src/test/java/org/hongxi/whatsmars/dubbo/demo/consumer/Consumer.java @@ -0,0 +1,26 @@ +package org.hongxi.whatsmars.dubbo.demo.consumer; + +import com.alibaba.dubbo.config.ApplicationConfig; +import com.alibaba.dubbo.config.ReferenceConfig; +import com.alibaba.dubbo.config.RegistryConfig; +import org.hongxi.whatsmars.dubbo.demo.api.DemoService; + +public class Consumer { + + public static void main(String[] args) { + ApplicationConfig application = new ApplicationConfig(); + application.setName("demo-consumer"); + + RegistryConfig registry = new RegistryConfig(); + registry.setAddress("zookeeper://127.0.0.1:2181"); + + ReferenceConfig reference = new ReferenceConfig<>(); + reference.setApplication(application); + reference.setRegistry(registry); + reference.setInterface(DemoService.class); + reference.setVersion("1.0.0"); + + DemoService demoService = reference.get(); + System.out.println(demoService.sayHello("hongxi")); + } +} diff --git a/whatsmars-dubbo/whatsmars-dubbo-provider/src/test/java/org/hongxi/whatsmars/dubbo/demo/provider/Provider.java b/whatsmars-dubbo/whatsmars-dubbo-provider/src/test/java/org/hongxi/whatsmars/dubbo/demo/provider/Provider.java new file mode 100644 index 0000000000000000000000000000000000000000..c527f502cd6d9d85eef725d032549c212e7e0fb4 --- /dev/null +++ b/whatsmars-dubbo/whatsmars-dubbo-provider/src/test/java/org/hongxi/whatsmars/dubbo/demo/provider/Provider.java @@ -0,0 +1,34 @@ +package org.hongxi.whatsmars.dubbo.demo.provider; + +import com.alibaba.dubbo.config.ApplicationConfig; +import com.alibaba.dubbo.config.ProtocolConfig; +import com.alibaba.dubbo.config.RegistryConfig; +import com.alibaba.dubbo.config.ServiceConfig; +import org.hongxi.whatsmars.dubbo.demo.api.DemoService; + +public class Provider { + + public static void main(String[] args) throws Exception { + ApplicationConfig application = new ApplicationConfig(); + application.setName("demo-provider"); + + RegistryConfig registry = new RegistryConfig(); + registry.setAddress("zookeeper://127.0.0.1:2181"); + + ProtocolConfig protocol = new ProtocolConfig(); + protocol.setName("dubbo"); + protocol.setPort(20882); + + ServiceConfig service = new ServiceConfig<>(); + service.setApplication(application); + service.setRegistry(registry); + service.setProtocol(protocol); + service.setInterface(DemoService.class); + service.setRef(new DemoServiceImpl2()); + service.setVersion("1.0.0"); + + service.export(); + + System.in.read(); // press any key to exit + } +}