javax.ws.rs.core.UriBuilder.scheme()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中javax.ws.rs.core.UriBuilder.scheme()方法的一些代码示例,展示了UriBuilder.scheme()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.scheme()方法的具体详情如下:
包路径:javax.ws.rs.core.UriBuilder
类名称:UriBuilder
方法名:scheme

UriBuilder.scheme介绍

[英]Set the URI scheme.
[中]设置URI方案。

代码示例

代码示例来源:origin: prestodb/presto

@GET
  public Response redirectIndexHtml(
      @HeaderParam(X_FORWARDED_PROTO) String proto,
      @Context UriInfo uriInfo)
  {
    if (isNullOrEmpty(proto)) {
      proto = uriInfo.getRequestUri().getScheme();
    }

    return Response.status(MOVED_PERMANENTLY)
        .location(uriInfo.getRequestUriBuilder().scheme(proto).path("/ui/").build())
        .build();
  }
}

代码示例来源:origin: prestodb/presto

private synchronized URI createNextResultsUri(String scheme, UriInfo uriInfo)
{
  return uriInfo.getBaseUriBuilder()
      .scheme(scheme)
      .replacePath("/v1/statement")
      .path(queryId.toString())
      .path(String.valueOf(resultId.incrementAndGet()))
      .replaceQuery("")
      .build();
}

代码示例来源:origin: neo4j/neo4j

private static URI externalUri( UriBuilder builder, String xForwardedHost, String xForwardedProto )
{
  ForwardedHost forwardedHost = new ForwardedHost( xForwardedHost );
  ForwardedProto forwardedProto = new ForwardedProto( xForwardedProto );
  if ( forwardedHost.isValid )
  {
    builder.host( forwardedHost.getHost() );
    if ( forwardedHost.hasExplicitlySpecifiedPort() )
    {
      builder.port( forwardedHost.getPort() );
    }
  }
  if ( forwardedProto.isValid() )
  {
    builder.scheme( forwardedProto.getScheme() );
  }
  return builder.build();
}

代码示例来源:origin: soabase/exhibitor

public Result         makeRequest(RemoteInstanceRequestClient client, String methodName, Object... values)
{
  String      remoteResponse;
  String      errorMessage;
  {
    try
    {
      URI remoteUri = UriBuilder
        .fromPath(getPath())
        .scheme(exhibitor.getRestScheme())
        .host(hostname)
        .port(exhibitor.getRestPort())
        .path(ClusterResource.class, methodName)
        .build(values);
      remoteResponse = client.getWebResource(remoteUri, MediaType.APPLICATION_JSON_TYPE, String.class);
      errorMessage = "";
    }
    catch ( Exception e )
    {
      remoteResponse = "{}";
      errorMessage = e.getMessage();
      if ( errorMessage == null )
      {
        errorMessage = "Unknown";
      }
    }
  }
  return new Result(remoteResponse, errorMessage);
}

代码示例来源:origin: prestodb/presto

.scheme(scheme)
.replacePath("ui/query.html")
.replaceQuery(queryId.toString())

代码示例来源:origin: bazaarvoice/emodb

/**
 * Returns the base URI for a location of type {@link LocationType#EMO_URL}.
 */
public static URI getBaseUriForLocation(URI location) {
  // Any request to the public ELBs must be made over https
  boolean useHttps = location.getHost().toLowerCase().endsWith("nexus.bazaarvoice.com");
  return UriBuilder.fromUri(location)
      .scheme(useHttps ? "https" : "http")
      .replacePath(DataStoreClient.SERVICE_PATH)
      .replaceQuery(null)
      .build();
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-workspace

private UriBuilder makeURIAbsolute(URI uri) {
 UriBuilder uriBuilder = UriBuilder.fromUri(uri);
 if (!uri.isAbsolute() && uri.getHost() == null) {
  uriBuilder
    .scheme(apiEndpoint.getScheme())
    .host(apiEndpoint.getHost())
    .port(apiEndpoint.getPort())
    .replacePath(apiEndpoint.getPath() + uri.toString());
 }
 return uriBuilder;
}

代码示例来源:origin: net.di2e.ecdr.libs/cdr-rest-search-commons

public static UriBuilder updateURLWithPlatformValues( UriBuilder builder, String scheme, String host, Integer port ) {
  if ( StringUtils.isNotBlank( scheme ) && StringUtils.isNotBlank( host ) ) {
    LOGGER.debug( "Using values from Platform Configuration for Atom Links host[" + host + "], scheme[" + scheme + "], and port[" + port + "]" );
    builder.scheme( scheme );
    builder.host( host );
    if ( port != null ) {
      builder.port( port );
    }
  }
  return builder;
}

代码示例来源:origin: ru.lanwen.diff/uri-differ-lib

@Override
public URI apply(URI uri) {
  UriBuilder urlBuilder = UriBuilder.fromUri(uri);
  if (schemeCanBe.isEmpty() || schemeCanBe.contains(urlBuilder.build().getScheme())) {
    String scheme = defaultIfEmpty(on(".").join(schemeCanBe), "any-scheme");
    return urlBuilder.scheme(scheme).build();
  }
  return uri;
}

代码示例来源:origin: com.bazaarvoice.emodb/emodb-common-dropwizard

private URI constructUrl(URI overrideUrl, String scheme, String host, int port, String path) {
  if (overrideUrl != null) {
    return overrideUrl;
  }
  checkState(scheme != null, "scheme");
  checkState(host != null, "host");
  checkState(port != 0, "port");
  checkState(path != null, "path");
  return UriBuilder.fromPath(path).scheme(scheme).host(host).port(port).build();
}

代码示例来源:origin: com.cloudbees.cloud_resource/cloud-resource-commons-jaxrs-auth

@Override
public ContainerRequest filter(ContainerRequest request) {
  /* un-secure http://... request */
  if(!request.isSecure()){
    URI location = request.getRequestUriBuilder().scheme("https").build();
    throw new WebApplicationException(Response.status(301).location(location).build());
  }
  return request;
}

代码示例来源:origin: bazaarvoice/emodb

private URI constructUrl(URI overrideUrl, String scheme, String host, int port, String path) {
  if (overrideUrl != null) {
    return overrideUrl;
  }
  checkState(scheme != null, "scheme");
  checkState(host != null, "host");
  checkState(port != 0, "port");
  checkState(path != null, "path");
  return UriBuilder.fromPath(path).scheme(scheme).host(host).port(port).build();
}

代码示例来源:origin: io.github.amyassist/amy-http-server

@Override
public URI getSocketUri() {
  if (this.contextPath.indexOf('/') != -1) {
    // see GrizzlyWebContainerFactory.create()
    this.logger.warn("Only first path segment will be used as context path, the rest will be ignored.");
  }
  if (this.contextPath.isEmpty()) {
    this.contextPath = "/";
  }
  String ip = this.local ? IP_LOCAL : IP_GLOBAL;
  return UriBuilder.fromPath(this.contextPath).scheme("http").host(ip).port(this.serverPort).build();
}

代码示例来源:origin: org.eclipse.lyo.oslc4j.core/oslc4j-core

private static String constructPublicUriBase(final String scheme, final String hostName,
    final int serverPort, final String contextPath) {
  return UriBuilder.fromPath(contextPath)
           .scheme(scheme)
           .host(hostName)
           .port(serverPort)
           .build()
           .normalize()
           .toString();
}

代码示例来源:origin: io.prestosql/presto-main

private synchronized URI createNextResultsUri(String scheme, UriInfo uriInfo)
{
  return uriInfo.getBaseUriBuilder()
      .scheme(scheme)
      .replacePath("/v1/statement")
      .path(queryId.toString())
      .path(String.valueOf(resultId.incrementAndGet()))
      .replaceQuery("")
      .build();
}

代码示例来源:origin: prestosql/presto

private synchronized URI createNextResultsUri(String scheme, UriInfo uriInfo)
{
  return uriInfo.getBaseUriBuilder()
      .scheme(scheme)
      .replacePath("/v1/statement")
      .path(queryId.toString())
      .path(String.valueOf(resultId.incrementAndGet()))
      .replaceQuery("")
      .build();
}

代码示例来源:origin: org.keycloak/keycloak-server-spi

@Override
public URI getRequestUri() {
  if (requestURI == null) {
    requestURI = delegate.getRequestUriBuilder().scheme(scheme).host(hostname).port(port).build();
  }
  return requestURI;
}

代码示例来源:origin: org.keycloak/keycloak-server-spi

@Override
public URI getAbsolutePath() {
  if (absolutePath == null) {
    absolutePath = delegate.getAbsolutePathBuilder().scheme(scheme).host(hostname).port(port).build();
  }
  return absolutePath;
}

代码示例来源:origin: com.yahoo.vespa/jaxrs_client_utils

@Override
  public <T> T createClient(Class<T> apiClass, HostName hostName, int port, String pathPrefix, String scheme) {
    UriBuilder uriBuilder = UriBuilder.fromPath(pathPrefix).host(hostName.s()).port(port).scheme(scheme);
    return createClient(new Params<>(apiClass, uriBuilder.build()));
  }
}

代码示例来源:origin: pravega/pravega

@Test
public void test() {
  URI streamResourceURI = UriBuilder.fromPath("//localhost:" + serverConfig.getPort() + "/ping")
                   .scheme(getURLScheme()).build();
  Response response = client.target(streamResourceURI).request().buildGet().invoke();
  assertEquals(200, response.getStatus());
}

相关文章