当前位置: 首页>>代码示例>>Java>>正文


Java WebAppContext.setServer方法代码示例

本文整理汇总了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));
}
 
开发者ID:opentracing-contrib,项目名称:java-spring-web,代码行数:17,代码来源:MVCJettyITest.java

示例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();
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:17,代码来源:RwServer.java

示例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;

    }
 
开发者ID:quqiangsheng,项目名称:abhot,代码行数:22,代码来源:Launcher.java

示例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);
        }
    }
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:37,代码来源:EmbeddedJettyServer.java

示例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();
}
 
开发者ID:dbiir,项目名称:paraflow,代码行数:16,代码来源:DataServer.java

示例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();
}
 
开发者ID:NEStock,项目名称:Voice_Activated_EV3_Robot,代码行数:31,代码来源:Runner.java

示例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);
  }
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:34,代码来源:DoctorKafkaWebServer.java

示例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();
}
 
开发者ID:XiaoMi,项目名称:linden,代码行数:15,代码来源:LindenAdmin.java

示例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);
	}
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:38,代码来源:StartEapWebInterface.java

示例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;
}
 
开发者ID:korena,项目名称:service-base,代码行数:23,代码来源:JServer.java

示例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);
    }
}
 
开发者ID:sparsick,项目名称:ansible-docker-talk,代码行数:65,代码来源:Start.java

示例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);
	}
}
 
开发者ID:pingunaut,项目名称:wicket-stream-download-example,代码行数:80,代码来源:Start.java

示例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);
      }
  }
 
开发者ID:OrienteerBAP,项目名称:wicket-bpmn-io,代码行数:42,代码来源:Start.java

示例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);
    }
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:65,代码来源:Start.java


注:本文中的org.eclipse.jetty.webapp.WebAppContext.setServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。