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


Java ResponseBuilder.cacheControl方法代码示例

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


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

示例1: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    ResponseBuilder response =
      Response.ok(new TableSchemaModel(getTableSchema()));
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (Exception e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return processException(e);
  } 
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:SchemaResource.java

示例2: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    ResponseBuilder response = Response.ok(getTableList());
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (Exception e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return processException(e);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:19,代码来源:RootResource.java

示例3: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    StorageClusterVersionModel model = new StorageClusterVersionModel();
    model.setVersion(servlet.getAdmin().getClusterStatus().getHBaseVersion());
    ResponseBuilder response = Response.ok(model);
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (IOException e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return Response.status(Response.Status.SERVICE_UNAVAILABLE)
      .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
      .build();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:StorageClusterVersionResource.java

示例4: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF, MIMETYPE_BINARY})
public Response get(final @Context UriInfo uriInfo) {
  try {
    if (!tableResource.exists()) {
      return Response.status(Response.Status.NOT_FOUND)
        .type(MIMETYPE_TEXT).entity("Not found" + CRLF)
        .build();
    }
  } catch (IOException e) {
    return Response.status(Response.Status.SERVICE_UNAVAILABLE)
      .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
      .build();
  }
  ResponseBuilder response = Response.ok();
  response.cacheControl(cacheControl);
  return response.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:20,代码来源:ExistsResource.java

示例5: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
/**
 * Build a response for a version request.
 * @param context servlet context
 * @param uriInfo (JAX-RS context variable) request URL
 * @return a response for a version request 
 */
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context ServletContext context, 
    final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  ResponseBuilder response = Response.ok(new VersionModel(context));
  response.cacheControl(cacheControl);
  servlet.getMetrics().incrementSucessfulGetRequests(1);
  return response.build();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:VersionResource.java

示例6: getBinary

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces(MIMETYPE_BINARY)
public Response getBinary(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath() + " as " +
      MIMETYPE_BINARY);
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    Cell value = generator.next();
    if (value == null) {
      LOG.info("generator exhausted");
      return Response.noContent().build();
    }
    ResponseBuilder response = Response.ok(CellUtil.cloneValue(value));
    response.cacheControl(cacheControl);
    response.header("X-Row", Base64.encodeBytes(CellUtil.cloneRow(value)));      
    response.header("X-Column", 
      Base64.encodeBytes(
        KeyValue.makeColumn(CellUtil.cloneFamily(value), CellUtil.cloneQualifier(value))));
    response.header("X-Timestamp", value.getTimestamp());
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (IllegalStateException e) {
    if (ScannerResource.delete(id)) {
      servlet.getMetrics().incrementSucessfulDeleteRequests(1);
    } else {
      servlet.getMetrics().incrementFailedDeleteRequests(1);
    }
    servlet.getMetrics().incrementFailedGetRequests(1);
    return Response.status(Response.Status.GONE)
      .type(MIMETYPE_TEXT).entity("Gone" + CRLF)
      .build();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:ScannerInstanceResource.java

示例7: get

import javax.ws.rs.core.Response.ResponseBuilder; //导入方法依赖的package包/类
@GET
@Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON, MIMETYPE_PROTOBUF,
  MIMETYPE_PROTOBUF_IETF})
public Response get(final @Context UriInfo uriInfo) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("GET " + uriInfo.getAbsolutePath());
  }
  servlet.getMetrics().incrementRequests(1);
  try {
    ClusterStatus status = servlet.getAdmin().getClusterStatus();
    StorageClusterStatusModel model = new StorageClusterStatusModel();
    model.setRegions(status.getRegionsCount());
    model.setRequests(status.getRequestsCount());
    model.setAverageLoad(status.getAverageLoad());
    for (ServerName info: status.getServers()) {
      ServerLoad load = status.getLoad(info);
      StorageClusterStatusModel.Node node =
        model.addLiveNode(
          info.getHostname() + ":" +
          Integer.toString(info.getPort()),
          info.getStartcode(), load.getUsedHeapMB(),
          load.getMaxHeapMB());
      node.setRequests(load.getNumberOfRequests());
      for (RegionLoad region: load.getRegionsLoad().values()) {
        node.addRegion(region.getName(), region.getStores(),
          region.getStorefiles(), region.getStorefileSizeMB(),
          region.getMemStoreSizeMB(), region.getStorefileIndexSizeMB(),
          region.getReadRequestsCount(), region.getWriteRequestsCount(),
          region.getRootIndexSizeKB(), region.getTotalStaticIndexSizeKB(),
          region.getTotalStaticBloomSizeKB(), region.getTotalCompactingKVs(),
          region.getCurrentCompactedKVs());
      }
    }
    for (ServerName name: status.getDeadServerNames()) {
      model.addDeadNode(name.toString());
    }
    ResponseBuilder response = Response.ok(model);
    response.cacheControl(cacheControl);
    servlet.getMetrics().incrementSucessfulGetRequests(1);
    return response.build();
  } catch (IOException e) {
    servlet.getMetrics().incrementFailedGetRequests(1);
    return Response.status(Response.Status.SERVICE_UNAVAILABLE)
      .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
      .build();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:48,代码来源:StorageClusterStatusResource.java


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