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


Java WebAppContext.setDescriptor方法代码示例

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


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

示例1: createDevServer

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createDevServer(int port, String contextPath) {

        Server server = new Server();
        server.setStopAtShutdown(true);

        ServerConnector connector = new ServerConnector(server);
        // 设置服务端口
        connector.setPort(port);
        connector.setReuseAddress(false);
        server.setConnectors(new Connector[] {connector});

        // 设置web资源根路径以及访问web的根路径
        WebAppContext webAppCtx = new WebAppContext(DEFAULT_APP_CONTEXT_PATH, contextPath);
        webAppCtx.setDescriptor(DEFAULT_APP_CONTEXT_PATH + "/WEB-INF/web.xml");
        webAppCtx.setResourceBase(DEFAULT_APP_CONTEXT_PATH);
        webAppCtx.setClassLoader(Thread.currentThread().getContextClassLoader());
        server.setHandler(webAppCtx);

        return server;
    }
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:21,代码来源:Launcher.java

示例2: buildJetty

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void buildJetty(int port, String sourceDir, String webXmlFile) throws Exception {
    server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);
    WebAppContext context = new WebAppContext();
    context.setResourceBase(sourceDir);
    context.setDescriptor(sourceDir + "/WEB-INF/" + webXmlFile);
    context.setLogUrlOnStart(true);
    context.setContextPath("/");
    context.setParentLoaderPriority(true);

    server.setHandler(context);

    server.start();
}
 
开发者ID:hazelcast,项目名称:hazelcast-wm,代码行数:18,代码来源:JettyServer.java

示例3: main

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
	Properties p = PropertyUtil.loadProperties("/ws.properties");
	System.out.println(JsonUtil.toJsonStr(p));
	Server server = new Server(Integer.parseInt(p
			.getProperty("webSocketPort")));
	try {
		HandlerList handlerList = new HandlerList();

		/* websocket */
		ServletContextHandler context = new ServletContextHandler(
				ServletContextHandler.SESSIONS);
		context.setContextPath("/");
		context.addServlet(
				new ServletHolder(new Jwservlet(p
						.getProperty("handlerClass"))), p
						.getProperty("webSocketPath"));

		/* webapp */
		WebAppContext c = new WebAppContext();
		c.setContextPath("/w");
		c.setDescriptor("../websockets/WebRoot/WEB-INF/web.xml");
		c.setResourceBase("../websockets/WebRoot");

		handlerList.addHandler(c);
		handlerList.addHandler(context);
		handlerList.addHandler(new DefaultHandler());
		server.setHandler(handlerList);
		server.start();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:Sunature,项目名称:websocket,代码行数:37,代码来源:Jetty9Ws.java

示例4: createDevServer

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createDevServer() {
	PlatformServerConfig.DEV_MODE = true;
	Path projectPath = Paths.get(System.getProperty("user.dir")).toAbsolutePath();
	Server jettyServer = new Server(8080);  
    WebAppContext context = new WebAppContext();  
    context.setContextPath("/BIMplatform");
    context.setDescriptor(projectPath.resolve("WebContent/WEB-INF/web.xml").toAbsolutePath().toString()); // 指定web.xml配置文件 
    context.setResourceBase(projectPath.resolve("WebContent/").toAbsolutePath().toString());// 指定webapp目录  
    context.setParentLoaderPriority(true); 
    jettyServer.setHandler(context);  

    return jettyServer;
}
 
开发者ID:shenan4321,项目名称:BIMplatform,代码行数:14,代码来源:PlatformServerStarter.java

示例5: beforeClass

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	/*
	 * This runs under maven, and I'm not sure how else to figure out the target directory from code..
	 */
	String path = ExampleServerIT.class.getClassLoader().getResource(".keep_hapi-fhir-jpaserver-example").getPath();
	path = new File(path).getParent();
	path = new File(path).getParent();
	path = new File(path).getParent();

	ourLog.info("Project base path is: {}", path);

	ourPort = RandomServerPortProvider.findFreePort();
	ourServer = new Server(ourPort);

	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath("/");
	webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
	webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-example");
	webAppContext.setParentLoaderPriority(true);

	ourServer.setHandler(webAppContext);
	ourServer.start();

	ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
	ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
	ourServerBase = "http://localhost:" + ourPort + "/baseDstu2";
	ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
	ourClient.registerInterceptor(new LoggingInterceptor(true));

}
 
开发者ID:gerard-bisama,项目名称:DHIS2-fhir-lab-app,代码行数:32,代码来源:ExampleServerIT.java

示例6: startServer

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
protected static void startServer(int port, String rootPath, String dbCfgPath)
		throws Exception, InterruptedException {
	Server server = new Server(port);
	WebAppContext webAppContext = new WebAppContext();
	webAppContext.setContextPath(rootPath);
	if (dbCfgPath != null) {
		Configurator cfg = null;
		try {
			cfg = ConfiguratorFactory.getInstance(APPINFO.getDbCfgFile());
		} catch (Exception e) {
			cfg = ConfiguratorFactory.getDefaultInstance();
		}
		if(cfg!=null) {ProcessLogger.debug(cfg.toString());}
		else {
			ProcessLogger.warn("Could not find db config file.");
		}
	}
	/* Important: Use getResource */
	String webxmlLocation = AppStarter.class.getResource("/webapp/WEB-INF/web.xml").toString();
	webAppContext.setDescriptor(webxmlLocation);

	/* Important: Use getResource */
	String resLocation = AppStarter.class.getResource("/webapp").toString();
	webAppContext.setResourceBase(resLocation);

	webAppContext.setParentLoaderPriority(true);

	server.setHandler(webAppContext);
	server.start();
	server.join();
}
 
开发者ID:daileyet,项目名称:helpdesk,代码行数:32,代码来源:AppStarter.java

示例7: beforeClass

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	// 创建一个server
	server = new Server(8080);
	WebAppContext context = new WebAppContext();
	String webapp = "F:/github/asm/WebContent";
	context.setDescriptor(webapp + "/WEB-INF/web.xml"); // 指定web.xml配置文件
	context.setResourceBase(webapp); // 指定webapp目录
	context.setContextPath("/");
	context.setParentLoaderPriority(true);

	server.setHandler(context);
	server.start();
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:15,代码来源:FetchSoldBtysTest.java

示例8: setupWebapp

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
 * This method is called to setup the application, it prepares the
 * application context, defines your web.xml and override-web.xml etc ...
 * This is basically what makes your application behave as if it was
 * deployed in a full fledged standard container ...
 *
 * @return WebAppContext
 */
private static WebAppContext setupWebapp() {
    ProtectionDomain domain = JServer.class.getProtectionDomain();
    URL location = domain.getCodeSource().getLocation();
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setLogUrlOnStart(true);
    webapp.setParentLoaderPriority(true);
    webapp.setWar(location.toExternalForm());
    webapp.setDescriptor("WEB-INF/web.xml");
    webapp.setOverrideDescriptor("WEB-INF/override-web.xml");
    webapp.prependServerClass("-org.eclipse.jetty.servlet.,-org.eclipse.jetty.server."); //TODO: too much exposure, check which classes are needed.
    webapp.setServer(embed_server);
    return webapp;
}
 
开发者ID:korena,项目名称:service-base,代码行数:23,代码来源:JServer.java

示例9: beforeClass

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {

    String path = Paths.get("").toAbsolutePath().toString();

    // changing from random to hard coded
    ourPort = 8080;
    ourServer = new Server(ourPort);

    WebAppContext webAppContext = new WebAppContext();
    webAppContext.setContextPath("/cqf-ruler");
    webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
    webAppContext.setResourceBase(path + "/target/cqf-ruler");
    webAppContext.setParentLoaderPriority(true);

    ourServer.setHandler(webAppContext);
    ourServer.start();

    ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
    ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
    ourServerBase = "http://localhost:" + ourPort + "/cqf-ruler/baseDstu3";
    ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
    ourClient.registerInterceptor(new LoggingInterceptor(true));

    // Load test data
    // Normally, I would use a transaction bundle, but issues with the random ports prevents that...
    // So, doing it the old-fashioned way =)

    // General
    putResource("general-practitioner.json", "Practitioner-12208");
    putResource("general-patient.json", "Patient-12214");
    putResource("general-fhirhelpers-3.json", "FHIRHelpers");
}
 
开发者ID:DBCG,项目名称:cqf-ruler,代码行数:34,代码来源:RulerTestBase.java

示例10: main

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Latkes.setScanPath("org.b3log.xiaov"); // For Latke IoC
    Latkes.initRuntimeEnv();

    final String classesPath = ClassLoader.getSystemResource("").getPath(); // Real path including maven sub folder
    String webappDirLocation = classesPath.replace("target/classes/", "src/main/webapp/"); // POM structure in dev env
    final File file = new File(webappDirLocation);
    if (!file.exists()) {
        webappDirLocation = "."; // production environment
    }

    final Server server = new Server(Integer.valueOf(Latkes.getServerPort()));
    final WebAppContext root = new WebAppContext();
    root.setParentLoaderPriority(true); // Use parent class loader
    root.setContextPath("/");
    root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
    root.setResourceBase(webappDirLocation);
    server.setHandler(root);

    try {
        server.start();
    } catch (final Exception e) {
        e.printStackTrace();

        System.exit(-1);
    }
}
 
开发者ID:b3log,项目名称:xiaov,代码行数:28,代码来源:Starter.java

示例11: beforeClass

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	// 创建一个server
	server = new Server(8080);
	WebAppContext context = new WebAppContext();
	String webapp = "D:\\sam-elle\\WebContent";
	context.setDescriptor(webapp + "/WEB-INF/web.xml"); // 指定web.xml配置文件
	context.setResourceBase(webapp); // 指定webapp目录
	context.setContextPath("/");
	context.setParentLoaderPriority(true);

	server.setHandler(context);
	server.start();
}
 
开发者ID:booleguo,项目名称:sam-elle,代码行数:15,代码来源:UserSigninTest.java

示例12: start

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start(boolean devMode, int port) throws Exception {

        Server server = new Server(new QueuedThreadPool(500));

        WebAppContext appContext = new WebAppContext();

        String resourceBasePath = "";
        //开发者模式
        if (devMode) {
            String artifact = MavenUtils.get(Thread.currentThread().getContextClassLoader()).getArtifactId();
            resourceBasePath = artifact + "/src/main/webapp";
        }
        appContext.setDescriptor(resourceBasePath + "WEB-INF/web.xml");
        appContext.setResourceBase(resourceBasePath);
        appContext.setExtractWAR(true);

        //init param
        appContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
        if (CommonUtils.isWindowOs()) {
            appContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
        }

        //for jsp support
        appContext.addBean(new JettyJspParser(appContext));
        appContext.addServlet(JettyJspServlet.class, "*.jsp");

        appContext.setContextPath("/");
        appContext.getServletContext().setExtendedListenerTypes(true);
        appContext.setParentLoaderPriority(true);
        appContext.setThrowUnavailableOnStartupException(true);
        appContext.setConfigurationDiscovered(true);
        appContext.setClassLoader(Thread.currentThread().getContextClassLoader());

        ServerConnector connector = new ServerConnector(server);
        connector.setHost("0.0.0.0");
        connector.setPort(port);
        server.setConnectors(new Connector[]{connector});
        server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1024 * 1024 * 1024);
        server.setDumpAfterStart(false);
        server.setDumpBeforeStop(false);
        server.setStopAtShutdown(true);
        server.setHandler(appContext);
        logger.info("[opencron] JettyLauncher starting...");
        server.start();
    }
 
开发者ID:wolfboys,项目名称:opencron,代码行数:46,代码来源:JettyLauncher.java


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