本文整理汇总了Java中javax.ws.rs.ext.WriterInterceptorContext.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java WriterInterceptorContext.getProperty方法的具体用法?Java WriterInterceptorContext.getProperty怎么用?Java WriterInterceptorContext.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.ext.WriterInterceptorContext
的用法示例。
在下文中一共展示了WriterInterceptorContext.getProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext)
throws IOException, WebApplicationException {
final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
writerInterceptorContext.proceed();
final Object requestId = Requests.getProperty(LOGGING_ID_PROPERTY);
final long id = requestId != null ? (Long) requestId : _id.incrementAndGet();
StringBuilder b = (StringBuilder) writerInterceptorContext.getProperty(LOGGER_BUFFER_PROPERTY);
if (b == null) {
b = new StringBuilder();
writerInterceptorContext.setProperty(LOGGER_BUFFER_PROPERTY, b);
}
printPrefixedHeaders(b, id, RESPONSE_PREFIX, HeaderUtils.asStringHeaders(writerInterceptorContext.getHeaders()));
if (stream != null) {
log(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())));
} else {
log(b);
}
}
示例2: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
final LoggingStream stream = (LoggingStream) context.getProperty("client.LoggingStream");
context.proceed();
if (stream != null) {
System.out.printf("Body: %s\n", stream.getString(StandardCharsets.UTF_8));
}
System.out.printf("-----------\n");
}
示例3: logRequestBody
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
private void logRequestBody(WriterInterceptorContext context) {
LoggingOutputStream loggingOutputStream = (LoggingOutputStream) context.getProperty(LOGGING_OUTPUT_STREAM_PROPERTY);
if (loggingOutputStream != null) {
Charset charset = MessageUtils.getCharset(context.getMediaType());
byte[] bytes = loggingOutputStream.getBytes();
logger.trace("Message body: " + new String(bytes, charset));
}
}
示例4: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext)
throws IOException, WebApplicationException {
final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
writerInterceptorContext.proceed();
if (stream != null) {
JaxRsExchangeMessage msg = stream.getMsg();
msg.setPayload(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())).toString());
stream.collect();
}
}
示例5: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
try {
context.proceed();
} catch (Throwable e) {
String path = (String) context.getProperty("metrics.path");
String name = name("REST", "WRITE", e.getClass().getSimpleName(), path);
JerseyMetricsPlugin.getMetricRegistry().meter(name).mark();
throw e;
}
}
示例6: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext) throws IOException, WebApplicationException {
final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
writerInterceptorContext.proceed();
if (stream != null) {
if (log.isDebugEnabled())
log.debug(stream.getStringBuilder(MessageUtils.getCharset(writerInterceptorContext.getMediaType())).toString());
}
}
示例7: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(final WriterInterceptorContext writerInterceptorContext) throws IOException,
WebApplicationException {
final LoggingStream stream = (LoggingStream) writerInterceptorContext.getProperty(ENTITY_LOGGER_PROPERTY);
writerInterceptorContext.proceed();
if (stream != null) {
log(stream.getStringBuilder());
}
}
示例8: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context) throws IOException, WebApplicationException {
context.proceed();
if (BooleanUtils.isTrue((Boolean) context.getProperty(LOGGING_ENABLED_PROPERTY))) {
Long requestTime = (Long) context.getProperty(REQUEST_TIME);
RestRequestDetails restRequest = (RestRequestDetails) context.getProperty(REQUEST_DETAILS);
RestResponseDetails restResponse = (RestResponseDetails) context.getProperty(RESPONSE_DETAILS);
String responseBody = ((LoggingStream) context.getProperty(LOGGINGSTREAM_PROPERTY)).getStringBuilder(
MessageUtils.getCharset(context.getMediaType())).toString();
Map<String, String> restParams = (Map<String, String>) context.getProperty(REST_PARAMS);
extendRestParamsFromResponse(restParams, responseBody);
sendStructuredEvent(restRequest, restResponse, restParams, requestTime, responseBody);
}
}
示例9: aroundWriteTo
import javax.ws.rs.ext.WriterInterceptorContext; //导入方法依赖的package包/类
@Override
public void aroundWriteTo(WriterInterceptorContext context)
throws IOException, WebApplicationException {
Object o = context.getProperty(NdexService.NdexZipFlag);
if ( o!=null && o == Boolean.TRUE) {
context.getHeaders().putSingle("Content-Encoding", "gzip");
context.getHeaders().putSingle("Vary", "Accept-Encoding");
}
context.proceed();
}