当前位置: 首页>>代码示例>>Java>>正文


Java ClientRequestContext.setProperty方法代码示例

本文整理汇总了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);
}
 
开发者ID:icode,项目名称:ameba,代码行数:26,代码来源:LoggingFilter.java

示例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);
    }
}
 
开发者ID:obsidian-toaster-quickstarts,项目名称:redhat-sso,代码行数:17,代码来源:LoggingFilter.java

示例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);
    }
}
 
开发者ID:docker-java,项目名称:docker-java,代码行数:18,代码来源:LoggingFilter.java

示例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);
}
 
开发者ID:ExpediaDotCom,项目名称:haystack-client-java,代码行数:15,代码来源:ClientFilter.java

示例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);
    }
}
 
开发者ID:intuit,项目名称:karate,代码行数:9,代码来源:LoggingInterceptor.java

示例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));

}
 
开发者ID:AdamBien,项目名称:SpanEE,代码行数:10,代码来源:SpanEEClientRequestFilter.java

示例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...
}
 
开发者ID:bootique,项目名称:bootique-jersey-client,代码行数:13,代码来源:ClientTimingFilter.java

示例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));
}
 
开发者ID:opentracing-contrib,项目名称:java-jaxrs,代码行数:40,代码来源:ClientTracingFilter.java

示例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);
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:35,代码来源:MSF4JClientTracingFilter.java

示例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));
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:6,代码来源:ClientLogFilter.java

示例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);
}
 
开发者ID:SK-EID,项目名称:smart-id-java-client,代码行数:7,代码来源:LoggingFilter.java

示例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)));
}
 
开发者ID:SAP,项目名称:cf-java-logging-support,代码行数:5,代码来源:RequestMetricsClientRequestFilter.java

示例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);
}
 
开发者ID:GoogleCloudPlatform,项目名称:cloud-trace-java-instrumentation,代码行数:7,代码来源:TraceClientFilter.java

示例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());
}
 
开发者ID:yahoo,项目名称:fili,代码行数:14,代码来源:BardLoggingFilter.java


注:本文中的javax.ws.rs.client.ClientRequestContext.setProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。