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


Java WebAppContext.setResourceBase方法代码示例

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


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

示例1: start

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception {
    Resource configXml = Resource.newSystemResource(config);
    XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
    server = (Server) configuration.configure();

    //        Integer port = getPort();
    //        if (port != null && port > 0) {
    //            Connector[] connectors = server.getConnectors();
    //            for (Connector connector : connectors) {
    //                connector.setPort(port);
    //            }
    //        }
    Handler handler = server.getHandler();
    if (handler != null && handler instanceof WebAppContext) {
        WebAppContext webAppContext = (WebAppContext) handler;
        webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
    }
    server.start();
    if (logger.isInfoEnabled()) {
        logger.info("##Jetty Embed Server is startup!");
    }
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:23,代码来源:JettyEmbedServer.java

示例2: 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

示例3: setupWebAppContext

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private static WebAppContext setupWebAppContext(
    ZeppelinConfiguration conf) {

  WebAppContext webApp = new WebAppContext();
  webApp.setContextPath(conf.getServerContextPath());
  File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
  if (warPath.isDirectory()) {
    // Development mode, read from FS
    // webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
    webApp.setResourceBase(warPath.getPath());
    webApp.setParentLoaderPriority(true);
  } else {
    // use packaged WAR
    webApp.setWar(warPath.getAbsolutePath());
    File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
    warTempDirectory.mkdir();
    LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
    webApp.setTempDirectory(warTempDirectory);
  }
  // Explicit bind to root
  webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
  return webApp;
}
 
开发者ID:lorthos,项目名称:incubator-zeppelin-druid,代码行数:24,代码来源:ZeppelinServer.java

示例4: initWebApp

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private WebAppContext initWebApp() throws IOException {
    WebAppContext ctx = new WebAppContext();
    ctx.setContextPath(CONFIG.getContextPath());
    ctx.setResourceBase(new ClassPathResource("webapp").getURI().toString());

    // Disable directory listings if no index.html is found.
    ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");

    ServletHolder web = new ServletHolder("spring-dispatcher", new DispatcherServlet(springContext));
    ServletHolder cxf = new ServletHolder("cxf", new CXFServlet());

    ctx.addEventListener(new ContextLoaderListener(springContext));
    ctx.addServlet(web, CONFIG.getSpringMapping());
    ctx.addServlet(cxf, CONFIG.getCxfMapping());

    if (CONFIG.getProfile().isProd()) {
        addSecurityFilter(ctx);
    }

    initJSP(ctx);
    return ctx;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:23,代码来源:SteveAppContext.java

示例5: run

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void run( ) {
	logger.info(masterConfig.toString());
	try {
		Server server = new Server(masterConfig.getWebServerPort());

		WebAppContext context = new WebAppContext();
		context.setDescriptor( masterConfig.getWebServerContentPath() + "/WEB-INF/web.xml" );
		context.setResourceBase( masterConfig.getWebServerContentPath() );
		context.setContextPath( masterConfig.getWebServerContextPath() );
		context.setParentLoaderPriority(true);
		server.setHandler(context);
		logger.info("Starting");
		server.start();
		logger.info("Started");
		server.join();
	} catch( Exception e ) {
		logger.error(e.getMessage(), e);
	}
}
 
开发者ID:petezybrick,项目名称:iote2e,代码行数:20,代码来源:ThreadEntryPointWeb.java

示例6: 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

示例7: 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

示例8: createServer

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createServer(int port) {
	
	WebAppContext context = new WebAppContext();
	context.setContextPath("/");
	context.setResourceBase(WEBAPP);
	context.setConfigurations(new Configuration[] { new JettyAnnotationConfiguration() });
	
	// Create server and configure it
	final Server server = new Server(port);
	server.setHandler(context);

	return server;
}
 
开发者ID:activeviam,项目名称:autopivot,代码行数:14,代码来源:AutoPivotLauncher.java

示例9: 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

示例10: 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

示例11: 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/");
	webAppContext.setParentLoaderPriority(true);

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

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

}
 
开发者ID:daimor,项目名称:isc-hapi-fhir-jpaserver,代码行数:32,代码来源:ExampleServerIT.java

示例12: 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,代码来源:UserSigninTest.java

示例13: start

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception {
    server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);

    WebAppContext context = new WebAppContext();
    context.setContextPath(contextPath);
    context.setResourceBase(webapp);
    context.setConfigurationDiscovered(true);

    server.setHandler(context);
    server.start();
}
 
开发者ID:blusechen,项目名称:venus,代码行数:16,代码来源:VenusJettyServer.java

示例14: 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,代码来源:SignupTest.java

示例15: start

import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@Override
    public void start() throws Exception{
        try {
            // 服务器的监听端口
            server = new Server(port);

            // 关联一个已经存在的上下文
            WebAppContext context = new WebAppContext();

            // 设置描述符位置
            context.setDescriptor(descriptor);

            // 设置Web内容上下文路径
            context.setResourceBase(resourceBase);

            // 设置上下文路径
            context.setContextPath(contextPath);
            context.setParentLoaderPriority(true);

            server.setHandler(context);

            // 启动
            server.start();

            System.out.println("gm模块启动,使用url:http://localhost:"+port+contextPath+" 进行访问");

//            server.join();

        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
 
开发者ID:xuerong,项目名称:MMServerEngine,代码行数:33,代码来源:GmEntranceJetty.java


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