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


Java ContainerResponse.getStatus方法代码示例

本文整理汇总了Java中com.sun.jersey.spi.container.ContainerResponse.getStatus方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerResponse.getStatus方法的具体用法?Java ContainerResponse.getStatus怎么用?Java ContainerResponse.getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jersey.spi.container.ContainerResponse的用法示例。


在下文中一共展示了ContainerResponse.getStatus方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    if (response.getStatusType().getFamily() == Response.Status.Family.SERVER_ERROR) {
        switch (response.getStatus()) {
            case 500:
                _meter500.mark();
                break;
            case 503:
                _meter503.mark();
                break;
            default:
                _meterOther.mark();
                break;
        }
    }
    return response;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:18,代码来源:ServerErrorResponseMetricsFilter.java

示例2: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {

  Collection<Object> contentTypes = response.getHttpHeaders().get("Content-Type");
  //LOGGER.debug("content types {}", contentTypes);
  if (null != contentTypes) {
    for (Object contentType : contentTypes) {
      if (contentType.equals(APPLICATION_X_PROTOBUF_TYPE) && !shouldSkipWrapping(response.getEntity())) {
        LOGGER.debug("Content type is x-protobuf, wrap response entity");
        ResponseCodeEntityWrapper<Object> wrapper = new ResponseCodeEntityWrapper<>(response.getStatus(), response.getEntity());
        response.setEntity(wrapper, response.getEntityType());
        break;
      }
    }

  }

  return response;
}
 
开发者ID:Wadpam,项目名称:guja,代码行数:20,代码来源:ProtoWrapperResponseFilter.java

示例3: addRequestIdToResponse

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
/**
 * Private helper that adds the request-id to the response payload.
 * @param response
 */
private void addRequestIdToResponse(ContainerResponse response) {
	
	// The request-id to be injected in the response
	String requestId = StaashRequestContext.getRequestId();
	
	// The key response attributes
	int status = response.getStatus();
	MediaType mediaType = response.getMediaType();
	
	if (mediaType.equals(MediaType.APPLICATION_JSON_TYPE)) {
		
		String message = (String)response.getEntity();
		JsonObject json = new JsonObject(message);
		json.putString("request-id", requestId);
		
		Response newJerseyResponse = Response.status(status).type(mediaType).entity(json.toString()).build();
		response.setResponse(newJerseyResponse);
	}
		
	// Add the request id to the response regardless of the media type, 
	// this allows non json responses to have a request id in the response
	response.getHttpHeaders().add("x-nflx-staash-request-id", requestId);
}
 
开发者ID:Netflix,项目名称:staash,代码行数:28,代码来源:StaashAuditFilter.java

示例4: filter

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
@Override
public ContainerResponse filter(ContainerRequest request, ContainerResponse response) {
    Integer status = response.getStatus();

    Counter counter = counters.get(status);
    if (counter == null) {
        // despite the method name, this actually will return a previously created metric with the same name
        Counter newCounter = metricsRegistry.counter(
            MetricRegistry.name(resourceClass, metricBaseName + " " + status + " counter"));
        Counter otherCounter = counters.putIfAbsent(status, newCounter);
        if (otherCounter != null) {
            // we lost the race to set that counter, but shouldn't create a duplicate since Metrics.newCounter will do the right thing
            counter = otherCounter;
        } else {
            counter = newCounter;
        }
    }

    counter.inc();

    return response;
}
 
开发者ID:palominolabs,项目名称:jersey-metrics-filter,代码行数:23,代码来源:HttpStatusCodeCounterResourceFilter.java

示例5: bridgeResponse

import com.sun.jersey.spi.container.ContainerResponse; //导入方法依赖的package包/类
ContainerResponseWriter bridgeResponse(final HttpServerResponse<ByteBuf> serverResponse) {
    return new ContainerResponseWriter() {

        private final ByteBuf contentBuffer = serverResponse.getChannel().alloc().buffer();

        @Override
        public OutputStream writeStatusAndHeaders(long contentLength, ContainerResponse response) {
            int responseStatus = response.getStatus();
            serverResponse.setStatus(HttpResponseStatus.valueOf(responseStatus));
            HttpResponseHeaders responseHeaders = serverResponse.getHeaders();
            for(Map.Entry<String, List<Object>> header : response.getHttpHeaders().entrySet()){
                responseHeaders.setHeader(header.getKey(), header.getValue());
            }
            return new ByteBufOutputStream(contentBuffer);
        }

        @Override
        public void finish() {
            serverResponse.writeAndFlush(contentBuffer);
        }
    };
}
 
开发者ID:Netflix,项目名称:karyon,代码行数:23,代码来源:NettyToJerseyBridge.java


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