当前位置: 首页>>代码示例>>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;未经允许,请勿转载。