本文整理了Java中javax.ws.rs.core.UriBuilder.host()
方法的一些代码示例,展示了UriBuilder.host()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。UriBuilder.host()
方法的具体详情如下:
包路径:javax.ws.rs.core.UriBuilder
类名称:UriBuilder
方法名:host
[英]Set the URI host.
[中]设置URI主机。
代码示例来源:origin: jersey/jersey
private URI getBaseURI(final URI baseUri) {
String stagingHostName = AccessController.doPrivileged(PropertiesHelper.getSystemProperty(JERSEY_TEST_HOST));
if (stagingHostName != null) {
return UriBuilder.fromUri(baseUri).host(stagingHostName).build();
}
return baseUri;
}
代码示例来源:origin: Netflix/eureka
private URI getRedirectBaseUri(URI locationURI) {
if (locationURI == null) {
throw new TransportException("Missing Location header in the redirect reply");
}
Matcher pathMatcher = REDIRECT_PATH_REGEX.matcher(locationURI.getPath());
if (pathMatcher.matches()) {
return UriBuilder.fromUri(locationURI)
.host(dnsService.resolveIp(locationURI.getHost()))
.replacePath(pathMatcher.group(1))
.replaceQuery(null)
.build();
}
logger.warn("Invalid redirect URL {}", locationURI);
return null;
}
}
代码示例来源: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: 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: org.glassfish.jersey.test-framework.providers/jersey-test-framework-provider-external
private URI getBaseURI(final URI baseUri) {
String stagingHostName = AccessController.doPrivileged(PropertiesHelper.getSystemProperty(JERSEY_TEST_HOST));
if (stagingHostName != null) {
return UriBuilder.fromUri(baseUri).host(stagingHostName).build();
}
return baseUri;
}
代码示例来源: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: HuygensING/timbuctoo
public URI fromResourceUri(URI resourceUri) {
URI baseUri = UriBuilder.fromUri(this.baseUri).build();
return UriBuilder.fromUri(resourceUri)
.userInfo(baseUri.getUserInfo())
.scheme(baseUri.getScheme())
.host(baseUri.getHost())
.port(baseUri.getPort())
.replacePath(baseUri.getPath()).path(resourceUri.getPath())
.build();
}
代码示例来源: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: 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: smallnest/Jax-RS-Performance-Comparison
public static HttpServer startServer(String host, int port) {
final ResourceConfig rc = ResourceConfig.forApplicationClass(MyApplication.class);
URI baseUri = UriBuilder.fromUri(BASE_URI).host(host).port(port).build();
return GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
}
代码示例来源:origin: smallnest/Jax-RS-Performance-Comparison
public static Server startServer(String host, int port) {
final ResourceConfig rc = ResourceConfig.forApplicationClass(MyApplication.class);
URI baseUri = UriBuilder.fromUri(BASE_URI).host(host).port(port).build();
return JettyHttpContainerFactory.createServer(baseUri, rc);
}
代码示例来源:origin: com.ning.billing/killbill-jaxrs
public Response buildResponse(final UriInfo uriInfo, final Class<? extends JaxrsResource> theClass, final String getMethodName, final Object objectId) {
final UriBuilder uriBuilder = UriBuilder.fromResource(theClass)
.path(theClass, getMethodName)
.scheme(uriInfo.getAbsolutePath().getScheme())
.host(uriInfo.getAbsolutePath().getHost())
.port(uriInfo.getAbsolutePath().getPort());
final URI location = objectId != null ? uriBuilder.build(objectId) : uriBuilder.build();
return Response.created(location).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: org.apache.pulsar/pulsar-broker
private URI getRedirectionUrl(ClusterData differentClusterData) throws MalformedURLException {
URL webUrl = null;
if (isRequestHttps() && pulsar.getConfiguration().isTlsEnabled()
&& StringUtils.isNotBlank(differentClusterData.getServiceUrlTls())) {
webUrl = new URL(differentClusterData.getServiceUrlTls());
} else {
webUrl = new URL(differentClusterData.getServiceUrl());
}
return UriBuilder.fromUri(uri.getRequestUri()).host(webUrl.getHost()).port(webUrl.getPort()).build();
}
代码示例来源:origin: org.keycloak/keycloak-server-spi
@Override
public URI getBaseUri() {
if (baseURI == null) {
baseURI = delegate.getBaseUriBuilder().scheme(scheme).host(hostname).port(port).build();
}
return baseURI;
}
代码示例来源:origin: com.jiuxian/mossrose-ui
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
final String currentLocker = competitive.currentLocker();
final String localIp = NetworkUtils.getLocalIp();
if (!Objects.equals(currentLocker, localIp)) {
URI masterLocation = requestContext.getUriInfo().getAbsolutePathBuilder().host(currentLocker).build();
LOGGER.info("Redirect url to {}.", masterLocation);
Response response = javax.ws.rs.core.Response.seeOther(masterLocation).build();
requestContext.abortWith(response);
}
}
代码示例来源: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()));
}
}
内容来源于网络,如有侵权,请联系作者删除!