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