當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。