當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。