當前位置: 首頁>>代碼示例>>Java>>正文


Java WebAppContext.setDefaultsDescriptor方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.webapp.WebAppContext.setDefaultsDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java WebAppContext.setDefaultsDescriptor方法的具體用法?Java WebAppContext.setDefaultsDescriptor怎麽用?Java WebAppContext.setDefaultsDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.webapp.WebAppContext的用法示例。


在下文中一共展示了WebAppContext.setDefaultsDescriptor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createServerInSource

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
/**
 * 創建用於開發運行調試的Jetty Server, 以src/main/webapp為Web應用目錄.
 */
public static Server createServerInSource(int port, String contextPath) {
	Server server = new Server();
	// 設置在JVM退出時關閉Jetty的鉤子。
	server.setStopAtShutdown(true);

	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(port);
	// 解決Windows下重複啟動Jetty居然不報告端口衝突的問題.
	connector.setReuseAddress(false);
	server.setConnectors(new Connector[] { connector });

	WebAppContext webContext = new WebAppContext(DEFAULT_WEBAPP_PATH, contextPath);
	// 修改webdefault.xml,解決Windows下Jetty Lock住靜態文件的問題.
	webContext.setDefaultsDescriptor(WINDOWS_WEBDEFAULT_PATH);
	server.setHandler(webContext);

	return server;
}
 
開發者ID:pengqiuyuan,項目名稱:g2,代碼行數:22,代碼來源:JettyFactory.java

示例2: loadWar

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private WebAppContext loadWar(final File warFile, final String contextPath) throws IOException {
    final WebAppContext webappContext = new WebAppContext(warFile.getPath(), contextPath);
    webappContext.setContextPath(contextPath);
    webappContext.setDisplayName(contextPath);

    // remove slf4j server class to allow WAR files to have slf4j dependencies in WEB-INF/lib
    List<String> serverClasses = new ArrayList<>(Arrays.asList(webappContext.getServerClasses()));
    serverClasses.remove("org.slf4j.");
    webappContext.setServerClasses(serverClasses.toArray(new String[0]));
    webappContext.setDefaultsDescriptor(WEB_DEFAULTS_XML);

    // get the temp directory for this webapp
    final File webWorkingDirectory = properties.getWebWorkingDirectory();
    final File tempDir = new File(webWorkingDirectory, warFile.getName());
    if (tempDir.exists() && !tempDir.isDirectory()) {
        throw new RuntimeException(tempDir.getAbsolutePath() + " is not a directory");
    } else if (!tempDir.exists()) {
        final boolean made = tempDir.mkdirs();
        if (!made) {
            throw new RuntimeException(tempDir.getAbsolutePath() + " could not be created");
        }
    }
    if (!(tempDir.canRead() && tempDir.canWrite())) {
        throw new RuntimeException(tempDir.getAbsolutePath() + " directory does not have read/write privilege");
    }

    // configure the temp dir
    webappContext.setTempDirectory(tempDir);

    // configure the max form size (3x the default)
    webappContext.setMaxFormContentSize(600000);

    webappContext.setClassLoader(new WebAppClassLoader(ClassLoader.getSystemClassLoader(), webappContext));

    logger.info("Loading WAR: " + warFile.getAbsolutePath() + " with context path set to " + contextPath);
    return webappContext;
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:38,代碼來源:JettyServer.java

示例3: loadWar

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private static WebAppContext loadWar(final File warFile, final String contextPath, final ClassLoader parentClassLoader) throws IOException {
    final WebAppContext webappContext = new WebAppContext(warFile.getPath(), contextPath);
    webappContext.setContextPath(contextPath);
    webappContext.setDisplayName(contextPath);

    // instruction jetty to examine these jars for tlds, web-fragments, etc
    webappContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\\\.jar$|.*/[^/]*taglibs.*\\.jar$" );

    // remove slf4j server class to allow WAR files to have slf4j dependencies in WEB-INF/lib
    List<String> serverClasses = new ArrayList<>(Arrays.asList(webappContext.getServerClasses()));
    serverClasses.remove("org.slf4j.");
    webappContext.setServerClasses(serverClasses.toArray(new String[0]));
    webappContext.setDefaultsDescriptor(WEB_DEFAULTS_XML);

    // get the temp directory for this webapp
    File tempDir = Paths.get(C2_SERVER_HOME, "tmp", warFile.getName()).toFile();
    if (tempDir.exists() && !tempDir.isDirectory()) {
        throw new RuntimeException(tempDir.getAbsolutePath() + " is not a directory");
    } else if (!tempDir.exists()) {
        final boolean made = tempDir.mkdirs();
        if (!made) {
            throw new RuntimeException(tempDir.getAbsolutePath() + " could not be created");
        }
    }
    if (!(tempDir.canRead() && tempDir.canWrite())) {
        throw new RuntimeException(tempDir.getAbsolutePath() + " directory does not have read/write privilege");
    }

    // configure the temp dir
    webappContext.setTempDirectory(tempDir);

    // configure the max form size (3x the default)
    webappContext.setMaxFormContentSize(600000);

    webappContext.setClassLoader(new WebAppClassLoader(parentClassLoader, webappContext));

    logger.info("Loading WAR: " + warFile.getAbsolutePath() + " with context path set to " + contextPath);
    return webappContext;
}
 
開發者ID:apache,項目名稱:nifi-minifi,代碼行數:40,代碼來源:JettyServer.java

示例4: buildContext

import org.eclipse.jetty.webapp.WebAppContext; //導入方法依賴的package包/類
private WebAppContext buildContext() {
    WebAppContext context = new WebAppContext();
    context.setDefaultsDescriptor("webapp/WEB-INF/webdefault.xml");
    context.setDescriptor("webapp/WEB-INF/web.xml");
    context.setResourceBase("webapp/");
    context.setContextPath("/");
    return context;
}
 
開發者ID:xsank,項目名稱:Shour,代碼行數:9,代碼來源:QAServer.java


注:本文中的org.eclipse.jetty.webapp.WebAppContext.setDefaultsDescriptor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。