本文整理汇总了Java中javax.ws.rs.client.ClientRequestContext.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ClientRequestContext.setProperty方法的具体用法?Java ClientRequestContext.setProperty怎么用?Java ClientRequestContext.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.client.ClientRequestContext
的用法示例。
在下文中一共展示了ClientRequestContext.setProperty方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void filter(final ClientRequestContext requestContext, final ClientResponseContext responseContext)
throws IOException {
final Object requestId = requestContext.getProperty(LOGGING_ID_PROPERTY);
final long id = requestId != null ? (Long) requestId : _id.incrementAndGet();
StringBuilder b = (StringBuilder) requestContext.getProperty(LOGGER_BUFFER_PROPERTY);
if (b == null) {
b = new StringBuilder();
requestContext.setProperty(LOGGER_BUFFER_PROPERTY, b);
}
printResponseLine(b, "Client response received", id, responseContext.getStatus());
printPrefixedHeaders(b, id, RESPONSE_PREFIX, responseContext.getHeaders());
if (printEntity && responseContext.hasEntity() && isSupportPrintType(responseContext.getMediaType())) {
responseContext.setEntityStream(logInboundEntity(b, responseContext.getEntityStream(),
MessageUtils.getCharset(responseContext.getMediaType())));
}
log(b);
}
示例2: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext clientRequestContext) throws IOException {
String method = clientRequestContext.getMethod();
URI uri = clientRequestContext.getUri();
MultivaluedMap<String, Object> headers = clientRequestContext.getHeaders();
System.out.printf("Sending %s to: %s\n", method, uri);
System.out.printf("Headers:\n");
for(String key : headers.keySet()) {
System.out.printf(" %s: %s\n", key, headers.getFirst(key));
}
if(clientRequestContext.hasEntity()) {
final OutputStream stream = new LoggingStream(clientRequestContext.getEntityStream());
clientRequestContext.setEntityStream(stream);
clientRequestContext.setProperty("client.LoggingStream", stream);
}
}
示例3: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(final ClientRequestContext context) throws IOException {
final long id = aid.incrementAndGet();
final StringBuilder b = new StringBuilder();
printRequestLine(b, "Sending client request", id, context.getMethod(), context.getUri());
printPrefixedHeaders(b, id, REQUEST_PREFIX, context.getStringHeaders());
if (printEntity && context.hasEntity()) {
final OutputStream stream = new LoggingStream(b, context.getEntityStream());
context.setEntityStream(stream);
context.setProperty(ENTITY_LOGGER_PROPERTY, stream);
// not calling log(b) here - it will be called by the interceptor
} else {
log(b);
}
}
示例4: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
Tracer.SpanBuilder builder = tracer.buildSpan(getOperationName(requestContext, resourceInfo))
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT)
.withTag(Tags.HTTP_URL.getKey(), requestContext.getUri().toString())
.withTag(Tags.HTTP_METHOD.getKey(), requestContext.getMethod())
.withTag(Tags.PEER_HOSTNAME.getKey(), requestContext.getUri().getHost())
.withTag(Tags.PEER_PORT.getKey(), requestContext.getUri().getPort());
final Span span = builder.startManual();
tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new ClientRequestContextTextMap(requestContext));
requestContext.setProperty(CLIENT_SPAN_CONTEXT_KEY, span);
}
示例5: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext request) throws IOException {
if (request.hasEntity() && isPrintable(request.getMediaType())) {
LoggingFilterOutputStream out = new LoggingFilterOutputStream(request.getEntityStream());
request.setEntityStream(out);
request.setProperty(LoggingFilterOutputStream.KEY, out);
}
}
示例6: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
System.out.println("Request: " + requestContext);
concurrentRequests.put(requestContext, System.nanoTime());
Optional<String> existingSpanId = extractTraceId(requestContext);
requestContext.setProperty(SPAN_EXISTED, existingSpanId.isPresent());
storeSpandId(requestContext, existingSpanId.orElseGet(this.tracEE::createId));
}
示例7: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) {
Timer.Context requestTimerContext = requestTimer.time();
requestContext.setProperty(TIMER_PROPERTY, requestTimerContext);
LOGGER.info("Client request started");
// note that response filter method may not be called at all if the
// request results in connection exception, etc... Would be nice to
// trace failed requests too, but nothing in JAX RS allows us to do
// that directly...
}
示例8: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
Boolean tracingDisabled = CastUtils.cast(requestContext.getProperty(TracingProperties.TRACING_DISABLED), Boolean.class);
if (tracingDisabled != null && tracingDisabled) {
log.finest("Client tracing disabled");
return;
}
// in case filter is registered twice
if (requestContext.getProperty(PROPERTY_NAME) != null) {
return;
}
Tracer.SpanBuilder spanBuilder = tracer.buildSpan(requestContext.getMethod())
.withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_CLIENT);
SpanContext parentSpanContext = CastUtils.cast(requestContext.getProperty(TracingProperties.CHILD_OF),
SpanContext.class);
if (parentSpanContext != null) {
spanBuilder.ignoreActiveSpan()
.asChildOf(parentSpanContext);
}
Span span = spanBuilder.startManual();
if (spanDecorators != null) {
for (ClientSpanDecorator decorator: spanDecorators) {
decorator.decorateRequest(requestContext, span);
}
}
if (log.isLoggable(Level.FINEST)) {
log.finest("Starting client span");
}
tracer.inject(span.context(), Format.Builtin.HTTP_HEADERS, new ClientHeadersInjectTextMap(requestContext.getHeaders()));
requestContext.setProperty(PROPERTY_NAME, new SpanWrapper(span));
}
示例9: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
/**
* Intercepts the client request flow and extract request information
* to be published to the DAS for tracing.
*/
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
long time = new Date().getTime();
String clientTraceId;
String traceOriginId;
String traceParentId = null;
if (this.parentEvent == null) {
traceOriginId = TracingUtil.generateUniqueId();
clientTraceId = traceOriginId;
} else {
traceOriginId = parentEvent.getOriginId();
clientTraceId = TracingUtil.generateUniqueId();
traceParentId = parentEvent.getTraceId();
}
TraceEvent clientTraceEvent = new TraceEvent(
TracingConstants.CLIENT_TRACE_START,
clientTraceId,
traceOriginId,
time
);
clientTraceEvent.setInstanceId(instanceId);
clientTraceEvent.setInstanceName(instanceName);
clientTraceEvent.setParentId(traceParentId);
clientTraceEvent.setHttpMethod(requestContext.getMethod());
clientTraceEvent.setUrl(requestContext.getUri().toString());
requestContext.setProperty(TRACE_EVENT_ATTRIBUTE, clientTraceEvent);
requestContext.getHeaders().putSingle(TracingConstants.TRACE_ID_HEADER, clientTraceId);
requestContext.getHeaders().putSingle(TracingConstants.TRACE_ORIGIN_ID_HEADER, traceOriginId);
TracingUtil.pushToDAS(clientTraceEvent, dasUrl);
}
示例10: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
requestContext.setProperty(PROPERTYNAME, System.nanoTime());
log.info(getCallSignature(requestContext));
}
示例11: wrapEntityStreamWithLogger
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
private void wrapEntityStreamWithLogger(ClientRequestContext requestContext) {
OutputStream entityStream = requestContext.getEntityStream();
LoggingOutputStream loggingOutputStream = new LoggingOutputStream(entityStream);
requestContext.setEntityStream(loggingOutputStream);
requestContext.setProperty(LOGGING_OUTPUT_STREAM_PROPERTY, loggingOutputStream);
}
示例12: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ClientRequestContext requestContext) throws IOException {
requestContext.setProperty(REQ_METRICS_KEY, handler.handle(new ClientRequestContextAdapter(requestContext)));
}
示例13: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
public void filter(ClientRequestContext requestContext) throws IOException {
TraceContext traceContext = requestInterceptor.process(new RequestAdapter(requestContext));
requestContext.getHeaders().add(SpanContextFactory.headerKey(),
SpanContextFactory.toHeader(traceContext.getHandle().getCurrentSpanContext()));
requestContext.setProperty(TRACE_CONTEXT_PROPERTY, traceContext);
}
示例14: filter
import javax.ws.rs.client.ClientRequestContext; //导入方法依赖的package包/类
/**
* Intercept Client request and add start timestamp.
*
* @param request Request to intercept
*
* @throws IOException if there's a problem processing the request
*/
@Override
public void filter(ClientRequestContext request) throws IOException {
appendRequestId(request.getStringHeaders().getFirst(X_REQUEST_ID_HEADER));
RequestLog.startTiming(CLIENT_TOTAL_TIMER);
request.setProperty(PROPERTY_NANOS, System.nanoTime());
}