當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientRequestContext.getProperty方法代碼示例

本文整理匯總了Java中javax.ws.rs.client.ClientRequestContext.getProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientRequestContext.getProperty方法的具體用法?Java ClientRequestContext.getProperty怎麽用?Java ClientRequestContext.getProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.client.ClientRequestContext的用法示例。


在下文中一共展示了ClientRequestContext.getProperty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 request, ClientResponseContext response) throws IOException {
    StringBuilder debugMsgBuilder = new StringBuilder();

    debugMsgBuilder.append("ClientRequest: ").append(request.getMethod()).append("\t");
    debugMsgBuilder.append(request.getUri().toASCIIString()).append("\t");

    appendObjectHeaders(debugMsgBuilder, "> ", request.getHeaders().entrySet());
    appendStringHeaders(debugMsgBuilder, "< ", response.getHeaders().entrySet());

    debugMsgBuilder.append(response.getStatusInfo()).append(", length=").append(response.getLength()).append(" ");

    Long requestStartTime = (Long) request.getProperty(PROPERTY_NANOS);
    if (requestStartTime != null) {
        debugMsgBuilder
                .append((System.nanoTime() - requestStartTime) / MILLISECONDS_PER_NANOSECOND)
                .append(" ms\t");
    }

    LOG.debug(debugMsgBuilder.toString());
    RequestLog.stopTiming(CLIENT_TOTAL_TIMER);
}
 
開發者ID:yahoo,項目名稱:fili,代碼行數:23,代碼來源:BardLoggingFilter.java

示例3: filter

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
/**
 * Intercepts the client response flow and extract response information
 * to be published to the DAS server for tracing.
 */
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
    long time = new Date().getTime();
    TraceEvent traceEvent = (TraceEvent) requestContext.getProperty(TRACE_EVENT_ATTRIBUTE);
    if (traceEvent != null) {
        TraceEvent endTraceEvent = new TraceEvent(
                TracingConstants.CLIENT_TRACE_END,
                traceEvent.getTraceId(),
                traceEvent.getOriginId(),
                time
        );
        endTraceEvent.setStatusCode(responseContext.getStatus());
        TracingUtil.pushToDAS(endTraceEvent, dasUrl);
    }
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:20,代碼來源:MSF4JClientTracingFilter.java

示例4: checkParams

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
/**
 * Check parameters on request Context
 * @param requestContext
 */
private void checkParams(ClientRequestContext requestContext){
    if (key==null) {
        Object keyObject = requestContext.getProperty(JWS_FILTER_KEY);
        if (keyObject == null) {
            requestContext.abortWith(
                    Response.status(Response.Status.BAD_REQUEST).entity("Error " + JWS_FILTER_KEY + " param is required")
                            .build()
            );
        }else if (keyObject instanceof RSAPrivateKey) {
            key = (RSAPrivateKey)keyObject;

       }

    }
}
 
開發者ID:Appverse,項目名稱:appverse-server,代碼行數:20,代碼來源:JWSJerseyFilter.java

示例5: filter

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
public void filter(ClientRequestContext requestContext) throws IOException {
	// Wrap entity to store property filters
	SpearalPropertyFilterBuilder clientPropertyFilterBuilder = (SpearalPropertyFilterBuilder)requestContext.getProperty(SpearalJaxrs.PROPERTY_FILTER_CLIENT);
	if (clientPropertyFilterBuilder != null)
		requestContext.setEntity(new SpearalEntity(requestContext.getEntity(), clientPropertyFilterBuilder));
	
	// Transmit server property filters as http header
	SpearalPropertyFilterBuilder serverPropertyFilterBuilder = (SpearalPropertyFilterBuilder)requestContext.getProperty(SpearalJaxrs.PROPERTY_FILTER_SERVER);
	if (serverPropertyFilterBuilder == null)
		return;
	
	SpearalFactory factory = SpearalJaxrs.locateFactory(configuration, providers);
	
	List<Object> serverPropertyFilterHeaders = new ArrayList<Object>(serverPropertyFilterBuilder.toHeaders(factory.getContext()));
	requestContext.getHeaders().put(Spearal.PROPERTY_FILTER_HEADER, serverPropertyFilterHeaders);
}
 
開發者ID:spearal,項目名稱:spearal-jaxrs,代碼行數:17,代碼來源:SpearalClientRequestFilter.java

示例6: filter

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
    try {
        Span span = (Span) requestContext.getProperty(CLIENT_SPAN_CONTEXT_KEY);
        if (span != null) {
            Tags.HTTP_STATUS.set(span, responseContext.getStatus());
            span.finish();
        }
    }
    catch (Exception e) {
        LOGGER.error("Client Tracing Filter failed:", e);
    }
}
 
開發者ID:ExpediaDotCom,項目名稱:haystack-client-java,代碼行數:14,代碼來源:ClientFilter.java

示例7: filter

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) {
	Timer.Context requestTimerContext = (Timer.Context) requestContext.getProperty(TIMER_PROPERTY);

	// TODO: this timing does not take into account reading response
	// content... May need to add additional interceptor for that.
	long timeNanos = requestTimerContext.stop();

	LOGGER.info("Client request finished. Status: {}, time: {} ms.", responseContext.getStatus(),
			timeNanos / 1000000);
}
 
開發者ID:bootique,項目名稱:bootique-jersey-client,代碼行數:12,代碼來源: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: getVisitedLocationsProperty

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private Set<URI> getVisitedLocationsProperty(ClientRequestContext requestContext) {
    final Object rawValue = requestContext.getProperty(VISITED_LOCATIONS_KEY);
    return rawValue == null
            ? Collections.<URI>emptySet()
            : (Set<URI>) rawValue;
}
 
開發者ID:BrandwatchLtd,項目名稱:robots,代碼行數:8,代碼來源:FollowRedirectsFilter.java

示例10: filter

import javax.ws.rs.client.ClientRequestContext; //導入方法依賴的package包/類
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext)
    throws IOException {
  TraceContext traceContext = (TraceContext) requestContext.getProperty(TRACE_CONTEXT_PROPERTY);
  responseInterceptor.process(new ResponseAdapter(responseContext), traceContext);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:cloud-trace-java-instrumentation,代碼行數:6,代碼來源:TraceClientFilter.java


注:本文中的javax.ws.rs.client.ClientRequestContext.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。