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

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

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

WebClient.getClientState介绍

暂无

代码示例

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

/**
 * Creates WebClient, baseURI will be set to Client currentURI
 * @param client existing client
 * @param inheritHeaders  if existing Client headers can be inherited by new client 
 */
public static WebClient fromClient(Client client, boolean inheritHeaders) {
  
  WebClient webClient = null;
  
  ClientState clientState = getClientState(client);
  if (clientState == null) {
    webClient = create(client.getCurrentURI());
    if (inheritHeaders) {
      webClient.headers(client.getHeaders());
    }
  } else {
    MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null;
    webClient = new WebClient(clientState.newState(client.getCurrentURI(), headers, null));
  }
  copyProperties(webClient, client);
  return webClient;
}

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

/**
 * Creates WebClient, baseURI will be set to Client currentURI
 * @param client existing client
 * @param inheritHeaders  if existing Client headers can be inherited by new client
 */
public static WebClient fromClient(Client client, boolean inheritHeaders) {
  WebClient webClient = null;
  ClientState clientState = getClientState(client);
  if (clientState == null) {
    webClient = create(client.getCurrentURI());
    if (inheritHeaders) {
      webClient.headers(client.getHeaders());
    }
  } else {
    MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null;
    webClient = new WebClient(clientState.newState(client.getCurrentURI(), headers, null));
  }
  copyProperties(webClient, client);
  return webClient;
}

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

/**
 * Creates WebClient, baseURI will be set to Client currentURI
 * @param client existing client
 * @param inheritHeaders  if existing Client headers can be inherited by new client
 */
public static WebClient fromClient(Client client, boolean inheritHeaders) {
  WebClient webClient = null;
  ClientState clientState = getClientState(client);
  if (clientState == null) {
    webClient = create(client.getCurrentURI());
    if (inheritHeaders) {
      webClient.headers(client.getHeaders());
    }
  } else {
    MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null;
    webClient = new WebClient(clientState.newState(client.getCurrentURI(), headers, null));
  }
  copyProperties(webClient, client);
  return webClient;
}

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

/**
 * Creates a proxy, baseURI will be set to Client currentURI
 * @param client Client instance
 * @param cls proxy class, if not interface then a CGLIB proxy will be created
 * @param inheritHeaders if true then existing Client headers will be inherited by new proxy
 *        and subresource proxies if any
 * @return typed proxy
 */
public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) {
  JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null);
  bean.setInheritHeaders(inheritHeaders);
  ClientState clientState = WebClient.getClientState(client);
  T proxy = null;
  if (clientState == null) {
    proxy = bean.create(cls);
    if (inheritHeaders) {
      WebClient.client(proxy).headers(client.getHeaders());
    }
  } else {
    MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null;
    bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null));
    proxy = bean.create(cls);
  }
  WebClient.copyProperties(WebClient.client(proxy), client);
  return proxy;
}

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

/**
 * Creates a proxy, baseURI will be set to Client currentURI
 * @param client Client instance
 * @param cls proxy class, if not interface then a CGLIB proxy will be created
 * @param inheritHeaders if true then existing Client headers will be inherited by new proxy
 *        and subresource proxies if any
 * @return typed proxy
 */
public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) {
  JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null);
  bean.setInheritHeaders(inheritHeaders);
  ClientState clientState = WebClient.getClientState(client);
  T proxy = null;
  if (clientState == null) {
    proxy = bean.create(cls);
    if (inheritHeaders) {
      WebClient.client(proxy).headers(client.getHeaders());
    }
  } else {
    MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null;
    bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null));
    proxy = bean.create(cls);
  }
  WebClient.copyProperties(WebClient.client(proxy), client);
  return proxy;
}

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

/**
 * Creates a proxy, baseURI will be set to Client currentURI
 * @param client Client instance
 * @param cls proxy class, if not interface then a CGLIB proxy will be created
 * @param inheritHeaders if true then existing Client headers will be inherited by new proxy 
 *        and subresource proxies if any 
 * @return typed proxy
 */
public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) {
  JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null);
  bean.setInheritHeaders(inheritHeaders);
  
  ClientState clientState = WebClient.getClientState(client);
  
  T proxy = null;
  if (clientState == null) {
    proxy = bean.create(cls);
    if (inheritHeaders) {
      WebClient.client(proxy).headers(client.getHeaders());
    }
  } else {
    MultivaluedMap<String, String> headers = inheritHeaders ? client.getHeaders() : null;
    bean.setInitialState(clientState.newState(client.getCurrentURI(), headers, null));
    proxy = bean.create(cls);
  }
  WebClient.copyProperties(WebClient.client(proxy), client);
  return proxy;
}

相关文章

WebClient类方法