Java Code Examples for org.apache.dubbo.config.ServiceConfig#setApplication()

The following examples show how to use org.apache.dubbo.config.ServiceConfig#setApplication() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Provider2.java    From dubbo-samples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<GreetingsService> greetingsService = new ServiceConfig<>();
    greetingsService.setApplication(application);
    greetingsService.setConfigCenter(configCenter);
    greetingsService.setRegistry(registry);
    greetingsService.setInterface(GreetingsService.class);
    greetingsService.setRef(new GreetingsServiceImpl());
    greetingsService.export();

    ServiceConfig<DemoService> demoService = new ServiceConfig<>();
    demoService.setApplication(application);
    demoService.setConfigCenter(configCenter);
    demoService.setInterface(DemoService.class);
    demoService.setRegistry(registry);
    demoService.setRef(new DemoServiceImpl());
    demoService.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example 2
Source File: GenericImplProvider.java    From dubbo-samples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    new EmbeddedZooKeeper(2181, false).start();

    ApplicationConfig applicationConfig = new ApplicationConfig();
    applicationConfig.setName("generic-impl-provider");
    RegistryConfig registryConfig = new RegistryConfig();
    registryConfig.setAddress(zookeeperAddress);

    GenericService helloService = new GenericImplOfHelloService();
    ServiceConfig<GenericService> service = new ServiceConfig<>();
    service.setApplication(applicationConfig);
    service.setRegistry(registryConfig);
    service.setInterface("org.apache.dubbo.samples.generic.call.api.HelloService");
    service.setRef(helloService);
    service.setGeneric("true");
    service.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example 3
Source File: ChronusAutoConfiguration.java    From chronus with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean({ApplicationConfig.class, RegistryConfig.class})
public ChronusSdkProcessor chronusSdkFacade() {
    ChronusSdkProcessor chronusClientFacade = new AbstractSdkService(){};
    ServiceConfig<ChronusSdkProcessor> serviceConfig = new ServiceConfig<>();
    serviceConfig.setApplication(applicationConfig);
    serviceConfig.setRegistry(registryConfig);
    serviceConfig.setInterface(ChronusSdkProcessor.class);
    serviceConfig.setRef(chronusClientFacade);
    serviceConfig.setPath("/" + applicationConfig.getName() + "/" + ChronusSdkProcessor.class.getName());
    //serviceConfig.setGroup(applicationConfig.getName());
    serviceConfig.export();
    return chronusClientFacade;
}
 
Example 4
Source File: DubboProvider.java    From alibabacloud-microservice-demo with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<GreetingsService> service = new ServiceConfig<>();
    service.setApplication(new ApplicationConfig("dubbo-provider"));
    service.setRegistry(new RegistryConfig("nacos://127.0.0.1:8848"));
    service.setInterface(GreetingsService.class);
    service.setRef(new GreetingsServiceImpl());
    service.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example 5
Source File: Dubbo27ITest.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
private static ServiceConfig<GreeterService> getService() {
  final ServiceConfig<GreeterService> service = new ServiceConfig<>();
  service.setApplication(new ApplicationConfig("test"));
  service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
  service.setProtocol(new ProtocolConfig("dubbo", TestUtil.nextFreePort()));
  service.setInterface(GreeterService.class);
  service.setRef(new GreeterServiceImpl());
  return service;
}
 
Example 6
Source File: Application.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<GreetingsService> service = new ServiceConfig<>();
    service.setApplication(new ApplicationConfig("first-dubbo-provider"));
    service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
    service.setInterface(GreetingsService.class);
    service.setRef(new GreetingsServiceImpl());
    service.export();

    System.out.println("dubbo service started");
    new CountDownLatch(1).await();
}
 
Example 7
Source File: MonitorServiceIT.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
@Before
    public void setUp() throws Exception {
        ServiceConfig<MonitorService> service = new ServiceConfig<>();
        // FIXME: has to set application name to "demo-consumer"
        service.setApplication(new ApplicationConfig("demo-consumer"));
        service.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
//        MonitorConfig monitorConfig = new MonitorConfig();
//        monitorConfig.setProtocol("registry");
//        monitorConfig.setInterval("100");
//        service.setMonitor(monitorConfig);
        service.setInterface(MonitorService.class);
        service.setFilter("-monitor");
        service.setRef(new MonitorServiceImpl());
        service.export();
    }
 
Example 8
Source File: Provider1.java    From dubbo-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<GreetingsService> service = new ServiceConfig<>();
    service.setApplication(applicationConfig);
    service.setConfigCenter(configCenter);
    service.setInterface(GreetingsService.class);
    service.setRef(new GreetingsServiceImpl());
    service.export();
    System.out.println("dubbo service started");
    System.in.read();
}
 
Example 9
Source File: Provider.java    From rpcx-benchmark with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    ServiceConfig<DemoServiceImpl> service = new ServiceConfig<>();
    service.setApplication(new ApplicationConfig("dubbo-demo-api-provider"));
    String zk = "zookeeper://127.0.0.1:2181";
    if (args.length > 0) {
        zk = args[0];
    }
    service.setRegistry(new RegistryConfig(zk));
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl());
    service.export();

    Thread.sleep(24 * 3600 * 1000);

}
 
Example 10
Source File: Application.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Bean(destroyMethod = "unexport")
public ServiceConfig<GreetService> service() {
    ServiceConfig<GreetService> serviceConfig = new ServiceConfig<>();
    serviceConfig.setApplication(applicationConfig);
    serviceConfig.setRegistry(registryConfig);
    serviceConfig.setProtocol(protocolConfig);
    serviceConfig.setInterface(GreetService.class);
    serviceConfig.setRef(new GreetServiceImpl());
    serviceConfig.setTimeout(5000);
    serviceConfig.export();
    return serviceConfig;
}