當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。