本文整理匯總了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();
}
}