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


Java CacheControl类代码示例

本文整理汇总了Java中io.dropwizard.jersey.caching.CacheControl的典型用法代码示例。如果您正苦于以下问题:Java CacheControl类的具体用法?Java CacheControl怎么用?Java CacheControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getNode

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/{id}")
@ApiOperation(value = "Get all properties of a node", response = Graph.class)
@Timed
@CacheControl(maxAge = 2, maxAgeUnit = TimeUnit.HOURS)
@Produces({MediaType.APPLICATION_JSON, CustomMediaTypes.APPLICATION_GRAPHSON,
    MediaType.APPLICATION_XML, CustomMediaTypes.APPLICATION_GRAPHML,
    CustomMediaTypes.APPLICATION_XGMML, CustomMediaTypes.TEXT_GML, CustomMediaTypes.TEXT_CSV,
    CustomMediaTypes.TEXT_TSV, CustomMediaTypes.IMAGE_JPEG, CustomMediaTypes.IMAGE_PNG})
public Object getNode(
    @ApiParam(value = DocumentationStrings.GRAPH_ID_DOC,
        required = true) @PathParam("id") String id,
    @ApiParam(value = DocumentationStrings.PROJECTION_DOC,
        required = false) @QueryParam("project") @DefaultValue("*") Set<String> projection,
    @ApiParam(value = DocumentationStrings.JSONP_DOC,
        required = false) @QueryParam("callback") String callback) {
  return getNeighbors(id, new IntParam("0"), new BooleanParam("false"), Optional.<String>empty(),
      null, new BooleanParam("false"), projection, callback);
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:20,代码来源:GraphService.java

示例2: getAllProductCatalog

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.HOURS)
public List<ProductCatalogRepresentation> getAllProductCatalog() {
	LOGGER.info("Retrieving all product catalog details of the product");
	List<ProductCatalog> details = productCatalogService.getAllProductDetails();
	if (details == null) {
		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	LOGGER.debug("Product details:" + details.toString());
	List<ProductCatalogRepresentation> representations = new ArrayList<>();
	for (ProductCatalog detail : details) {
		representations.add(ProductRepresentationDomainConverter.toRepresentation(detail));
	}
	return representations;
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:19,代码来源:ProductCatalogResource.java

示例3: getAllProductReviews

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/{skuId}")
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.HOURS)
public List<ProductReviewRepresentation> getAllProductReviews(@PathParam("skuId") String skuId) {
	LOGGER.info("Retrieving all product reviews of the product:" + skuId);
	List<ProductReview> reviews = productReviewService.getAllProductReviews(skuId);
	if (reviews == null || reviews.isEmpty()) {
		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	List<ProductReviewRepresentation> representations = new ArrayList<>();
	for (ProductReview review : reviews) {
		representations.add(ProductReviewRepresentationDomainConverter.toRepresentation(review));
	}
	return representations;
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:19,代码来源:ProductReviewResource.java

示例4: getProductCatalog

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/{id}")
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.SECONDS)
@JacksonFeatures(serializationEnable = { SerializationFeature.INDENT_OUTPUT })
public ProductRepresentation getProductCatalog(@Auth User user, @PathParam("id") String id) throws Exception {
	LOGGER.info("Fetching the product catalog for the product with id:" + id);
	ProductRepresentation product = new ProductRepresentation();
	JSONObject productCatalog = productCatalogClient.getProductCatalog(id);
	if (productCatalog == null) {
		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	product.setProductCatalog((HashMap<String, Object>) productCatalog.toMap());
	List<HashMap<String, Object>> reviewList = new ArrayList<>();
	List<Object> reviews = productReviewClient.getProductReviews(id).toList();
	for (Object review : reviews) {
		reviewList.add((HashMap<String, Object>) review);
	}
	product.setProductReviews(reviewList);
	return product;
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:24,代码来源:ProductResource.java

示例5: findById

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/id/{id}")
@ApiOperation(value = "Find a concept by its ID",
notes = "Find concepts that match either a IRI or a CURIE. ",
response = ConceptDTO.class)
@ApiResponses({
  @ApiResponse(code = 404, message = "Concept with ID could not be found")
})
@Timed
@CacheControl(maxAge = 2, maxAgeUnit = TimeUnit.HOURS)
public ConceptDTO findById(
    @ApiParam( value = "ID to find", required = true)
    @PathParam("id") String id) throws Exception {
  Vocabulary.Query query = new Vocabulary.Query.Builder(id).build();
  Optional<Concept> concept = vocabulary.getConceptFromId(query);
  if (!concept.isPresent()) {
    throw new WebApplicationException(404);
  } else {
    ConceptDTO dto = conceptDtoTransformer.apply(concept.get());
    return dto;
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:23,代码来源:VocabularyService.java

示例6: suggestFromTerm

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/suggestions/{term}")
@ApiOperation(value = "Suggest terms",
notes = "Suggests terms based on a mispelled or mistyped term.",
response = String.class,
responseContainer = "List")
@Timed
@CacheControl(maxAge = 2, maxAgeUnit = TimeUnit.HOURS)
public Object suggestFromTerm(
    @ApiParam( value = "Mispelled term", required = true )
    @PathParam("term") String term,
    @ApiParam( value = DocumentationStrings.RESULT_LIMIT_DOC, required = false )
    @QueryParam("limit") @DefaultValue("1") IntParam limit) {
  List<String> suggestions = newArrayList(Iterables.limit(vocabulary.getSuggestions(term), limit.get()));
  return suggestions;
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:17,代码来源:VocabularyService.java

示例7: getIdAsProtobuf

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
/**
 * Get one or more IDs as a Google Protocol Buffer response
 *
 * @param agent
 *            User Agent
 * @param count
 *            Number of IDs to return
 * @return generated IDs
 */
@GET
@Timed
@Produces(ProtocolBufferMediaType.APPLICATION_PROTOBUF)
@CacheControl(mustRevalidate = true, noCache = true, noStore = true)
public SnowizardResponse getIdAsProtobuf(
        @HeaderParam(HttpHeaders.USER_AGENT) final String agent,
        @QueryParam("count") final Optional<IntParam> count) {

    final List<Long> ids = Lists.newArrayList();
    if (count.isPresent()) {
        for (int i = 0; i < count.get().get(); i++) {
            ids.add(getId(agent));
        }
    } else {
        ids.add(getId(agent));
    }
    return SnowizardResponse.newBuilder().addAllId(ids).build();
}
 
开发者ID:GeneralElectric,项目名称:snowizard,代码行数:28,代码来源:IdResource.java

示例8: get

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@CacheControl(maxAge = 1, maxAgeUnit = DAYS)
public Response get() {
    DaylightDto daylight = new DaylightDto();
    daylight.setSunrise(OffsetTime.of(6, 0, 0, 0, STOCKHOLM_OFFSET));
    daylight.setSunset(OffsetTime.of(18, 0, 0, 0, STOCKHOLM_OFFSET));
    return Response.ok(daylight).expires(endOfTheDayUtcTime()).build();
}
 
开发者ID:andreschaffer,项目名称:http-caching-and-concurrency-examples,代码行数:9,代码来源:DaylightResource.java

示例9: configure

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
    /* don't add a header if the method provides its own annotation */
    CacheControl cacheControl = resourceInfo.getResourceMethod().getAnnotation(CacheControl.class);
    if (cacheControl == null) {
        context.register(NO_TRANSFORM_FILTER);
    }
}
 
开发者ID:openregister,项目名称:openregister-java,代码行数:9,代码来源:CacheNoTransformFilterFactory.java

示例10: getAuthenticatedUser

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@PermitAll
@Path("/services/oauth2/user")
@CacheControl(noCache = true)
@ApiOperation("Get authenticated user.")
public User getAuthenticatedUser(
  @Context SecurityContext securityContext
) {
  return RestHelper.getUser(securityContext);
}
 
开发者ID:atgse,项目名称:sam,代码行数:11,代码来源:OAuth2Resource.java

示例11: getProductCatalog

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/{id}")
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.SECONDS)
public ProductCatalogRepresentation getProductCatalog(@PathParam("id") String id) {
	LOGGER.info("Retrieving product catalog details of the product with id:" + id);
	ProductCatalog details = productCatalogService.getProductDetails(id);
	if (details == null) {
		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	LOGGER.debug("Product details:" + details.toString());
	return ProductRepresentationDomainConverter.toRepresentation(details);
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:16,代码来源:ProductCatalogResource.java

示例12: getAllProductCatalog

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
@Path("/catalog")
@Timed(name = "showAll-timed-get")
@Metered(name = "showAll-metered-get")
@ExceptionMetered
@CacheControl(maxAge = 12, maxAgeUnit = TimeUnit.SECONDS)
@JacksonFeatures(serializationEnable = { SerializationFeature.INDENT_OUTPUT })
public List<Object> getAllProductCatalog(@Auth Admin user) throws Exception {
	LOGGER.info("Fetching all the product catalog for the product ");
	JSONArray productCatalogs = productCatalogClient.getAllProductCatalog();
	if (productCatalogs == null) {
		throw new WebApplicationException(Response.Status.NOT_FOUND);
	}
	return productCatalogs.toList();
}
 
开发者ID:G1GC,项目名称:dropwizard-microservices-example,代码行数:16,代码来源:ProductResource.java

示例13: getTestData

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@GET
    @Path("/test")
    @CacheControl(maxAge = 60)
    @CacheGroup("otter")
    @Vary({"ACCEPT", "ACCEPT-LANGUAGE"})
    public ExampleResult getTestData(@Context HttpContext requestContext) {
//        throw new RuntimeException("uh oh");
        return new ExampleResult(_count++);
    }
 
开发者ID:bazaarvoice,项目名称:dropwizard-caching-bundle,代码行数:10,代码来源:ExampleResource.java

示例14: create

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
@Override
public RequestDispatcher create(AbstractResourceMethod abstractResourceMethod) {
    RequestDispatcher dispatcher = _provider.create(abstractResourceMethod);
    CacheGroup groupNameAnn = abstractResourceMethod.getAnnotation(CacheGroup.class);
    Vary varyAnn = abstractResourceMethod.getAnnotation(Vary.class);
    IncludeBodyInCacheKey includeBodyInCacheKeyAnn = abstractResourceMethod.getAnnotation(IncludeBodyInCacheKey.class);

    Set<String> vary = ImmutableSet.of();

    if (varyAnn != null && varyAnn.value() != null) {
        vary = HttpHeaderUtils.headerNames(Iterables.filter(
                Arrays.asList(varyAnn.value()),
                Predicates.notNull()));
    }

    boolean includeBodyInCacheKey = includeBodyInCacheKeyAnn != null && includeBodyInCacheKeyAnn.enabled();

    if (groupNameAnn != null || abstractResourceMethod.isAnnotationPresent(CacheControl.class)) {
        String groupName = groupNameAnn == null ? "" : groupNameAnn.value();
        dispatcher = new CachingDispatcher(dispatcher, _cache, _cacheControlMapper.apply(groupName), vary, includeBodyInCacheKey);
    } else if (abstractResourceMethod.getHttpMethod().equals("GET")) {
        Optional<String> cacheControlOverride = _cacheControlMapper.apply("");

        if (cacheControlOverride != null && cacheControlOverride.isPresent()) {
            dispatcher = new CachingDispatcher(dispatcher, _cache, cacheControlOverride, vary, includeBodyInCacheKey);
        }
    }

    return dispatcher;
}
 
开发者ID:bazaarvoice,项目名称:dropwizard-caching-bundle,代码行数:31,代码来源:CacheResourceMethodDispatchAdapter.java

示例15: getUserHierarchicalMenu

import io.dropwizard.jersey.caching.CacheControl; //导入依赖的package包/类
/**
 * get menu for logged user
 *
 * @param credentials injected by {@link RobeAuth} annotation for authentication.
 * @return user {@link MenuItem} as collection
 */

@RobeService(group = "Menu", description = "Get menu for logged user")
@Path("user")
@GET
@UnitOfWork(readOnly = true, cacheMode = GET, flushMode = FlushMode.MANUAL)
@CacheControl(noCache = true)
public List<MenuItem> getUserHierarchicalMenu(@RobeAuth Credentials credentials) {
    Optional<User> user = userDao.findByUsername(credentials.getUsername());
    Set<Permission> permissions = new HashSet<Permission>();

    Role parent = roleDao.findById(user.get().getRoleOid());
    getAllRolePermissions(parent, permissions);
    Set<String> menuOids = new HashSet<String>();

    List<MenuItem> items = convertMenuToMenuItem(menuDao.findHierarchicalMenu());
    items = readMenuHierarchical(items);

    for (Permission permission : permissions) {
        if (permission.getType().equals(Permission.Type.MENU)) {
            menuOids.add(permission.getRestrictedItemOid());
        }
    }
    List<MenuItem> permittedItems = new LinkedList<MenuItem>();

    createMenuWithPermissions(menuOids, items, permittedItems);

    return permittedItems;
}
 
开发者ID:robeio,项目名称:robe,代码行数:35,代码来源:MenuResource.java


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