當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServer.createSimpleServer方法代碼示例

本文整理匯總了Java中org.glassfish.grizzly.http.server.HttpServer.createSimpleServer方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServer.createSimpleServer方法的具體用法?Java HttpServer.createSimpleServer怎麽用?Java HttpServer.createSimpleServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.glassfish.grizzly.http.server.HttpServer的用法示例。


在下文中一共展示了HttpServer.createSimpleServer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerWebsocket

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
private void registerWebsocket() throws IOException {
  Configuration configuration = ConfigurationReader.INSTANCE.readConfiguration("core-site.xml");
  websocketServicePort = Integer
      .parseInt(configuration.get("events.server.websocket.port", "8082"));
  try {
    ServerSocket s = new ServerSocket(websocketServicePort);
    websocketServicePort = s.getLocalPort();
    s.close();
    waitTillSocketIsClosed(s);
    String webSocketserviceHost = java.net.InetAddress.getLocalHost().getHostAddress();
    final HttpServer server = HttpServer.createSimpleServer(null, webSocketserviceHost,
        websocketServicePort);
    for (NetworkListener listener : server.getListeners()) {
      listener.registerAddOn(new WebSocketAddOn());
    }
    WebSocketEngine.getEngine().register("", "/event-stream", new EventsSocketApplication());
    server.start();

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
      @Override
      public void run() {
        server.shutdownNow();
      }
    }, "Server-Showdown-Thread"));

  } catch (IOException | InterruptedException e) {
    throw new IllegalStateException("Failed to start api-service. name = events.service", e);
  }
}
 
開發者ID:DataRPM-Labs,項目名稱:sigma-events,代碼行數:30,代碼來源:EventEngineAPIServiceStarter.java

示例2: httpServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Bean
public HttpServer httpServer()
		throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, KeyStoreException,
		FileNotFoundException, CertificateException, UnrecoverableEntryException, ConfigurationException {
	HttpServer server = HttpServer.createSimpleServer("./", 8080);
	WebSocketAddOn addon = new WebSocketAddOn();
	server.getListeners().stream().forEach((listen) -> {
		listen.registerAddOn(addon);
		listen.setSecure(true);
		listen.setSSLEngineConfig(
				new SSLEngineConfigurator(this.sslConf()).setClientMode(false).setNeedClientAuth(false));
	});

	String messengerPath = configuration().getString(GlobalConfig.MESSENGER_PATH);
	if (messengerPath == null) {
		messengerPath = GlobalConfig.MESSENGER_PATH_DEFAULT;
	}

	ChatApplication application = this.chatApplication();
	WebSocketEngine.getEngine().register("", messengerPath, application);
	return server;
}
 
開發者ID:shilongdai,項目名稱:LSChatServer,代碼行數:23,代碼來源:ApplicationRootContext.java

示例3: PullServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public PullServer(PushSerConfig config) {

		this.wsContext = new PushContext(config);
		this.center = new MessageCenter();
		PreCheckListener check = new PreCheckListener(center);
		ProtocolManager instance = ProtocolManager.getInstance();
		instance.addCodec(new RFC6455CodecImpl());
		this.wsContext.setProtocolManager(instance);
		this.wsContext.addConnListener(check);
		this.wsContext.setMessageCenter(center);
		this.port = config.getPort();
		
		String base = config.getResourceBase();
		server = HttpServer.createSimpleServer(base, port);
		sercfg = server.getServerConfiguration();
		sercfg.getMonitoringConfig().getWebServerConfig().addProbes(this);
		doInit(center);
	}
 
開發者ID:coderczp,項目名稱:HtmlSocket,代碼行數:19,代碼來源:PullServer.java

示例4: start

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void start(final ApplicationContext applicationConfig, final int port, String path) {
    try {
        // Logging settings
        InputStream loggingStream = GrizzlyServer.class.getResourceAsStream("/logging.properties");
        if (nonNull(loggingStream)) {
            LogManager.getLogManager().readConfiguration(loggingStream);
        }

        HttpServer server = HttpServer.createSimpleServer(null, port);
        server.getServerConfiguration().addHttpHandler(
            new GrizzlyApplicationHandler(applicationConfig), path);

        Runtime.getRuntime().addShutdownHook(new Thread(server::shutdownNow));

        server.start();
        LOG.info("Grizzly Server started. Stop the application using ^C.");
        Thread.currentThread().join();
    } catch (IOException | InterruptedException e) {
        LOG.log(Level.SEVERE, null, e);
    }
}
 
開發者ID:petrbouda,項目名稱:joyrest,代碼行數:22,代碼來源:GrizzlyServer.java

示例5: runHttpServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
private static void runHttpServer() throws IOException, InterruptedException {
	logger.info("Http Server starting");
	final HttpServer server = HttpServer.createSimpleServer("/",10024);
	final ServerConfiguration config = server.getServerConfiguration();
	config.addHttpHandler(new UpdateLocationApi(), "/yelli/update");
	config.addHttpHandler(new CreateTrackerApi(), "/yelli/create");
	config.addHttpHandler(new TestServelet(), "/yelli/test");
	config.setJmxEnabled(true);
	server.start();
}
 
開發者ID:callmesusheel,項目名稱:yelli,代碼行數:11,代碼來源:App.java

示例6: startServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer(int port, Action<ServerWebSocket> websocketAction) throws Exception {
  server = HttpServer.createSimpleServer(null, port);
  NetworkListener listener = server.getListener("grizzly");
  listener.registerAddOn(new WebSocketAddOn());
  WebSocketEngine.getEngine().register("", TEST_URI, new AsityWebSocketApplication()
    .onwebsocket(websocketAction));
  server.start();
}
 
開發者ID:cettia,項目名稱:asity,代碼行數:10,代碼來源:GrizzlyServerWebSocketTest.java

示例7: startServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer(int port, Action<ServerHttpExchange> requestAction) throws Exception {
  server = HttpServer.createSimpleServer(null, port);
  ServerConfiguration config = server.getServerConfiguration();
  config.addHttpHandler(new AsityHttpHandler().onhttp(requestAction), TEST_URI);
  server.start();
}
 
開發者ID:cettia,項目名稱:asity,代碼行數:8,代碼來源:GrizzlyServerHttpExchangeTest.java

示例8: IPCamServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
/**
 * @param httpPort the http port to server on
 */
public IPCamServer(int httpPort) {
    mCamDevices = new ConcurrentHashMap<>();
    synchronized (serverMonitor) {
        server = HttpServer.createSimpleServer(null, httpPort);
        server.getServerConfiguration().addHttpHandler(new IndexHandler(mCamDevices));
    }
}
 
開發者ID:Blaubot,項目名稱:Blaubot,代碼行數:11,代碼來源:IPCamServer.java

示例9: startServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer() throws Exception {
    server = HttpServer.createSimpleServer(null, port);
    NetworkListener listener = server.getListener("grizzly");
    listener.registerAddOn(new WebSocketAddOn());
    WebSocketEngine.getEngine().register("", "/test", new VibeWebSocketApplication().onwebsocket(performer.serverAction()));
    server.start();
}
 
開發者ID:vibe-project,項目名稱:vibe-java-platform,代碼行數:9,代碼來源:GrizzlyServerWebSocketTest.java

示例10: startServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
protected void startServer() throws Exception {
    server = HttpServer.createSimpleServer(null, port);
    ServerConfiguration config = server.getServerConfiguration();
    config.addHttpHandler(new VibeHttpHandler().onhttp(performer.serverAction()), "/test");
    server.start();
}
 
開發者ID:vibe-project,項目名稱:vibe-java-platform,代碼行數:8,代碼來源:GrizzlyServerHttpExchangeTest.java

示例11: startWebserver

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@BeforeClass
public static void startWebserver() throws IOException {
  MimeType.add("mp4", "video/mp4");

  server =
      HttpServer.createSimpleServer(
          Samples.TEST_PREFIX, "127.0.0.1", new PortRange(10000, 60000));
  server.start();

  LOG.info("Started server at {}", getWebserverRoot());
}
 
開發者ID:bramp,項目名稱:ffmpeg-cli-wrapper,代碼行數:12,代碼來源:FFmpegExecutorTest.java

示例12: setUp

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    
    String httpRoot = URLDecoder.decode(new File(getClass().getResource("/").getFile()).getAbsolutePath(), "utf-8");
    httpServer = HttpServer.createSimpleServer(httpRoot, "localhost", 9997);
    // Disable file cache to fix https://java.net/jira/browse/GRIZZLY-1350
    ((StaticHttpHandler) httpServer.getServerConfiguration().getHttpHandlers().keySet().iterator().next()).setFileCacheEnabled(false);
    httpServer.start();
}
 
開發者ID:sismics,項目名稱:books,代碼行數:12,代碼來源:BaseJerseyTest.java

示例13: initServer

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
final HttpServer initServer(Bck2Brwsr.Resources... extraResources) throws IOException {
    xRes.addAll(Arrays.asList(extraResources));
    
    HttpServer s = HttpServer.createSimpleServer(".", new PortRange(8080, 65535));

    final ServerConfiguration conf = s.getServerConfiguration();
    conf.addHttpHandler(new VM(resources), "/bck2brwsr.js");
    conf.addHttpHandler(new VMInit(), "/vm.js");
    conf.addHttpHandler(new Classes(resources), "/classes/");
    return s;
}
 
開發者ID:jtulach,項目名稱:dew,代碼行數:12,代碼來源:DewLauncher.java

示例14: main

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public static void main(String[] args) {
    Server server = new Server(HOST, WEB_SOCKET_PORT, WEB_SOCKET_CONTEXT, EchoEndpoint.class);
    HttpServer httpServer = HttpServer.createSimpleServer(HTTP_SERVER_CONTEXT_ROOT, HOST, HTTP_SERVER_PORT);
    try {
        server.start();
        httpServer.start();
        System.out.println("Please press a key to stop the server.");
        System.in.read();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        httpServer.stop();
        server.stop();
    }
}
 
開發者ID:ihiroky,項目名稱:tyrus-sample,代碼行數:16,代碼來源:SampleStandalone.java

示例15: run

import org.glassfish.grizzly.http.server.HttpServer; //導入方法依賴的package包/類
public void run(CompletableFuture start,  JaxRsServletConfigurer jaxRsConfigurer, CompletableFuture end) {

		WebappContext webappContext = new WebappContext("WebappContext", "");

		new ServletContextListenerConfigurer(serverData, servletContextListenerData, servletRequestListenerData);

		
		jaxRsConfigurer.addServlet(this.serverData,webappContext);

		new ServletConfigurer(serverData, servletData).addServlets(webappContext);

		new FilterConfigurer(serverData, this.filterData).addFilters(webappContext);

		addListeners(webappContext);

		HttpServer httpServer = HttpServer.createSimpleServer(null, "0.0.0.0", serverData.getPort());
		serverData.getModule().getServerConfigManager().accept(new WebServerProvider(httpServer));
		addAccessLog(httpServer);
		addSSL(httpServer);

		startServer(webappContext, httpServer, start, end);
	}
 
開發者ID:aol,項目名稱:micro-server,代碼行數:23,代碼來源:GrizzlyApplication.java


注:本文中的org.glassfish.grizzly.http.server.HttpServer.createSimpleServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。