org.eclipse.jetty.server.Server#join ( )源码实例Demo

下面列出了org.eclipse.jetty.server.Server#join ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public static void main(String[] args) throws Exception {
    Map<String, String> arguments = parseArguments(args);
    String port = arguments.get("p");

    if (port == null || !port.matches("\\d+")) {
        port = "8081";
    }

    Server server = new Server(Integer.parseInt(port));
    server.setHandler(new MainServer());
    server.start();

    System.out.println("License Server started at http://localhost:" + port);
    System.out.println("JetBrains Activation address was: http://localhost:" + port + "/");
    System.out.println("JRebel 7.1 and earlier version Activation address was: http://localhost:" + port + "/{tokenname}, with any email.");
    System.out.println("JRebel 2018.1 and later version Activation address was: http://localhost:" + port + "/{guid}(eg:http://localhost:" + port + "/"+ UUID.randomUUID().toString()+"), with any email.");

    server.join();
}
 
源代码2 项目: amforeas   文件: AmforeasJetty.java
protected void startServer (final AmforeasConfiguration conf) throws Exception {
    final QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(conf.getServerThreadsMin());
    threadPool.setMaxThreads(conf.getServerThreadsMax());

    final Server server = new Server(threadPool);

    setupJerseyServlet(conf, server);
    setupHTTPConnection(conf, server);
    setupHTTPSConnection(conf, server);


    server.start();
    server.setStopAtShutdown(true);
    server.join();
}
 
源代码3 项目: cxf   文件: StatsServer.java
public static void main(final String[] args) throws Exception {
    final Server server = new Server(8686);

    final ServletHolder staticHolder = new ServletHolder(new DefaultServlet());
    final ServletContextHandler staticContext = new ServletContextHandler();
    staticContext.setContextPath("/static");
    staticContext.addServlet(staticHolder, "/*");
    staticContext.setResourceBase(StatsServer.class.getResource("/web-ui").toURI().toString());

     // Register and map the dispatcher servlet
    final ServletHolder cxfServletHolder = new ServletHolder(new CXFServlet());
    final ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    context.addEventListener(new ContextLoaderListener());
    context.addServlet(cxfServletHolder, "/rest/*");
    context.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    context.setInitParameter("contextConfigLocation", StatsConfig.class.getName());

    HandlerList handlers = new HandlerList();
    handlers.addHandler(staticContext);
    handlers.addHandler(context);

    server.setHandler(handlers);
    server.start();
    server.join();
}
 
源代码4 项目: openscoring   文件: Main.java
public void run() throws Exception {
	InetSocketAddress address;

	if(this.host != null){
		address = new InetSocketAddress(this.host, this.port);
	} else

	{
		address = new InetSocketAddress(this.port);
	}

	Server server = createServer(address);

	server.start();
	server.join();
}
 
源代码5 项目: monsoon   文件: PrometheusServer.java
public static void main(String[] args) throws Exception {
    final ApiServer api = new ApiServer(new InetSocketAddress(9998));

    PrometheusConfig cfg = createPrometheusConfig(args);
    final Optional<File> _cfg = cfg.getConfiguration();
    if (_cfg.isPresent())
        registry_ = new PipelineBuilder(_cfg.get()).build();
    else
        registry_ = new PipelineBuilder(Configuration.DEFAULT).build();

    api.start();
    Runtime.getRuntime().addShutdownHook(new Thread(api::close));

    Server server = new Server(cfg.getPort());
    ContextHandler context = new ContextHandler();
    context.setClassLoader(Thread.currentThread().getContextClassLoader());
    context.setContextPath(cfg.getPath());
    context.setHandler(new DisplayMetrics(registry_));
    server.setHandler(context);
    server.start();
    server.join();
}
 
源代码6 项目: vk-java-sdk   文件: Application.java
private static void initServer(Properties properties) throws Exception {
    Integer port = Integer.valueOf(properties.getProperty("server.port"));
    String host = properties.getProperty("server.host");

    Integer clientId = Integer.valueOf(properties.getProperty("client.id"));
    String clientSecret = properties.getProperty("client.secret");

    HandlerCollection handlers = new HandlerCollection();

    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setWelcomeFiles(new String[]{"index.html"});
    resourceHandler.setResourceBase(Application.class.getResource("/static").getPath());

    VkApiClient vk = new VkApiClient(new HttpTransportClient());
    handlers.setHandlers(new Handler[]{resourceHandler, new RequestHandler(vk, clientId, clientSecret, host)});

    Server server = new Server(port);
    server.setHandler(handlers);

    server.start();
    server.join();
}
 
源代码7 项目: qmq   文件: Bootstrap.java
public static void main(String[] args) throws Exception {
    final ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    context.setResourceBase(System.getProperty("java.io.tmpdir"));
    DynamicConfig config = DynamicConfigLoader.load("metaserver.properties");
    final ServerWrapper wrapper = new ServerWrapper(config);
    wrapper.start(context.getServletContext());

    context.addServlet(MetaServerAddressSupplierServlet.class, "/meta/address");
    context.addServlet(MetaManagementServlet.class, "/management");
    context.addServlet(SubjectConsumerServlet.class, "/subject/consumers");
    context.addServlet(OnOfflineServlet.class, "/onoffline");
    context.addServlet(SlaveServerAddressSupplierServlet.class, "/slave/meta");

    // TODO(keli.wang): allow set port use env
    int port = config.getInt("meta.server.discover.port", 8080);
    final Server server = new Server(port);
    server.setHandler(context);
    server.start();
    server.join();
}
 
源代码8 项目: ignite   文件: WebSessionServerStart.java
/**
 * @param args Arguments.
 * @throws Exception In case of error.
 */
public static void main(String[] args) throws Exception {
    Server srv = jettyServer(Integer.valueOf(args[0]), Boolean.valueOf(args[1]) ?
        new SessionCheckServlet() : new SessionCreateServlet());

    srv.start();
    srv.join();
}
 
源代码9 项目: heroku-maven-plugin   文件: Main.java
public static void main(String[] args) throws Exception{
  Server server = new Server(Integer.valueOf(System.getenv("PORT")));
  ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
  context.setContextPath("/");
  server.setHandler(context);
  context.addServlet(new ServletHolder(new Main()),"/*");
  server.start();
  server.join();
}
 
源代码10 项目: cloudwatch_exporter   文件: WebServer.java
public static void main(String[] args) throws Exception {
    if (args.length < 2) {
        System.err.println("Usage: WebServer <port> <yml configuration file>");
        System.exit(1);
    }

    configFilePath = args[1];
    CloudWatchCollector collector = null;
    FileReader reader = null;

    try {
      reader = new FileReader(configFilePath);
      collector = new CloudWatchCollector(new FileReader(configFilePath)).register();
    } finally {
      if (reader != null) {
        reader.close();
      }
    }

    ReloadSignalHandler.start(collector);

    int port = Integer.parseInt(args[0]);
    Server server = new Server(port);
    ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
    context.addServlet(new ServletHolder(new DynamicReloadServlet(collector)), "/-/reload");
    context.addServlet(new ServletHolder(new HealthServlet()), "/-/healthy");
    context.addServlet(new ServletHolder(new HealthServlet()), "/-/ready");
    context.addServlet(new ServletHolder(new HomePageServlet()), "/");
    server.start();
    server.join();
}
 
源代码11 项目: wingtips   文件: Main.java
public static void main(String[] args) throws Exception {
    Server server = createServer(Integer.parseInt(System.getProperty(PORT_SYSTEM_PROP_KEY, "8080")));

    try {
        server.start();
        server.join();
    }
    finally {
        server.destroy();
    }
}
 
源代码12 项目: cs601   文件: FileServer.java
public static void main(String[] args) throws Exception {
      Server server = new Server(8080);
      ResourceHandler resource_handler = new ResourceHandler();
      resource_handler.setDirectoriesListed(true);
resource_handler.setResourceBase(".");                    // must set root dir

      HandlerList handlers = new HandlerList();
      handlers.setHandlers(new Handler[] { resource_handler, 	  // file handler
									 new DefaultHandler() // handles 404 etc...
});
      server.setHandler(handlers);

      server.start();
      server.join();
  }
 
源代码13 项目: backstopper   文件: Main.java
public static void main(String[] args) throws Exception {
    Server server = createServer(Integer.parseInt(System.getProperty(PORT_SYSTEM_PROP_KEY, "8080")));

    try {
        server.start();
        server.join();
    }
    finally {
        server.destroy();
    }
}
 
源代码14 项目: jumbune   文件: Starter.java
public void start() {

		Server server = new Server(9080);
		ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
		servletContextHandler.setContextPath("/");
		servletContextHandler.setResourceBase("src/main/webapp");

		final String webAppDirectory = JumbuneInfo.getHome() + "modules/webapp";
		final ResourceHandler resHandler = new ResourceHandler();
		resHandler.setResourceBase(webAppDirectory);
		final ContextHandler ctx = new ContextHandler("/");
		ctx.setHandler(resHandler);
		servletContextHandler.setSessionHandler(new SessionHandler());

		ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/apis/*");
		servletHolder.setInitOrder(0);
		servletHolder.setAsyncSupported(true);
		servletHolder.setInitParameter("jersey.config.server.provider.packages", "org.jumbune.web.services");
		servletHolder.setInitParameter("jersey.config.server.provider.classnames",
				"org.glassfish.jersey.media.multipart.MultiPartFeature");

		try {
			server.insertHandler(servletContextHandler);
			server.insertHandler(resHandler);
			server.start();
			server.join();
		} catch (Exception e) {
			LOGGER.error("Error occurred while starting Jetty", e);
			System.exit(1);
		}
	}
 
源代码15 项目: client_java   文件: ExampleExporter.java
public static void main(String[] args) throws Exception {
  Server server = new Server(1234);
  ServletContextHandler context = new ServletContextHandler();
  context.setContextPath("/");
  server.setHandler(context);
  context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
  g.set(1);
  c.inc(2);
  s.observe(3);
  h.observe(4);
  l.labels("foo").inc(5);
  server.start();
  server.join();
}
 
源代码16 项目: smarthome   文件: TestServer.java
/**
 * Starts the server and returns a {@link CompletableFuture}. The {@link CompletableFuture} gets completed as soon
 * as the server is ready to accept connections.
 *
 * @return a {@link CompletableFuture} which completes as soon as the server is ready to accept connections.
 */
public CompletableFuture<Boolean> startServer() {
    final CompletableFuture<Boolean> serverStarted = new CompletableFuture<>();

    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            server = new Server();
            ServletHandler handler = new ServletHandler();
            handler.addServletWithMapping(servletHolder, "/*");
            server.setHandler(handler);

            // HTTP connector
            ServerConnector http = new ServerConnector(server);
            http.setHost(host);
            http.setPort(port);
            http.setIdleTimeout(timeout);

            server.addConnector(http);

            try {
                server.start();
                serverStarted.complete(true);
                server.join();
            } catch (InterruptedException ex) {
                logger.error("Server got interrupted", ex);
                serverStarted.completeExceptionally(ex);
                return;
            } catch (Exception e) {
                logger.error("Error in starting the server", e);
                serverStarted.completeExceptionally(e);
                return;
            }

        }
    });

    thread.start();

    return serverStarted;
}
 
源代码17 项目: logsniffer   文件: JettyLauncher.java
/**
 * Starts Jetty.
 * 
 * @param args
 * @throws Exception
 */
public void start(final String[] args, final URL warLocation) throws Exception {
	Server server = new Server();
	ServerConnector connector = new ServerConnector(server);

	// Set JSP to use Standard JavaC always
	System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");

	// Set some timeout options to make debugging easier.
	connector.setIdleTimeout(1000 * 60 * 60);
	connector.setSoLingerTime(-1);
	connector.setPort(Integer.parseInt(System.getProperty("logsniffer.httpPort", "8082")));
	connector.setHost(System.getProperty("logsniffer.httpListenAddress", "0.0.0.0"));
	server.setConnectors(new Connector[] { connector });

	// Log.setLog(new Slf4jLog());

	// This webapp will use jsps and jstl. We need to enable the
	// AnnotationConfiguration in order to correctly
	// set up the jsp container
	Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(server);
	classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
			"org.eclipse.jetty.annotations.AnnotationConfiguration");

	WebContextWithExtraConfigurations ctx = createWebAppContext();

	ctx.setServer(server);
	ctx.setWar(warLocation.toExternalForm());
	String ctxPath = System.getProperty("logsniffer.contextPath", "/");
	if (!ctxPath.startsWith("/")) {
		ctxPath = "/" + ctxPath;
	}
	ctx.setContextPath(ctxPath);
	configureWebAppContext(ctx);
	ctx.freezeConfigClasses();
	server.setHandler(ctx);

	server.setStopAtShutdown(true);
	try {
		server.start();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(100);
	}
}
 
源代码18 项目: graphicsfuzz   文件: FuzzerServer.java
public void start() throws Exception {

    FuzzerServiceImpl fuzzerService = new FuzzerServiceImpl(
        Paths.get(workingDir, processingDir).toString(),
        executorService);

    FuzzerService.Processor processor =
        new FuzzerService.Processor<FuzzerService.Iface>(fuzzerService);

    FuzzerServiceManagerImpl fuzzerServiceManager = new FuzzerServiceManagerImpl(fuzzerService,
          new PublicServerCommandDispatcher());
    FuzzerServiceManager.Processor managerProcessor =
        new FuzzerServiceManager.Processor<FuzzerServiceManager.Iface>(fuzzerServiceManager);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    {
      ServletHolder sh = new ServletHolder();
      sh.setServlet(new TServlet(processor, new TBinaryProtocol.Factory()));
      context.addServlet(sh, "/request");
    }
    {
      ServletHolder serveltHolderJson = new ServletHolder();
      serveltHolderJson.setServlet(new TServlet(processor, new TJSONProtocol.Factory()));
      context.addServlet(serveltHolderJson, "/requestJSON");
    }

    {
      ServletHolder shManager = new ServletHolder();
      shManager.setServlet(new TServlet(managerProcessor, new TBinaryProtocol.Factory()));
      context.addServlet(shManager, "/manageAPI");
    }

    final String staticDir = ToolPaths.getStaticDir();
    context.addServlet(
          new ServletHolder(
                new FileDownloadServlet(
                    (pathInfo, worker) -> Paths.get(staticDir, pathInfo).toFile(), staticDir)),
          "/static/*");

    HandlerList handlerList = new HandlerList();
    handlerList.addHandler(context);

    GzipHandler gzipHandler = new GzipHandler();
    gzipHandler.setHandler(handlerList);

    Server server = new Server(port);

    server.setHandler(gzipHandler);
    server.start();
    server.join();
  }
 
public static void main(String[] args) throws Exception {
	Server server = createJettyServer();
	server.start();
	server.join();
}
 
源代码20 项目: wicket-orientdb   文件: Start.java
/**
 * 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);
	}
}