Search in sources :

Example 1 with DemoService

use of com.alibaba.dubbo.demo.DemoService in project dubbo by alibaba.

the class Consumer method main.

public static void main(String[] args) {
    // Prevent to get IPV6 address,this way only work in debug mode
    // But you can pass use -Djava.net.preferIPv4Stack=true,then it work well whether in debug mode or not
    System.setProperty("java.net.preferIPv4Stack", "true");
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "META-INF/spring/dubbo-demo-consumer.xml" });
    context.start();
    // get remote service proxy
    DemoService demoService = (DemoService) context.getBean("demoService");
    while (true) {
        try {
            Thread.sleep(1000);
            // call remote method
            String hello = demoService.sayHello("world");
            // get result
            System.out.println(hello);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DemoService(com.alibaba.dubbo.demo.DemoService)

Example 2 with DemoService

use of com.alibaba.dubbo.demo.DemoService in project dubbo by alibaba.

the class Spring3CompatibilityTest method main.

public static void main(String[] args) {
    ConfigurableApplicationContext provider = startupProvider();
    ConfigurableApplicationContext consumer = startConsumer();
    ConsumerConfiguration consumerConfiguration = consumer.getBean(ConsumerConfiguration.class);
    DemoService demoService = consumerConfiguration.getDemoService();
    String value = demoService.sayHello("Mercy");
    Assert.isTrue("DefaultDemoService - sayHell() : Mercy".equals(value), "Test is failed!");
    System.out.println(value);
    provider.close();
    consumer.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ConsumerConfiguration(com.alibaba.dubbo.test.consumer.ConsumerConfiguration) DemoService(com.alibaba.dubbo.demo.DemoService)

Aggregations

DemoService (com.alibaba.dubbo.demo.DemoService)2 ConsumerConfiguration (com.alibaba.dubbo.test.consumer.ConsumerConfiguration)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1