Forked from anonymous/call-dubbo-with-no-config.java
Created
December 29, 2012 08:20
-
-
Save xumingming/4405421 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.alibaba.dubbo.demo; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import com.alibaba.dubbo.common.utils.Assert; | |
import com.alibaba.dubbo.config.ApplicationConfig; | |
import com.alibaba.dubbo.config.ReferenceConfig; | |
import com.alibaba.dubbo.config.RegistryConfig; | |
import com.alibaba.dubbo.rpc.service.GenericService; | |
public class Consumer1 { | |
public static void main(String[] args) throws Exception { | |
// create the registry | |
RegistryConfig registry = new RegistryConfig(); | |
registry.setAddress("127.0.0.1:9090"); | |
// reference the service | |
ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); | |
reference.setApplication(new ApplicationConfig("generic-consumer")); | |
reference.setInterface("com.alibaba.dubbo.demo.DemoService"); | |
reference.setGeneric(true); | |
reference.setRegistry(registry); | |
// get the service | |
GenericService genericService = reference.get(); | |
try { | |
// call service | |
String user = (String) genericService.$invoke("sayHello", new String[]{"java.lang.String"}, new Object[]{"xumingmingv"}); | |
System.out.println(user); | |
} finally { | |
reference.destroy(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment