本文整理了Java中javax.ws.rs.core.Response.bufferEntity
方法的一些代码示例,展示了Response.bufferEntity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.bufferEntity
方法的具体详情如下:
包路径:javax.ws.rs.core.Response
类名称:Response
方法名:bufferEntity
[英]Buffer the message entity data.
In case the message entity is backed by an unconsumed entity input stream, all the bytes of the original entity input stream are read and stored in a local buffer. The original entity input stream is consumed and automatically closed as part of the operation and the method returns true.
In case the response entity instance is not backed by an unconsumed input stream an invocation of bufferEntity method is ignored and the method returns false.
This operation is idempotent, i.e. it can be invoked multiple times with the same effect which also means that calling the bufferEntity()method on an already buffered (and thus closed) message instance is legal and has no further effect. Also, the result returned by the bufferEntity()method is consistent across all invocations of the method on the same Response instance.
Buffering the message entity data allows for multiple invocations of readEntity(...) methods on the response instance. Note however, that once the response instance itself is #close(), the implementations are expected to release the buffered message entity data too. Therefore any subsequent attempts to read a message entity stream on such closed response will result in an IllegalStateException being thrown.
[中]缓冲消息实体数据。
如果消息实体由未使用的实体输入流支持,则读取原始实体输入流的所有字节,并将其存储在本地缓冲区中。原始实体输入流被消耗,并作为操作的一部分自动关闭,该方法返回true。
如果未使用的输入流不支持响应实体实例,则忽略对bufferEntity方法的调用,该方法返回false。
这个操作是幂等的,也就是说,它可以被多次调用,具有相同的效果,这也意味着在已经缓冲(因此关闭)的消息实例上调用bufferEntity()方法是合法的,没有进一步的效果。此外,bufferEntity()方法返回的结果在同一响应实例上对该方法的所有调用中都是一致的。
缓冲消息实体数据允许多次调用readEntity(…)响应实例上的方法。但是请注意,一旦响应实例本身为#close(),实现也会释放缓冲的消息实体数据。因此,在这种关闭的响应上读取消息实体流的任何后续尝试都将导致抛出IllegalStateException。
代码示例来源:origin: apache/nifi
public synchronized void bufferResponse() {
try {
response.bufferEntity();
} catch (final ProcessingException e) {
this.throwable = e;
}
}
代码示例来源:origin: jersey/jersey
response.bufferEntity();
代码示例来源:origin: jersey/jersey
response.bufferEntity();
代码示例来源:origin: org.glassfish.jersey.core/jersey-client
response.bufferEntity();
代码示例来源:origin: jamesagnew/hapi-fhir
@Override
public void bufferEntity() throws IOException {
if(!myBufferedEntity && myResponse.hasEntity()) {
myBufferedEntity = true;
myResponse.bufferEntity();
} else {
myResponse.bufferEntity();
}
}
代码示例来源:origin: resteasy/Resteasy
response.bufferEntity();
if (prioritised.isPresent())
代码示例来源:origin: resteasy/Resteasy
if (s == null || Boolean.parseBoolean(s))
response.bufferEntity();
代码示例来源:origin: SAP/cloud-s4-sdk-examples
@Override
public boolean bufferEntity()
{
return delegate.bufferEntity();
}
代码示例来源:origin: com.cerner.beadledom/beadledom-resteasy-genericresponse
@Override
public boolean bufferEntity() {
return rawResponse.bufferEntity();
}
代码示例来源:origin: org.pacesys.openstack4j.connectors/openstack4j-resteasy
@Override
public <T> T readEntity(Class<T> typeToReadAs) {
response.bufferEntity();
return response.readEntity(typeToReadAs);
}
代码示例来源:origin: org.pacesys.openstack4j.connectors/openstack4j-resteasy
/**
* @return the input stream
*/
public InputStream getInputStream() {
response.bufferEntity();
return response.readEntity(InputStream.class);
}
代码示例来源:origin: locationtech/geowave
@Override
public Response list(final String filter) {
final Response resp = configService.list(filter);
resp.bufferEntity();
return resp;
}
代码示例来源:origin: locationtech/geowave
public Response listPlugins() {
final Response resp = ingestService.listPlugins();
resp.bufferEntity();
return resp;
}
代码示例来源:origin: io.smallrye/smallrye-rest-client
@Override
public Throwable toThrowable(Response response) {
try {
response.bufferEntity();
} catch (Exception ignored) {}
response.close();
return new WebApplicationException("Unknown error, status code " + response.getStatus(), response);
}
代码示例来源:origin: com.axway.ats.framework/ats-actionlibrary
private void checkResponseBodyStatus() {
/* prevents java.lang.IllegalStateException: Entity input stream has already been closed.
* if the file size is less than MAX_RESPONSE_SIZE
*/
if (response.getLength() < MAX_RESPONSE_SIZE) {
response.bufferEntity();
}
}
代码示例来源:origin: stackoverflow.com
Response upstreamResponse = client./* code code */.get();
upstreamResponse.bufferEntity();
return Response.status(upstreamResponse.status())
.type(upstreamResponse.getMediaType()
// and so on
代码示例来源:origin: zanata/zanata-platform
@Override
public CopyTransStatus startCopyTrans(String projectSlug,
String iterationSlug, String docId) {
Client client = factory.getClient();
Response response = webResource(client, projectSlug, iterationSlug, docId)
.post(Entity.json(""));
response.bufferEntity();
return response.readEntity(CopyTransStatus.class);
}
代码示例来源:origin: org.zanata/zanata-rest-client
@Override
public CopyTransStatus startCopyTrans(String projectSlug,
String iterationSlug, String docId) {
Client client = factory.getClient();
Response response = webResource(client, projectSlug, iterationSlug, docId)
.post(Entity.json(""));
response.bufferEntity();
return response.readEntity(CopyTransStatus.class);
}
代码示例来源:origin: dremio/dremio-oss
private <T> T readEntity(Response response, GenericType<T> c) {
response.bufferEntity();
try {
return response.readEntity(c);
} catch (ProcessingException e) {
String body = response.readEntity(String.class);
throw new RuntimeException("Error deserializing entity with " + c + " : " + body, e);
}
}
代码示例来源:origin: apache/cxf
@Test
public void testGetCustomBookBufferedResponse() {
String address = "http://localhost:" + PORT + "/bookstore/customresponse";
WebClient wc = WebClient.create(address);
Response r = wc.accept("application/xml").get(Response.class);
r.bufferEntity();
String bookStr = r.readEntity(String.class);
assertTrue(bookStr.endsWith("</Book>"));
Book book = r.readEntity(Book.class);
assertEquals(222L, book.getId());
assertEquals("OK", r.getHeaderString("customresponse"));
}
内容来源于网络,如有侵权,请联系作者删除!