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

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

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

WebClient.getState介绍

暂无

代码示例

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

/**
 * Replaces the header value with the new values.
 * @param headerName headerValues
 * @param value new values, null is equivalent to removing the header
 * @return updated WebClient
 */
public WebClient replaceHeader(String headerName, String value) {
  MultivaluedMap<String, String> headers = getState().getRequestHeaders();
  headers.remove(headerName);
  if (value != null) {
    headers.add(headerName, value);
  }
  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-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: 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: org.apache.cxf/cxf-rt-rs-client

/**
 * Updates the current URI path with path segment which may contain template variables
 * @param path new relative path segment
 * @param values template variable values
 * @return updated WebClient
 */
public WebClient path(String path, Object... values) {
  URI u = new UriBuilderImpl().uri(URI.create("http://tempuri")).path(path).buildFromEncoded(values);
  getState().setTemplates(getTemplateParametersMap(new URITemplate(path), Arrays.asList(values)));
  return path(u.getRawPath());
}

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

/**
 * Updates the current URI path with path segment which may contain template variables
 * @param path new relative path segment
 * @param values template variable values
 * @return updated WebClient
 */
public WebClient path(String path, Object... values) {
  URI u = new UriBuilderImpl().uri(URI.create("http://tempuri")).path(path).buildFromEncoded(values);
  getState().setTemplates(getTemplateParametersMap(new URITemplate(path), Arrays.asList(values)));
  return path(u.getRawPath());
}

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

/**
 * Updates the current URI path with path segment which may contain template variables
 * @param path new relative path segment
 * @param values template variable values
 * @return updated WebClient
 */
public WebClient path(String path, Object... values) {
  URI u = new UriBuilderImpl().uri(URI.create("http://tempuri")).path(path).buildFromEncoded(values);
  getState().setTemplates(getTemplateParametersMap(new URITemplate(path), Arrays.asList(values)));
  return path(u.getRawPath());
}

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

/**
 * Replaces the header value with the new values.
 * @param headerName headerValues
 * @param value new values, null is equivalent to removing the header
 * @return updated WebClient
 */
public WebClient replaceHeader(String headerName, Object value) {
  MultivaluedMap<String, String> headers = getState().getRequestHeaders();
  headers.remove(headerName);
  if (value != null) {
    super.header(headerName, value);
  }
  return this;
}

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

/**
 * Replaces the header value with the new values.
 * @param headerName headerValues
 * @param value new values, null is equivalent to removing the header
 * @return updated WebClient
 */
public WebClient replaceHeader(String headerName, Object value) {
  MultivaluedMap<String, String> headers = getState().getRequestHeaders();
  headers.remove(headerName);
  if (value != null) {
    super.header(headerName, value);
  }
  return this;
}

代码示例来源: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-bundle-jaxrs

((ResponseImpl)r).setMessage(outMessage);
getState().setResponse(r);

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

protected Response handleResponse(Message outMessage, Class<?> responseClass, Type genericType) {
  try {
    ResponseBuilder rb = setResponseBuilder(outMessage, outMessage.getExchange());
    Response currentResponse = rb.clone().build();
    ((ResponseImpl)currentResponse).setOutMessage(outMessage);
    Object entity = readBody(currentResponse, outMessage, responseClass, genericType,
                 new Annotation[]{});
    if (entity == null) {
      int status = currentResponse.getStatus();
      if (status >= 400) {
        entity = currentResponse.getEntity();
      }
    }
    rb = JAXRSUtils.fromResponse(currentResponse, false);
    rb.entity(entity instanceof Response
         ? ((Response)entity).getEntity() : entity);
    Response r = rb.build();
    getState().setResponse(r);
    ((ResponseImpl)r).setOutMessage(outMessage);
    return r;
  } catch (Throwable ex) {
    throw (ex instanceof ProcessingException) ? (ProcessingException)ex
                       : new ProcessingException(ex);
  } finally {
    ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
  }
}

代码示例来源: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-rt-rs-client

protected Response handleResponse(Message outMessage, Class<?> responseClass, Type genericType) {
  try {
    ResponseBuilder rb = setResponseBuilder(outMessage, outMessage.getExchange());
    Response currentResponse = rb.clone().build();
    ((ResponseImpl)currentResponse).setOutMessage(outMessage);
    Object entity = readBody(currentResponse, outMessage, responseClass, genericType,
                 new Annotation[]{});
    if (entity == null) {
      int status = currentResponse.getStatus();
      if (status >= 400) {
        entity = currentResponse.getEntity();
      }
    }
    rb = JAXRSUtils.fromResponse(currentResponse, false);
    rb.entity(entity instanceof Response
         ? ((Response)entity).getEntity() : entity);
    Response r = rb.build();
    getState().setResponse(r);
    ((ResponseImpl)r).setOutMessage(outMessage);
    return r;
  } catch (Throwable ex) {
    throw (ex instanceof ProcessingException) ? (ProcessingException)ex
                       : new ProcessingException(ex);
  } finally {
    ClientProviderFactory.getInstance(outMessage).clearThreadLocalProxies();
  }
}

代码示例来源: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;
}

相关文章

WebClient类方法