当前位置: 首页>>代码示例>>Java>>正文


Java ServiceInstance.getPort方法代码示例

本文整理汇总了Java中org.springframework.cloud.client.ServiceInstance.getPort方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceInstance.getPort方法的具体用法?Java ServiceInstance.getPort怎么用?Java ServiceInstance.getPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.cloud.client.ServiceInstance的用法示例。


在下文中一共展示了ServiceInstance.getPort方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hello1

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
@ResponseBody
@RequestMapping(value = "/hi", method = RequestMethod.GET)
public String hello1(@RequestParam String name){
    System.err.println("-----------------------------");
    ServiceInstance instance = discoveryClient.getInstances("mi-eureka-client").get(0);

    log.info("Method:---->"+this.getClass().getSimpleName()+"---->Hello");
    log.info("Url:---->"+instance.getUri());
    log.info("Host:---->"+instance.getHost());
    log.info("Port:---->"+instance.getPort());

    return "Hello !!   "+name + " ,I here in port  "+instance.getPort();
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:14,代码来源:ClientController.java

示例2: hello

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
@RequestMapping("/hi")
public String hello(@RequestParam String name){
    System.err.println("-----------------------------");
    //监听指定的服务提供者
    ServiceInstance instance = discoveryClient.getInstances("mi-eureka-client").get(0);

    log.info("Method:---->"+this.getClass().getSimpleName()+"---->Hello");
    log.info("Url:---->"+instance.getUri());
    log.info("Host:---->"+instance.getHost());
    log.info("Port:---->"+instance.getPort());

    return "Hello Api "+name + " ,i here in port :" +instance.getPort();
}
 
开发者ID:MIYAOW,项目名称:MI-S,代码行数:14,代码来源:ApiController.java

示例3: getInstance

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
private ServiceInstance getInstance(String ipPort) {
    List<ServiceInstance> instances = discoveryClient.getInstances(DeliveryServerService.SOCKET_SERVER_KEY);
    for (ServiceInstance instance : instances) {
        String ip = instance.getHost();
        int port = instance.getPort();
        String instancesIpPort = String.format("%s:%d", ip, port);
        if (instancesIpPort.equals(ipPort)) {
            return instance;
        }
    }
    return null;
}
 
开发者ID:1991wangliang,项目名称:sds,代码行数:13,代码来源:DeliveryServiceImpl.java

示例4: catalogURL

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
private String catalogURL() {
	if (useRibbon) {
		ServiceInstance instance = loadBalancer.choose("CATALOG");
		return "http://" + instance.getHost() + ":" + instance.getPort()
				+ "/catalog/";
	} else {
		return "http://" + catalogServiceHost + ":" + catalogServicePort
				+ "/catalog/";
	}
}
 
开发者ID:ewolff,项目名称:microservice-consul,代码行数:11,代码来源:CatalogClient.java

示例5: customerURL

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
private String customerURL() {
	if (useRibbon) {
		ServiceInstance instance = loadBalancer.choose("CUSTOMER");
		return "http://" + instance.getHost() + ":" + instance.getPort()
				+ "/customer/";
	} else {
		return "http://" + customerServiceHost + ":" + customerServicePort
				+ "/customer/";
	}

}
 
开发者ID:ewolff,项目名称:microservice-consul,代码行数:12,代码来源:CustomerClient.java

示例6: getUrl

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
/**
 * Constructs a url for rest template
 *
 * @param path resource path on the service
 * @return a url String for use in RestTemplate
 */
protected String getUrl(String path) {
    String url;
    ServiceInstance instance = loadBalancerClient.choose(serviceName);
    String prefix = instance.isSecure() ? "https://" : "http://";

    url = prefix + instance.getHost() + ":" + instance.getPort() + "/api/" + path;


    return url;
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:17,代码来源:AbstractMicroserviceClient.java

示例7: printServiceB

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
@RequestMapping(value = "/", method = RequestMethod.GET)
public String printServiceB() {
    ServiceInstance serviceInstance = discoveryClient.getLocalServiceInstance();
    return serviceInstance.getServiceId() + " (" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + ")" + "===>Say " + msg;
}
 
开发者ID:yidongnan,项目名称:spring-cloud-netflix-example,代码行数:6,代码来源:ServiceB1Controller.java

示例8: printServiceA

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
@RequestMapping(value = "/", method = RequestMethod.GET)
public String printServiceA() {
    ServiceInstance serviceInstance = discoveryClient.getLocalServiceInstance();
    return serviceInstance.getServiceId() + " (" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + ")" + "===>name:" + name + "<br/>" + serviceBClient.printServiceB();
}
 
开发者ID:yidongnan,项目名称:spring-cloud-netflix-example,代码行数:6,代码来源:AServiceController.java

示例9: locate

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
@Override
public Host locate(Span span) {
	ServiceInstance instance = this.client.getLocalServiceInstance();
	return new Host(instance.getServiceId(), getIpAddress(instance),
			instance.getPort());
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:7,代码来源:DiscoveryClientHostLocator.java

示例10: getUrl

import org.springframework.cloud.client.ServiceInstance; //导入方法依赖的package包/类
protected String getUrl(String path) {
    String url;
    ServiceInstance instance = loadBalancerClient.choose(serviceName);

    url = "http://" + instance.getHost() + ":" + instance.getPort() + "/api/" + path;


    return url;
}
 
开发者ID:xetys,项目名称:jhipster-ribbon-hystrix,代码行数:10,代码来源:AbstractMicroserviceClient.java


注:本文中的org.springframework.cloud.client.ServiceInstance.getPort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。