org.apache.cxf.jaxrs.client.WebClient.getBaseURI()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(140)

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

WebClient.getBaseURI介绍

暂无

代码示例

代码示例来源:origin: org.apache.cxf/cxf-rt-management-web

public String getEndpointAddress() {
    return wc.getBaseURI().toString();
  }
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Moves WebClient to a new baseURI or forwards to new currentURI
 * @param newAddress new URI
 * @param forward if true then currentURI will be based on baseURI
 * @return updated WebClient
 */
public WebClient to(String newAddress, boolean forward) {
  getState().setTemplates(null);
  if (forward) {
    if (!newAddress.startsWith("/")
      && !newAddress.startsWith(getBaseURI().toString())) {
      throw new IllegalArgumentException("Base address can not be preserved");
    }
    resetCurrentBuilder(URI.create(newAddress));
  } else {
    resetBaseAddress(URI.create(newAddress));
  }
  return this;
}

代码示例来源:origin: apache/cxf

/**
 * Moves WebClient to a new baseURI or forwards to new currentURI
 * @param newAddress new URI
 * @param forward if true then currentURI will be based on baseURI
 * @return updated WebClient
 */
public WebClient to(String newAddress, boolean forward) {
  getState().setTemplates(null);
  if (forward) {
    if (!newAddress.startsWith("/")
      && !newAddress.startsWith(getBaseURI().toString())) {
      throw new IllegalArgumentException("Base address can not be preserved");
    }
    resetCurrentBuilder(URI.create(newAddress));
  } else {
    resetBaseAddress(URI.create(newAddress));
  }
  return this;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

/**
 * Moves WebClient to a new baseURI or forwards to new currentURI  
 * @param newAddress new URI
 * @param forward if true then currentURI will be based on baseURI  
 * @return updated WebClient
 */
public WebClient to(String newAddress, boolean forward) {
  getState().setTemplates(null);
  if (forward) {
    if (!newAddress.startsWith(getBaseURI().toString())) {
      throw new IllegalArgumentException("Base address can not be preserved");
    }
    resetCurrentBuilder(URI.create(newAddress));
  } else {
    resetBaseAddress(URI.create(newAddress));
  }
  return this;
}

代码示例来源:origin: com.redhat.rhevm.api/rhevm-api-cli-base

private WebClient configureTLS(WebClient client) throws Exception {
  if (client.getBaseURI().getScheme().startsWith(HTTPS_SCHEME)
    && !(trustStorePath == null || trustStorePassword ==null)) {
    HTTPConduit conduit =
      (HTTPConduit)WebClient.getConfig(client).getConduit();
    TLSClientParameters tlsParameters = new TLSClientParameters();
    KeyStore trustStore = KeyStore.getInstance("JKS");
    trustStore.load(new FileInputStream(trustStorePath),
            trustStorePassword.toCharArray());
    TrustManagerFactory trustFactory =
      TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
    trustFactory.init(trustStore);
    tlsParameters.setTrustManagers(trustFactory.getTrustManagers());
    // allow a hostname mismatch
    tlsParameters.setDisableCNCheck(true);
    conduit.setTlsClientParameters(tlsParameters);
  }
  return client;
}

代码示例来源:origin: apache/cxf

private static Token getToken(WebClient tokenService, OAuthAccessor accessor,
  Map<String, String> parameters) throws OAuthServiceException {
  String header = doGetAuthorizationHeader(accessor,
                       "POST",
                       tokenService.getBaseURI().toString(),
                       parameters);
  try {
    tokenService.replaceHeader("Authorization", header);
    Form form = tokenService.post(null, Form.class);
    return new Token(form.asMap().getFirst("oauth_token"),
        form.asMap().getFirst("oauth_token_secret"));
  } catch (WebApplicationException ex) {
    throw new OAuthServiceException(ex);
  }
}

代码示例来源:origin: apache/cxf

/**
 * Goes back
 * @param fast if true then goes back to baseURI otherwise to a previous path segment
 * @return updated WebClient
 */
public WebClient back(boolean fast) {
  getState().setTemplates(null);
  if (fast) {
    getCurrentBuilder().replacePath(getBaseURI().getPath());
  } else {
    URI uri = getCurrentURI();
    if (uri == getBaseURI()) {
      return this;
    }
    List<PathSegment> segments = JAXRSUtils.getPathSegments(uri.getPath(), false);
    getCurrentBuilder().replacePath(null);
    for (int i = 0; i < segments.size() - 1; i++) {
      getCurrentBuilder().path(HttpUtils.fromPathSegment(segments.get(i)));
    }
  }
  return this;
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-client

/**
 * Goes back
 * @param fast if true then goes back to baseURI otherwise to a previous path segment
 * @return updated WebClient
 */
public WebClient back(boolean fast) {
  getState().setTemplates(null);
  if (fast) {
    getCurrentBuilder().replacePath(getBaseURI().getPath());
  } else {
    URI uri = getCurrentURI();
    if (uri == getBaseURI()) {
      return this;
    }
    List<PathSegment> segments = JAXRSUtils.getPathSegments(uri.getPath(), false);
    getCurrentBuilder().replacePath(null);
    for (int i = 0; i < segments.size() - 1; i++) {
      getCurrentBuilder().path(HttpUtils.fromPathSegment(segments.get(i)));
    }
  }
  return this;
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

/**
 * Goes back
 * @param fast if true then goes back to baseURI otherwise to a previous path segment 
 * @return updated WebClient
 */
public WebClient back(boolean fast) {
  getState().setTemplates(null);
  if (fast) {
    getCurrentBuilder().replacePath(getBaseURI().getPath());
  } else {
    URI uri = getCurrentURI();
    if (uri == getBaseURI()) {
      return this;
    }
    List<PathSegment> segments = JAXRSUtils.getPathSegments(uri.getPath(), false);
    getCurrentBuilder().replacePath(null);
    for (int i = 0; i < segments.size() - 1; i++) {
      getCurrentBuilder().path(HttpUtils.fromPathSegment(segments.get(i)));
    }
    
  }
  return this;
}

代码示例来源:origin: org.talend.esb.auxiliary.storage/auxiliary-storage-client-rest

client.reset();
switchServerURL(client.getBaseURI().toString(), e);
deleteObject(key, false);

代码示例来源:origin: Talend/tesb-rt-se

client.reset();
switchServerURL(client.getBaseURI().toString());
return saveObject(ctx, false);
  client.reset();
switchServerURL(client.getBaseURI().toString(), e);
return saveObject(ctx);

代码示例来源:origin: Talend/tesb-rt-se

client.reset();
switchServerURL(client.getBaseURI().toString(), e);
deleteObject(key, false);

代码示例来源:origin: org.talend.esb.auxiliary.storage/auxiliary-storage-client-rest

client.reset();
switchServerURL(client.getBaseURI().toString(), e);
return lookupObject(contextKey, false);

代码示例来源:origin: Talend/tesb-rt-se

client.reset();
switchServerURL(client.getBaseURI().toString(), e);
return lookupObject(contextKey, false);

代码示例来源:origin: apache/cxf

@Test
public void testAbsolutePathOne() throws Exception {
  WebClient wc = WebClient.create("http://localhost:" + PORT + "/one/bookstore/request");
  String path = wc.accept("text/plain").get(String.class);
  assertEquals("Absolute RequestURI is wrong", wc.getBaseURI().toString(), path);
}

代码示例来源:origin: apache/cxf

@Test
public void testAbsolutePathTwo() throws Exception {
  WebClient wc = WebClient.create("http://localhost:" + PORT + "/two/bookstore/request");
  String path = wc.accept("text/plain").get(String.class);
  assertEquals("Absolute RequestURI is wrong", wc.getBaseURI().toString(), path);
}

代码示例来源:origin: apache/cxf

private void doTestGetBook123WebClient(String configFile) throws Exception {
  WebClient client = WebClient.create("https://localhost:" + PORT, configFile);
  assertEquals("https://localhost:" + PORT, client.getBaseURI().toString());
  client.path("/bookstore/securebooks/123").accept(MediaType.APPLICATION_XML_TYPE);
  Book b = client.get(Book.class);
  assertEquals(123, b.getId());
}

代码示例来源:origin: apache/cxf

@Test
public void testGetBook123WebClientFromSpringWildcard() throws Exception {
  ClassPathXmlApplicationContext ctx =
    new ClassPathXmlApplicationContext(new String[] {CLIENT_CONFIG_FILE5});
  Object bean = ctx.getBean("bookService.proxyFactory");
  assertNotNull(bean);
  JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
  WebClient wc = (WebClient)cfb.create();
  assertEquals("https://localhost:" + PORT, wc.getBaseURI().toString());
  wc.accept("application/xml");
  wc.path("bookstore/securebooks/123");
  TheBook b = wc.get(TheBook.class);
  assertEquals(b.getId(), 123);
  b = wc.get(TheBook.class);
  assertEquals(b.getId(), 123);
  ctx.close();
}

代码示例来源:origin: apache/cxf

assertEquals("root", b.getName());
assertEquals("http://localhost:" + PORT1 + "/bookstore",
       webClient.getBaseURI().toString());
assertEquals("root", b.getName());
assertEquals("http://localhost:" + PORT2 + "/bookstore",
       webClient.getBaseURI().toString());
assertEquals("root", b.getName());
assertEquals("http://localhost:" + PORT3 + "/bookstore",
       webClient.getBaseURI().toString());

代码示例来源:origin: apache/cxf

@Test
@Ignore("Works in the studio only if local jaxrs.xsd is updated to have jaxrs:client")
public void testGetBook123WebClientFromSpringWildcardOldJaxrsClient() throws Exception {
  ClassPathXmlApplicationContext ctx =
    new ClassPathXmlApplicationContext(new String[] {CLIENT_CONFIG_FILE_OLD});
  Object bean = ctx.getBean("bookService.proxyFactory");
  assertNotNull(bean);
  JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
  WebClient wc = (WebClient)cfb.create();
  assertEquals("https://localhost:" + PORT, wc.getBaseURI().toString());
  wc.accept("application/xml");
  wc.path("bookstore/securebooks/123");
  TheBook b = wc.get(TheBook.class);
  assertEquals(b.getId(), 123);
  b = wc.get(TheBook.class);
  assertEquals(b.getId(), 123);
  ctx.close();
}

相关文章

WebClient类方法