本文整理汇总了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!");
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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));
}
示例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();
}
示例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));
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}