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


Java CacheControl.setPrivate方法代码示例

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


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

示例1: show

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("{derivate}{path: (/[^?#]*)?}")
public Response show(@Context HttpServletRequest request, @Context Request jaxReq,
    @Context ServletContext context, @Context ServletConfig config) throws Exception {
    MCRContent content = getContent(request);
    String contentETag = content.getETag();
    Response.ResponseBuilder responseBuilder = null;
    EntityTag eTag = contentETag == null ? null : new EntityTag(contentETag);
    if (eTag != null) {
        responseBuilder = jaxReq.evaluatePreconditions(eTag);
    }
    if (responseBuilder == null) {
        responseBuilder = Response.ok(content.asByteArray(), MediaType.valueOf(content.getMimeType()));
    }
    if (eTag != null) {
        responseBuilder.tag(eTag);
    }
    if (content.isUsingSession()) {
        CacheControl cc = new CacheControl();
        cc.setPrivate(true);
        cc.setMaxAge(0);
        cc.setMustRevalidate(true);
        responseBuilder.cacheControl(cc);
    }
    return responseBuilder.build();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:27,代码来源:MCRViewerResource.java

示例2: newResponseBuilder

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
final ResponseBuilder newResponseBuilder(final Status status, @Nullable final Object entity,
        @Nullable final GenericType<?> type) {
    Preconditions.checkState(this.context.variant != null);
    final ResponseBuilder builder = Response.status(status);
    if (entity != null) {
        builder.entity(type == null ? entity : new GenericEntity<Object>(entity, type
                .getType()));
        builder.variant(this.context.variant);
        final CacheControl cacheControl = new CacheControl();
        cacheControl.setNoStore(true);
        if ("GET".equalsIgnoreCase(this.request.getMethod())
                || "HEAD".equalsIgnoreCase(this.request.getMethod())) {
            builder.lastModified(this.context.lastModified);
            builder.tag(this.context.etag);
            if (isCachingEnabled()) {
                cacheControl.setNoStore(false);
                cacheControl.setMaxAge(0); // always stale, must revalidate each time
                cacheControl.setMustRevalidate(true);
                cacheControl.setPrivate(getUsername() != null);
                cacheControl.setNoTransform(true);
            }
        }
        builder.cacheControl(cacheControl);
    }
    return builder;
}
 
开发者ID:dkmfbk,项目名称:knowledgestore,代码行数:27,代码来源:Resource.java

示例3: index

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
 * Show a photo.
 * @param num ID of the user
 * @return PNG
 * @throws IOException If fails
 */
@GET
@Path("/{id : \\d+}.png")
@Produces("image/png")
public Response index(@PathParam("id") final String num)
    throws IOException {
    final URN urn = URN.create(String.format("urn:aintshy:%s", num));
    final byte[] png = this.base().human(urn).profile().photo();
    if (png == null) {
        throw new WebApplicationException(
            Response.seeOther(
                URI.create("http://img.aintshy.com/no-photo.png")
            ).build()
        );
    }
    final CacheControl cache = new CacheControl();
    cache.setMaxAge((int) TimeUnit.HOURS.toSeconds(1L));
    cache.setPrivate(false);
    return Response.ok(new ByteArrayInputStream(png))
        .cacheControl(cache)
        .type("image/png")
        .build();
}
 
开发者ID:aintshy,项目名称:hub,代码行数:29,代码来源:PhotoRs.java

示例4: createCacheControl

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
 * Converts a {@code Cache-Control} annotation to a {@code Cache-Control}
 * Jersey API object.
 *
 * @param annotation the annotation
 *
 * @return the Jersey API object
 *
 * @see javax.ws.rs.core.CacheControl
 * @see com.github.autermann.jersey.cache.CacheControl
 */
private CacheControl createCacheControl(
        com.github.autermann.jersey.cache.CacheControl annotation) {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(annotation._private() ||
                            annotation.privateFields().length > 0);
    cacheControl.getPrivateFields()
            .addAll(Arrays.asList(annotation.privateFields()));
    cacheControl.setMustRevalidate(annotation.mustRevalidate());
    cacheControl.setNoCache(annotation.noCache() ||
                            annotation.noCacheFields().length > 0);
    cacheControl.getNoCacheFields()
            .addAll(Arrays.asList(annotation.noCacheFields()));
    cacheControl.setNoStore(annotation.noStore());
    cacheControl.setNoTransform(annotation.noTransform());
    cacheControl.setProxyRevalidate(annotation.proxyRevalidate());
    cacheControl.setMaxAge(annotation.maxAge());
    cacheControl.setSMaxAge(annotation.sMaxAge());
    for (CacheControlExtension e : annotation.extensions()) {
        cacheControl.getCacheExtension().put(e.key(), e.value());
    }
    return cacheControl;
}
 
开发者ID:autermann,项目名称:jersey-cache-control,代码行数:34,代码来源:CacheControlFilterFactory.java

示例5: getVersionInfo

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("version")
@Produces(MediaType.APPLICATION_JSON)
public Response getVersionInfo() {

	CacheControl cc = new CacheControl();
	cc.setMaxAge(60 * 60 * 24); // seconds
	cc.setPrivate(true);

	return Response
               .status(Response.Status.OK)
               .cacheControl(cc)
               .entity(graphene.getVersionInfo())
               .build();
   }
 
开发者ID:Lambda-3,项目名称:Graphene,代码行数:16,代码来源:AdminResource.java

示例6: fromString

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@Override
public CacheControl fromString(final String value) {
    if (value == null) {
        return null;
    }

    final CacheControl result = new CacheControl();
    result.setPrivate(true);
    result.setNoTransform(false);

    for (final String directive : value.split(",\\s+")) {
        if (directive.startsWith("max-age=")) {
            result.setMaxAge(Integer.parseInt(directive.split("=")[1]));
        } else if (directive.equals("must-revalidate")) {
            result.setMustRevalidate(true);
        } else if (directive.equals("no-cache")) {
            result.setNoCache(true);
        } else if (directive.equals("no-store")) {
            result.setNoStore(true);
        } else if (directive.equalsIgnoreCase("no-transform")) {
            result.setNoTransform(true);
        } else if (directive.equals("private")) {
            result.setPrivate(true);
        } else if (directive.equals("proxy-revalidate")) {
            result.setProxyRevalidate(true);
        } else if (directive.equals("public")) {
            result.setPrivate(false);
        } else if (directive.startsWith("s-maxage=")) {
            result.setSMaxAge(Integer.parseInt(directive.split("=")[1]));
        }
    }

    return result;
}
 
开发者ID:minijax,项目名称:minijax,代码行数:35,代码来源:MinijaxCacheControlDelegate.java

示例7: testSerializeFull

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@Test
public void testSerializeFull() {
    final CacheControl c = new CacheControl();
    c.setMaxAge(100);
    c.setMustRevalidate(true);
    c.setNoCache(true);
    c.setNoStore(true);
    c.setNoTransform(false);
    c.setPrivate(true);
    c.setProxyRevalidate(true);
    c.setSMaxAge(200);
    assertEquals(
            "private, max-age=100, s-maxage=200, must-revalidate, no-cache, no-store, proxy-revalidate",
            d.toString(c));
}
 
开发者ID:minijax,项目名称:minijax,代码行数:16,代码来源:CacheControlDelegateTest.java

示例8: noCache

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
 * Edit the response headers to indicating no caching.
 *
 * @param response response
 * @return builder
 */
protected Response.ResponseBuilder noCache(final Response.ResponseBuilder response) {
    final CacheControl cacheControl = new CacheControl();
    cacheControl.setPrivate(true);
    cacheControl.setNoCache(true);
    cacheControl.setNoStore(true);
    return response.cacheControl(cacheControl);
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:14,代码来源:ApplicationResource.java

示例9: applyCachePolicyToResponse

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
/**
 * Apply cache policy to a response.
 *
 * @param response     The response builder.
 * @param eTag         The ETag of the resource.
 * @param lastModified The last modified date of the resource.
 * @return The response builder with the cache policy.
 */
private static Response.ResponseBuilder applyCachePolicyToResponse(Response.ResponseBuilder response, EntityTag eTag, Date lastModified) {
    CacheControl cc = new CacheControl();
    cc.setMaxAge(CACHE_SECOND);
    cc.setNoTransform(false);
    cc.setPrivate(false);

    Calendar expirationDate = Calendar.getInstance();
    expirationDate.add(Calendar.SECOND, CACHE_SECOND);

    return response.cacheControl(cc)
            .expires(expirationDate.getTime())
            .lastModified(lastModified)
            .tag(eTag);
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:23,代码来源:BinaryResourceDownloadResponseBuilder.java

示例10: createCacheControl

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
private static CacheControl createCacheControl(Cacheable cacheable) {
    CacheControl cacheControl = new CacheControl();
    cacheControl.setMaxAge(cacheable.maxAge());
    cacheControl.setMustRevalidate(cacheable.mustRevalidate());
    cacheControl.setNoCache(cacheable.noCache());
    cacheControl.setNoStore(cacheable.noStore());
    cacheControl.setNoTransform(cacheable.noTransform());
    cacheControl.setPrivate(cacheable.privateFlag());
    cacheControl.setProxyRevalidate(cacheable.proxyRevalidate());
    cacheControl.setSMaxAge(cacheable.sMaxAge());
    cacheControl.getNoCacheFields().addAll(Arrays.asList(cacheable.noCacheFields()));
    cacheControl.getPrivateFields().addAll(Arrays.asList(cacheable.privateFields()));
    return cacheControl;
}
 
开发者ID:Microbule,项目名称:microbule,代码行数:15,代码来源:ContainerCacheFilter.java

示例11: home

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Produces(MediaType.TEXT_HTML)
public Response home(){
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    cc.setPrivate(true);

    ResponseBuilder builder = Response.ok(
        getClass().getResourceAsStream("/static/index.html"));
    builder.cacheControl(cc);

    return builder.build();
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:14,代码来源:DefaultWeb.java

示例12: css

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("/css")
@Produces("text/css")
public Response css() {
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    cc.setPrivate(true);

    ResponseBuilder builder = Response.ok(
        getClass().getResourceAsStream("/static/style.css"));
    builder.cacheControl(cc);

    return builder.build();
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:15,代码来源:DefaultWeb.java

示例13: github

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("/github")
@Produces("text/css")
public Response github() {
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    cc.setPrivate(true);

    ResponseBuilder builder = Response.ok(
        getClass().getResourceAsStream("/static/highlight/styles/github.css"));
    builder.cacheControl(cc);

    return builder.build();
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:15,代码来源:DefaultWeb.java

示例14: highlight

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("/highlight")
@Produces("text/javascript")
public Response highlight() {
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    cc.setPrivate(true);

    ResponseBuilder builder = Response.ok(
        getClass().getResourceAsStream("/static/highlight/highlight.pack.js"));
    builder.cacheControl(cc);

    return builder.build();
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:15,代码来源:DefaultWeb.java

示例15: logo

import javax.ws.rs.core.CacheControl; //导入方法依赖的package包/类
@GET
@Path("/logo")
@Produces("image/gif")
public Response logo() {
    CacheControl cc = new CacheControl();
    cc.setMaxAge(86400);
    cc.setPrivate(true);

    ResponseBuilder builder = Response.ok(
        getClass().getResourceAsStream("/static/Arieslogo_Horizontal.gif"));
    builder.cacheControl(cc);

    return builder.build();
}
 
开发者ID:apache,项目名称:aries-jax-rs-whiteboard,代码行数:15,代码来源:DefaultWeb.java


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