当前位置: 首页>>代码示例>>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;未经允许,请勿转载。