本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.setServer方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setServer方法的具体用法?Java WebAppContext.setServer怎么用?Java WebAppContext.setServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setServer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beforeClass
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
jettyServer = new Server(0);
WebAppContext webApp = new WebAppContext();
webApp.setServer(jettyServer);
webApp.setContextPath(CONTEXT_PATH);
webApp.setWar("src/test/webapp");
jettyServer.setHandler(webApp);
jettyServer.start();
serverPort = ((ServerConnector)jettyServer.getConnectors()[0]).getLocalPort();
testRestTemplate = new TestRestTemplate(new RestTemplateBuilder()
.rootUri("http://localhost:" + serverPort + CONTEXT_PATH));
}
示例2: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception
{
String relativelyPath = System.getProperty("user.dir");
server = new Server(port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar(relativelyPath + "\\rainbow-web\\target\\rainbow-web.war");
webAppContext.setParentLoaderPriority(true);
webAppContext.setServer(server);
webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
webAppContext.getSessionHandler().getSessionManager()
.setMaxInactiveInterval(10);
server.setHandler(webAppContext);
server.start();
}
示例3: createJettyServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createJettyServer(int port, String contextPath) {
Server server = new Server(port);
server.setStopAtShutdown(true);
ProtectionDomain protectionDomain = Launcher.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
String warFile = location.toExternalForm();
WebAppContext context = new WebAppContext(warFile, contextPath);
context.setServer(server);
// 设置work dir,war包将解压到该目录,jsp编译后的文件也将放入其中。
String currentDir = new File(location.getPath()).getParent();
File workDir = new File(currentDir, "work");
context.setTempDirectory(workDir);
server.setHandler(context);
return server;
}
示例4: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
connector.setPort(8080);
server.setConnectors(new Connector[]{connector});
WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/");
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*taglibs.*\\.jar$");
context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);
// Prevent loading of logging classes
context.getSystemClasspathPattern().add("org.apache.log4j.");
context.getSystemClasspathPattern().add("org.slf4j.");
context.getSystemClasspathPattern().add("org.apache.commons.logging.");
ProtectionDomain protectionDomain = EmbeddedJettyServer.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
context.setWar(location.toExternalForm());
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
}
}
示例5: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception
{
server = new Server(port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar("/Users/Jelly/Developer/paraflow/paraflow-http-server/target/paraflow-server.war");
webAppContext.setParentLoaderPriority(true);
webAppContext.setServer(server);
webAppContext.setClassLoader(ClassLoader.getSystemClassLoader());
webAppContext.getSessionHandler().getSessionManager()
.setMaxInactiveInterval(10);
server.setHandler(webAppContext);
server.start();
}
示例6: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
int port = 8888;
if (args.length > 0) {
port = Integer.parseInt(args[0]);
}
if (port == 80) {
System.out.println("Dorset web demo running on http://localhost/");
} else {
System.out.println("Dorset web demo running on http://localhost:"
+ String.valueOf(port) + "/");
}
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setServer(server);
context.setContextPath("/");
// turn off class loading from WEB-INF due to logging
context.setParentLoaderPriority(true);
ProtectionDomain protectionDomain = Runner.class.getProtectionDomain();
URL location = protectionDomain.getCodeSource().getLocation();
context.setWar(location.toExternalForm());
server.setHandler(context);
server.start();
server.join();
}
示例7: run
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
@Override
public void run() {
try {
Server server = new Server(port);
URL warUrl = DoctorKafkaWebServer.class.getClassLoader().getResource(WEBAPP_DIR);
if (warUrl == null) {
LOG.error("warUrl is null");
}
String warUrlString = warUrl.toExternalForm();
WebAppContext webapp = new WebAppContext();
webapp.addServlet(ClusterInfoServlet.class, "/servlet/clusterinfo");
webapp.addServlet(KafkaTopicStatsServlet.class, "/servlet/topicstats");
webapp.addServlet(DoctorKafkaActionsServlet.class, "/servlet/actions");
webapp.addServlet(DoctorKafkaInfoServlet.class, "/servlet/info");
webapp.addServlet(DoctorKafkaBrokerStatsServlet.class, "/servlet/brokerstats");
webapp.addServlet(UnderReplicatedPartitionsServlet.class, "/servlet/urp");
webapp.addServlet(OperatorIndexServlet.class, "/");
webapp.setContextPath("/");
webapp.setServer(server);
webapp.setWar(warUrlString);
server.setHandler(webapp);
server.start();
if (LOG.isDebugEnabled()) {
server.dumpStdErr();
}
server.join();
} catch (Exception e) {
LOG.error("Exception in KafkaOperatorWebServer.", e);
}
}
示例8: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() throws Exception {
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setWar(webappPath);
webAppContext.setServer(server);
server.setHandler(webAppContext);
String host = CommonUtils.getLocalHostIp();
System.out.printf("Linden admin started: http://%s:%d\n", host, port);
LOGGER.info("Linden admin started: http://{}:{}", host, port);
server.start();
server.join();
}
示例9: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(final String[] args) throws Exception {
final int timeout = (int) Duration.ONE_HOUR.getMilliseconds();
final Server server = new Server();
final SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(timeout);
connector.setSoLingerTime(-1);
connector.setPort(8081);
server.addConnector(connector);
final WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
try {
// System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
// System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (final Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例10: 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;
}
示例11: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
int timeout = (int) Duration.ONE_HOUR.getMilliseconds();
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(timeout);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.addConnector(connector);
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
// if a keystore for a SSL certificate is available, start a SSL
// connector on port 8443.
// By default, the quickstart comes with a Apache Wicket Quickstart
// Certificate that expires about half way september 2021. Do not
// use this certificate anywhere important as the passwords are
// available in the source.
connector.setConfidentialPort(8443);
SslContextFactory factory = new SslContextFactory();
factory.setKeyStoreResource(keystore);
factory.setKeyStorePassword("wicket");
factory.setTrustStoreResource(keystore);
factory.setKeyManagerPassword("wicket");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(timeout);
sslConnector.setPort(8443);
sslConnector.setAcceptors(4);
server.addConnector(sslConnector);
System.out.println("SSL access to the quickstart has been enabled on port 8443");
System.out.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例12: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Main function, starts the jetty server.
*
* @param args
*/
public static void main(String[] args)
{
System.setProperty("wicket.configuration", "development");
Server server = new Server();
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme("https");
http_config.setSecurePort(8443);
http_config.setOutputBufferSize(32768);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
http.setPort(8080);
http.setIdleTimeout(1000 * 60 * 60);
server.addConnector(http);
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists())
{
// if a keystore for a SSL certificate is available, start a SSL
// connector on port 8443.
// By default, the quickstart comes with a Apache Wicket Quickstart
// Certificate that expires about half way september 2021. Do not
// use this certificate anywhere important as the passwords are
// available in the source.
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStoreResource(keystore);
sslContextFactory.setKeyStorePassword("wicket");
sslContextFactory.setKeyManagerPassword("wicket");
HttpConfiguration https_config = new HttpConfiguration(http_config);
https_config.addCustomizer(new SecureRequestCustomizer());
ServerConnector https = new ServerConnector(server, new SslConnectionFactory(
sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config));
https.setPort(8443);
https.setIdleTimeout(500000);
server.addConnector(https);
System.out.println("SSL access to the examples has been enabled on port 8443");
System.out
.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// uncomment next line if you want to test with JSESSIONID encoded in the urls
// ((AbstractSessionManager)
// bb.getSessionHandler().getSessionManager()).setUsingCookies(false);
server.setHandler(bb);
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
server.addEventListener(mBeanContainer);
server.addBean(mBeanContainer);
try
{
server.start();
server.join();
}
catch (Exception e)
{
e.printStackTrace();
System.exit(100);
}
}
示例13: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
int timeout = (int) Duration.ONE_HOUR.getMilliseconds();
Server server = new Server();
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443);
httpConfig.setOutputBufferSize(32768);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
http.setPort(8081);
http.setIdleTimeout(timeout);
server.addConnector(http);
Resource.setDefaultUseCaches(false);
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例14: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
int timeout = (int) Duration.ONE_HOUR.getMilliseconds();
Server server = new Server();
SocketConnector connector = new SocketConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(timeout);
connector.setSoLingerTime(-1);
connector.setPort(8090);
server.addConnector(connector);
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
// if a keystore for a SSL certificate is available, start a SSL
// connector on port 8443.
// By default, the quickstart comes with a Apache Wicket Quickstart
// Certificate that expires about half way september 2021. Do not
// use this certificate anywhere important as the passwords are
// available in the source.
connector.setConfidentialPort(8443);
SslContextFactory factory = new SslContextFactory();
factory.setKeyStoreResource(keystore);
factory.setKeyStorePassword("wicket");
factory.setTrustStoreResource(keystore);
factory.setKeyManagerPassword("wicket");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(timeout);
sslConnector.setPort(8443);
sslConnector.setAcceptors(4);
server.addConnector(sslConnector);
System.out.println("SSL access to the quickstart has been enabled on port 8443");
System.out.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
WebAppContext bb = new WebAppContext();
bb.setServer(server);
bb.setContextPath("/");
bb.setWar("src/main/webapp");
// START JMX SERVER
// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
// server.getContainer().addEventListener(mBeanContainer);
// mBeanContainer.start();
server.setHandler(bb);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}