コード例 #1
0
  private Endpoint computeEndpoint(String serviceName) {

    Service service = partition.getServices().get(serviceName);

    if (service != null) {
      if (service.getEndpoints().containsKey(region)) {

        Endpoint merged =
            Endpoint.merge(
                partition.getDefaults(),
                Endpoint.merge(service.getDefaults(), service.getEndpoints().get(region)));

        return merged;

      } else if (service.isPartitionWideEndpointAvailable() && !service.isRegionalized()) {
        // partition doesn't have any information about a service.

        Endpoint merged =
            Endpoint.merge(
                partition.getDefaults(),
                Endpoint.merge(
                    service.getDefaults(),
                    service.getEndpoints().get(service.getPartitionEndpoint())));

        return merged;

      } else {
        if (partition.getDefaults() != null && partition.getDefaults().getHostName() != null) {
          return partition.getDefaults();
        }
      }
    }
    return null;
  }
コード例 #2
0
 private String getEndpointString(String serviceName, Endpoint endpoint) {
   return endpoint == null
       ? null
       : endpoint
           .getHostName()
           .replace(SERVICE, serviceName)
           .replace(REGION, region)
           .replace(DNS_SUFFIX, partition.getDnsSuffix());
 }