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


Java WebAppContext.setCopyWebDir方法代码示例

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


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

示例1: start

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() {
	Thread t = new Thread() {
		public void run() {

			Server server = new Server(Integer.valueOf(jettyServerProperties.getProperty(Constants.PORT)));
			WebAppContext context = new WebAppContext();
			context.setDescriptor("src/main/webapp/WEB-INF/web.xml");
			context.setResourceBase("src/main/webapp/WEB-INF/views");
			context.setExtractWAR(true);
			context.setCopyWebInf(true);
			context.setCopyWebDir(true);
							
			context.setContextPath("/");
			context.setParentLoaderPriority(true);
			server.setHandler(context);
			
			try {
				server.start();
				server.join();

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	};
	t.start();
}
 
开发者ID:raghavendar-ts,项目名称:ElasticTab-Elasticsearch-to-Excel-Report,代码行数:28,代码来源:JettyServerEmbedded.java

示例2: createWebApp

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private static WebAppContext createWebApp(String contextPah)
        throws Exception
{
    WebAppContext webApp = new WebAppContext();
    webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    webApp.setContextPath(contextPah);
    webApp.setCopyWebDir(true);
    webApp.setPersistTempDirectory(false);
    webApp.setTempDirectory(WORK_DIR);
    webApp.setWar(WAR_FILENAME);
    return webApp;
}
 
开发者ID:Sel8616,项目名称:Wetty,代码行数:13,代码来源:Main.java

示例3: run

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server run(ResourceConfig application, Properties properties, int port, String originFilter,
                         String aliasName, File keystoreFile, String password, String frontendRoot, String apiPathPattern, boolean copyWebDir) {
    try {
        QueuedThreadPool threadPool = new QueuedThreadPool(
                Integer.valueOf(properties.getProperty("jetty.maxThreads")),
                Integer.valueOf(properties.getProperty("jetty.minThreads")),
                Integer.valueOf(properties.getProperty("jetty.idleTimeout")),
                new ArrayBlockingQueue<>(Integer.valueOf(properties.getProperty("jetty.maxQueueSize"))));
        Server server = new Server(threadPool);
        HttpConfiguration config = new HttpConfiguration();

        if (keystoreFile != null) {
            log.info("Jetty runner {}. SSL enabled.", application.getClass());
            SslContextFactory sslFactory = new SslContextFactory();
            sslFactory.setCertAlias(aliasName);

            String path = keystoreFile.getAbsolutePath();
            if (!keystoreFile.exists()) {
                log.error("Couldn't load keystore file: {}", path);
                return null;
            }
            sslFactory.setKeyStorePath(path);
            sslFactory.setKeyStorePassword(password);
            sslFactory.setKeyManagerPassword(password);
            sslFactory.setTrustStorePath(path);
            sslFactory.setTrustStorePassword(password);

            config.setSecureScheme("https");
            config.setSecurePort(port);
            config.addCustomizer(new SecureRequestCustomizer());

            ServerConnector https = new ServerConnector(server,
                    new SslConnectionFactory(sslFactory, "http/1.1"),
                    new HttpConnectionFactory(config));
            https.setPort(port);
            server.setConnectors(new Connector[]{https});
        } else {
            ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(config));
            http.setPort(port);
            server.setConnectors(new Connector[]{http});
        }

        Handler handler = ContainerFactory.createContainer(JettyHttpContainer.class, application);
        if (originFilter != null)
            handler = new CrossDomainFilter(handler, originFilter);
        if (frontendRoot != null) {
            WebAppContext htmlHandler = new WebAppContext();
            htmlHandler.setResourceBase(frontendRoot);
            htmlHandler.setCopyWebDir(copyWebDir);
            Map<Pattern, Handler> pathToHandler = new HashMap<>();
            pathToHandler.put(Pattern.compile(apiPathPattern), handler);

            SessionManager sm = new HashSessionManager();
            SessionHandler sh = new SessionHandler(sm);
            htmlHandler.setSessionHandler(sh);

            DefaultServlet defaultServlet = new DefaultServlet();
            ServletHolder holder = new ServletHolder(defaultServlet);
            holder.setInitParameter("useFileMappedBuffer", Boolean.toString(!copyWebDir));
            holder.setInitParameter("cacheControl", "no-store,no-cache,must-revalidate,max-age=-1,public");
            htmlHandler.addServlet(holder, "/");
            
            handler = new RequestsRouter(htmlHandler, pathToHandler, frontendRoot);
        }
        server.setHandler(handler);
        server.start();

        while (!server.isStarted()) {
            Thread.sleep(50);
        }
        log.info("Jetty server started {} on port {}", application.getClass(), port);
        return server;
    } catch (Exception e) {
        log.error(String.format("Jetty start failed %s.", application.getClass()), e);
        return null;
    }
}
 
开发者ID:dsx-tech,项目名称:e-voting,代码行数:78,代码来源:JettyRunner.java


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