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


Java ResourceHandler.setEtags方法代码示例

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


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

示例1: addResources

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public void addResources(String contextPath, String resourcePath, String welcomesCsv) {
	int opt = ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS;
	ServletContextHandler context = new ServletContextHandler(opt);
	{
		context.setContextPath(contextPath);
		context.setCompactPath(true);
		context.setAllowNullPathInfo(true);

		if (Resources.exists(resourcePath)) {
			URL url = Resources.getURL(resourcePath);
			context.setResourceBase(url.toExternalForm());
		}
		ResourceHandler h = new ResourceHandler();
		h.setMinMemoryMappedContentLength(-1);
		h.setEtags(true);
		context.setHandler(h);
		context.setWelcomeFiles(Iterables.toArray(Splitters.notEmpties(",").split(welcomesCsv), String.class));
	}
	this.handlers.addHandler(context);
}
 
开发者ID:dohbot,项目名称:knives,代码行数:21,代码来源:EmbeddedJetty.java

示例2: addStaticResources

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public void addStaticResources(String basePath, String resourcePath) {
    ContextHandler capHandler = new ContextHandler();
    capHandler.setContextPath(basePath);
    ResourceHandler resHandler = new ResourceHandler();
    resHandler.setBaseResource(Resource.newClassPathResource(resourcePath));
    resHandler.setEtags(true);
    resHandler.setCacheControl(WebService.HANDLER_CACHE_CONTROL);
    capHandler.setHandler(resHandler);
    handlers.add(capHandler);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:11,代码来源:WebService.java

示例3: getResourceHandler

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
public ResourceHandler getResourceHandler() {
    ResourceHandler handler = new ResourceHandler();

    String resourceBase = null;
    org.eclipse.jetty.util.resource.Resource baseResource = null;

    for (String path : resourcePaths) {
        File dir = new File(rootDir, path);
        // seriously?
        if (dir.isDirectory() && dir.list().length > 0) {
            resourceBase = dir.getAbsolutePath();
            break;
        }
    }

    if (resourceBase == null) {
        for (String classpathResource : classpathResources) {
            baseResource = org.eclipse.jetty.util.resource.Resource.newClassPathResource(classpathResource);
            // this sucks
            if (baseResource != null && baseResource.exists()) {
                break;
            }
        }
    }

    if (resourceBase == null && baseResource == null) {
        throw new IllegalStateException("Could not find resourceBase or baseResource for context " + this.context);
    }

    // the things I do for backwards compatibility
    if (resourceBase != null) {
        log.info("Assigning " + resourceBase + " to context " + this.context);
        handler.setResourceBase(resourceBase);
    } else { // baseResource != null
        log.info("Assigning " + baseResource.getName() + " to context " + this.context);
        handler.setBaseResource(baseResource);
    }
    handler.setWelcomeFiles(welcomeFiles.toArray(new String[welcomeFiles.size()]));
    handler.setDirectoriesListed(allowDirectoryListing);
    handler.setCacheControl("max-age=21600"); //6hrs
    handler.setEtags(true);

    return handler;
}
 
开发者ID:jivesoftware,项目名称:routing-bird,代码行数:45,代码来源:Resource.java

示例4: __invoke

import org.eclipse.jetty.server.handler.ResourceHandler; //导入方法依赖的package包/类
@Signature
public void __invoke(PHttpServerRequest request, PHttpServerResponse response) throws Exception {
    final boolean[] once = {false};

    ResourceHandler resourceHandler = new ResourceHandler() {
        @Override
        public Resource getResource(String path) {
            if (!once[0]) {
                once[0] = true;
                Object attr = request.getRequest().getAttribute("**");
                File file;

                if (attr != null) {
                    file = new File(PHttpResourceHandler.this.file, "/" + attr);
                } else {
                    file = new File(PHttpResourceHandler.this.file);
                }

                if (file.exists()) {
                    return new PathResource(file.getAbsoluteFile());
                } else {
                    return null;
                }
            } else {
                return null;
            }
        }
    };

    resourceHandler.doStart();

    resourceHandler.setResourceBase(file());

    if (cacheControl() != null) {
        resourceHandler.setCacheControl(cacheControl());
    }

    resourceHandler.setRedirectWelcome(redirectWelcome());
    resourceHandler.setPathInfoOnly(pathInfoOnly());
    resourceHandler.setDirectoriesListed(directoriesListed());
    resourceHandler.setDirAllowed(dirAllowed());
    resourceHandler.setAcceptRanges(acceptRanges());
    resourceHandler.setEtags(etags());

    Request baseRequest = Request.getBaseRequest(request.getRequest());

    resourceHandler.handle(
            request.getRequest().getRequestURI(), baseRequest, request.getRequest(), response.getResponse()
    );
}
 
开发者ID:jphp-compiler,项目名称:jphp,代码行数:51,代码来源:PHttpResourceHandler.java


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