本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.<init>()
方法的一些代码示例,展示了WebAppContext.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.<init>()
方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:<init>
暂无
代码示例来源:origin: stackoverflow.com
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class JettyServer {
public static void main(String[] args) {
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setResourceBase("../webapp-project/WebContent");
context.setDescriptor("../webapp-project/WebContent/WEB-INF/web.xml");
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: apache/hive
/**
* Create the web context for the application of specified name
*/
WebAppContext createWebAppContext(Builder b) {
WebAppContext ctx = new WebAppContext();
setContextAttributes(ctx.getServletContext(), b.contextAttrs);
ctx.setDisplayName(b.name);
ctx.setContextPath("/");
ctx.setWar(appDir + "/" + b.name);
return ctx;
}
代码示例来源:origin: apache/hbase
masterJettyServer = new Server();
final ServerConnector connector = new ServerConnector(masterJettyServer);
connector.setHost(addr);
final WebAppContext context = new WebAppContext(null, "/", null, null, null, null, WebAppContext.NO_SESSIONS);
context.addServlet(new ServletHolder(redirect), "/*");
context.setServer(masterJettyServer);
masterJettyServer.start();
} catch (Exception e) {
throw new IOException("Failed to start redirecting jetty server", e);
代码示例来源:origin: stackoverflow.com
public class Jetty {
public static Server createServer(int port) {
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setResourceBase("src/main/webapp");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{context});
server.setHandler(handlers);
return server;
}
}
代码示例来源:origin: loklak/loklak_server
WebAppContext htrootContext = new WebAppContext();
htrootContext.setContextPath("/");
ipaccess.setHandler(securityHandler);
LoklakServer.server.setHandler(ipaccess);
代码示例来源:origin: stackoverflow.com
...
WebAppContext webapp = new WebAppContext();
// classURLs may contains URL to WEB-INF/classes or WEB-INF/lib/additional_jar of you web app
URLClassLoader classLoader = new URLClassLoader(classURLs.toArray(new URL[classURLs.size()]),
Thread.currentThread().getContextClassLoader());
webapp.setClassLoader(classLoader);
...
ContextHandlerCollection contextCollection = new ContextHandlerCollection();
contextCollection.addHandler(webapp);
...
Server server = new Server(threadPool);
server.setHandler(contextCollection);
server.start();
...
代码示例来源:origin: stackoverflow.com
Server server = new Server(8080);
Configuration.ClassList classlist = Configuration.ClassList
.setServerDefault(server);
classlist.addAfter("org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.plus.webapp.EnvConfiguration",
"org.eclipse.jetty.plus.webapp.PlusConfiguration");
classlist.addBefore(
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.annotations.AnnotationConfiguration");
WebAppContext context = new WebAppContext();
context.setContextPath("/");
// ... etc ...
代码示例来源:origin: opensourceBIM/BIMserver
public EmbeddedWebServer(BimServer bimServer, String resourceBase, boolean localDev) {
server = new Server(new QueuedThreadPool(200, 20));
socketConnector.setStopTimeout(10800000); // 3 hours for bulkcheckin
server.addConnector(socketConnector);
context = new WebAppContext(server, "", "/");
context.setTempDirectory(bimServer.getHomeDir().resolve("jettytmp").toFile());
代码示例来源:origin: apache/geode
WebAppContext webapp = new WebAppContext();
webapp.setContextPath(webAppContext);
webapp.setWar(warFilePath);
webapp.setParentLoaderPriority(false);
logger.info("Attempting to start HTTP service on port ({}) at bind-address ({})...",
this.port, this.bindAddress);
httpServer.start();
} else {
webapp.start();
代码示例来源:origin: ocpsoft/prettytime
public static void main(String[] args) throws Exception {
String weppAppHome = args[0];
Integer port = 8080;
Server server = new Server(port);
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/");
webapp.setCompactPath(true);
webapp.setDescriptor(weppAppHome + "/WEB-INF/web.xml");
webapp.setResourceBase(weppAppHome);
webapp.setParentLoaderPriority(true);
server.setHandler(webapp);
server.start();
server.join();
}
代码示例来源:origin: com.github.dapeng-soa/dapeng-api-doc
public static Server createServer(int port) throws MalformedURLException, URISyntaxException {
Server server = new Server();
server.setStopAtShutdown(true);
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
connector.setReuseAddress(true);
server.setConnectors(new Connector[]{connector});
WebAppContext webContext = new WebAppContext("webapp", CONTEXT);
webContext.setBaseResource(Resource.newResource(new URL(ApiWebSite.class.getResource("/webapp/WEB-INF"), ".")));
webContext.setClassLoader(ApiWebSite.class.getClassLoader());
server.setHandler(webContext);
return server;
}
代码示例来源:origin: stackoverflow.com
Server server = new Server(0);
WebAppContext webAppContext = new WebAppContext("src/main/webapp", "/");
server.addHandler(webAppContext);
server.start();
webServerPort = server.getConnectors()[0].getLocalPort();
代码示例来源:origin: apache/shiro
final String classpath = configuration.getClasspath();
WebAppContext ctx = new WebAppContext();
ctx.setClassLoader(Thread.currentThread().getContextClassLoader());
ctx.setContextPath(path);
server.setHandler(ctx);
代码示例来源:origin: stackoverflow.com
server = new Server();
SocketConnector connector = new SocketConnector();
connector.setPort(8080);
server.setConnectors(new Connector[] { connector });
WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/your-context");
context.setWar("path to war");
server.addHandler(context);
Thread monitor = new MonitorThread();
monitor.start();
server.start();
server.join();
代码示例来源:origin: pl.edu.icm.synat/synat-platform-integration-tests
public JettyEmbeddedServer() {
server = new Server();
server.setStopAtShutdown(true);
connector = new ServerConnector(server);
context = new WebAppContext();
}
代码示例来源:origin: apache/nifi
private WebAppContext loadWar(final File warFile, final String contextPath, final ClassLoader parentClassLoader) {
final WebAppContext webappContext = new WebAppContext(warFile.getPath(), contextPath);
webappContext.setContextPath(contextPath);
webappContext.setDisplayName(contextPath);
代码示例来源:origin: stackoverflow.com
Server server = new Server( port );
WebAppContext root = new WebAppContext();
root.setWar("/path/to/somewhere");
root.setContextPath("/");
server.addHandler( root );
server.start();
代码示例来源:origin: kaaproject/kaa
@Override
public void start() {
LOG.info("Starting Kaa Admin Web Server...");
server = new Server(adminPort);
webAppContext = new WebAppContext();
webAppContext.setEventListeners(new EventListener[]{adminContextLoaderListener});
webAppContext.setContextPath("/");
String webXmlLocation = AdminInitializationService.class.getResource("/admin-web/WEB-INF/"
+ webXmlFile).toString();
webAppContext.setDescriptor(webXmlLocation);
String resLocation = AdminInitializationService.class.getResource("/admin-web").toString();
webAppContext.setResourceBase(resLocation);
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
try {
server.start();
LOG.info("Kaa Admin Web Server started.");
} catch (Exception ex) {
LOG.error("Error starting Kaa Admin Web Server!", ex);
}
}
代码示例来源:origin: dapeng-soa/dapeng-soa
public static Server createServer(int port) throws MalformedURLException, URISyntaxException {
Server server = new Server();
server.setStopAtShutdown(true);
ServerConnector connector = new ServerConnector(server);
connector.setPort(port);
connector.setReuseAddress(true);
server.setConnectors(new Connector[]{connector});
WebAppContext webContext = new WebAppContext("webapp", CONTEXT);
webContext.setBaseResource(Resource.newResource(new URL(ApiWebSite.class.getResource("/webapp/WEB-INF"), ".")));
webContext.setClassLoader(ApiWebSite.class.getClassLoader());
server.setHandler(webContext);
return server;
}
代码示例来源:origin: stackoverflow.com
Server server = new Server(8080);
server.setStopAtShutdown(true);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/app");
webAppContext.setResourceBase("src/main/webapp");
webAppContext.setClassLoader(getClass().getClassLoader());
server.addHandler(webAppContext);
server.start();
URL url = new URL("http://localhost:8080/app/some_call");
URLConnection connection = url.openConnection();
List<String> lines = IOUtils.readLines(connection.getInputStream());
System.out.println(lines.get(0));
内容来源于网络,如有侵权,请联系作者删除!