本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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;
}
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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: 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;
}
示例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);
}