com.sun.net.httpserver.HttpServer.stop()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中com.sun.net.httpserver.HttpServer.stop()方法的一些代码示例,展示了HttpServer.stop()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpServer.stop()方法的具体详情如下:
包路径:com.sun.net.httpserver.HttpServer
类名称:HttpServer
方法名:stop

HttpServer.stop介绍

[英]stops this server by closing the listening socket and disallowing any new exchanges from being processed. The method will then block until all current exchange handlers have completed or else when approximately delay seconds have elapsed (whichever happens sooner). Then, all open TCP connections are closed, the background thread created by start() exits, and the method returns. Once stopped, a HttpServer cannot be re-used.
[中]通过关闭侦听套接字并禁止处理任何新交换来停止此服务器。然后,该方法将阻塞,直到所有当前exchange处理程序都已完成,或者大约已过延迟秒(以较早发生的为准)。然后,关闭所有打开的TCP连接,退出由start()创建的后台线程,然后该方法返回。一旦停止,HttpServer就不能重复使用。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void destroy() {
  logger.info("Stopping HttpServer");
  this.server.stop(this.shutdownDelay);
}

代码示例来源:origin: Netflix/eureka

public void shutdown() {
  httpServer.stop(0);
}

代码示例来源:origin: jersey/jersey

@Override
  public void run() {
    server.stop(0);
  }
}));

代码示例来源:origin: org.springframework/spring-context

@Override
public void destroy() {
  logger.info("Stopping HttpServer");
  this.server.stop(this.shutdownDelay);
}

代码示例来源:origin: alibaba/jstorm

@Override
public void shutdown() {
  if (hs != null) {
    hs.stop(0);
    LOG.info("Successfully stopped http server");
  }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void destroy() {
  super.destroy();
  if (this.server != null && this.localServer) {
    logger.info("Stopping HttpServer");
    this.server.stop(this.shutdownDelay);
  }
}

代码示例来源:origin: jersey/jersey

@Override
  public void stop() {
    if (started.compareAndSet(true, false)) {
      LOGGER.log(Level.FINE, "Stopping JdkHttpServerTestContainer...");
      this.server.stop(3);
    } else {
      LOGGER.log(Level.WARNING, "Ignoring stop request - JdkHttpServerTestContainer is already stopped.");
    }
  }
}

代码示例来源:origin: org.springframework/spring-web

@Override
public void destroy() {
  super.destroy();
  if (this.server != null && this.localServer) {
    logger.info("Stopping HttpServer");
    this.server.stop(this.shutdownDelay);
  }
}

代码示例来源:origin: jersey/jersey

@Override
public void stop(final int i) {
  handler.onServerStop();
  delegate.stop(i);
}

代码示例来源:origin: apache/ignite

/**
 * Stops server by closing the listening socket and disallowing any new exchanges
 * from being processed.
 *
 * @param delay - the maximum time in seconds to wait until exchanges have finished.
 */
public void stop(int delay) {
  httpSrv.stop(delay);
}

代码示例来源:origin: pentaho/pentaho-kettle

private static void stopHTTPServer() {
  httpServer.stop( 2 );
 }
}

代码示例来源:origin: cloudfoundry/uaa

public void stop() {
  if (httpServer != null) {
    httpServer.stop(0);
  }
}

代码示例来源:origin: apache/incubator-pinot

@AfterClass
public void tearDown() {
 for (HttpServer server : servers) {
  if (server != null) {
   server.stop(0);
  }
 }
}

代码示例来源:origin: apache/incubator-pinot

@AfterClass
 public void shutDown() {
  TEST_SERVER.stop(0);
 }
}

代码示例来源:origin: apache/incubator-pinot

@AfterClass
public void tearDown() {
 for (Map.Entry<String, FakeSizeServer> fakeServerEntry : serverMap.entrySet()) {
  fakeServerEntry.getValue().httpServer.stop(0);
 }
}

代码示例来源:origin: apache/incubator-pinot

@AfterTest
public void tearDownTest() {
 for (HttpServer server : servers) {
  server.stop(0);
 }
}

代码示例来源:origin: testcontainers/testcontainers-java

@AfterClass
public static void tearDownClass() throws Exception {
  server.stop(0);
}

代码示例来源:origin: testcontainers/testcontainers-java

@AfterClass
public static void tearDown() throws Exception {
  server.stop(0);
}

代码示例来源:origin: cloudfoundry/uaa

@After
public void teardown() throws Exception {
  httpsServer.stop(0);
  httpServer.stop(0);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void simpleHessianServiceExporter() throws IOException {
  final int port = SocketUtils.findAvailableTcpPort();
  TestBean tb = new TestBean("tb");
  SimpleHessianServiceExporter exporter = new SimpleHessianServiceExporter();
  exporter.setService(tb);
  exporter.setServiceInterface(ITestBean.class);
  exporter.setDebug(true);
  exporter.prepare();
  HttpServer server = HttpServer.create(new InetSocketAddress(port), -1);
  server.createContext("/hessian", exporter);
  server.start();
  try {
    HessianClientInterceptor client = new HessianClientInterceptor();
    client.setServiceUrl("http://localhost:" + port + "/hessian");
    client.setServiceInterface(ITestBean.class);
    //client.setHessian2(true);
    client.prepare();
    ITestBean proxy = ProxyFactory.getProxy(ITestBean.class, client);
    assertEquals("tb", proxy.getName());
    proxy.setName("test");
    assertEquals("test", proxy.getName());
  }
  finally {
    server.stop(Integer.MAX_VALUE);
  }
}

相关文章