/** Starts the thread that runs the Resource Manager server. */ public void start() { server.start(); }
synchronized public void run() { log.fine("Starting StreamServer..."); // Starts a new thread but inherits the properties of the calling thread server.start(); }
@Override public void afterPropertiesSet() throws Exception { if (this.server == null) { InetSocketAddress address = (this.hostname != null ? new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port)); HttpServer server = HttpServer.create(address, this.backlog); if (logger.isInfoEnabled()) { logger.info("Starting HttpServer at address " + address); } server.start(); this.server = server; this.localServer = true; } super.afterPropertiesSet(); }
@Override public void start() { delegate.start(); handler.onServerStart(); }
@Override public void run() { server.start(); } }).start();
@Override public void run() { httpServer.start(); } }).start();
@Override public void run() { server.start(); } }).start();
@Override public void start() { if (started.compareAndSet(false, true)) { LOGGER.log(Level.FINE, "Starting JdkHttpServerTestContainer..."); server.start(); if (baseUri.getPort() == 0) { baseUri = UriBuilder.fromUri(baseUri) .port(server.getAddress().getPort()) .build(); LOGGER.log(Level.INFO, "Started JdkHttpServerTestContainer at the base URI " + baseUri); } } else { LOGGER.log(Level.WARNING, "Ignoring start request - JdkHttpServerTestContainer is already started."); } }
@Override public void afterPropertiesSet() throws Exception { if (this.server == null) { InetSocketAddress address = (this.hostname != null ? new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port)); HttpServer server = HttpServer.create(address, this.backlog); if (logger.isInfoEnabled()) { logger.info("Starting HttpServer at address " + address); } server.start(); this.server = server; this.localServer = true; } super.afterPropertiesSet(); }
@Override public void afterPropertiesSet() throws IOException { InetSocketAddress address = (this.hostname != null ? new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port)); this.server = HttpServer.create(address, this.backlog); if (this.executor != null) { this.server.setExecutor(this.executor); } if (this.contexts != null) { this.contexts.forEach((key, context) -> { HttpContext httpContext = this.server.createContext(key, context); if (this.filters != null) { httpContext.getFilters().addAll(this.filters); } if (this.authenticator != null) { httpContext.setAuthenticator(this.authenticator); } }); } if (logger.isInfoEnabled()) { logger.info("Starting HttpServer at address " + address); } this.server.start(); }
public SimpleEurekaHttpServer(EurekaHttpClient requestHandler, EurekaTransportEventListener eventListener) throws IOException { this.requestHandler = requestHandler; this.eventListener = eventListener; this.httpServer = HttpServer.create(new InetSocketAddress(0), 1); httpServer.createContext("/v2", createEurekaV2Handle()); httpServer.setExecutor(null); httpServer.start(); }
public void start() { int numHandler = 3; InetSocketAddress socketAddr = new InetSocketAddress(port); Executor executor = Executors.newFixedThreadPool(numHandler); try { hs = HttpServer.create(socketAddr, 0); hs.createContext(HttpserverUtils.HTTPSERVER_CONTEXT_PATH_LOGVIEW, new LogHandler(conf)); hs.setExecutor(executor); hs.start(); } catch (BindException e) { LOG.info("HttpServer has started already!"); hs = null; return; } catch (IOException e) { LOG.error("Failed to start HttpServer", e); hs = null; return; } LOG.info("Success started HttpServer at port:" + port); }
server.createContext("/test", new MyHandler()); server.start();
@Override public void afterPropertiesSet() throws IOException { InetSocketAddress address = (this.hostname != null ? new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port)); this.server = HttpServer.create(address, this.backlog); if (this.executor != null) { this.server.setExecutor(this.executor); } if (this.contexts != null) { this.contexts.forEach((key, context) -> { HttpContext httpContext = this.server.createContext(key, context); if (this.filters != null) { httpContext.getFilters().addAll(this.filters); } if (this.authenticator != null) { httpContext.setAuthenticator(this.authenticator); } }); } if (logger.isInfoEnabled()) { logger.info("Starting HttpServer at address " + address); } this.server.start(); }
public static HttpServer startHttpServer(int port, HttpHandler handler) throws Exception { //some stack overflow goodness for testing only InetSocketAddress address = new InetSocketAddress(port); HttpServer httpServer = HttpServer.create(address, 0); httpServer.createContext("/", handler); httpServer.setExecutor(new ThreadPoolExecutor(1, 1, 10, TimeUnit.SECONDS, new LinkedBlockingQueue<>())); httpServer.start(); return httpServer; }
@BeforeClass public void setUp() throws Exception { TEST_SERVER = HttpServer.create(new InetSocketAddress(TEST_PORT), 0); TEST_SERVER.createContext("/v2/segments", new testSegmentUploadHandler()); TEST_SERVER.setExecutor(null); // creates a default executor TEST_SERVER.start(); }
@BeforeClass public static void setUpClass() throws Exception { server = HttpServer.create(new InetSocketAddress(0), 0); server.createContext("/", exchange -> { byte[] content = "Hello World!".getBytes(); exchange.sendResponseHeaders(200, content.length); try (OutputStream responseBody = exchange.getResponseBody()) { responseBody.write(content); responseBody.flush(); } }); server.start(); Testcontainers.exposeHostPorts(server.getAddress().getPort()); }
@BeforeClass public static void setUp() throws Exception { server = HttpServer.create(new InetSocketAddress(0), 0); server.createContext("/", exchange -> { byte[] content = "Hello World!".getBytes(); exchange.sendResponseHeaders(200, content.length); try (OutputStream responseBody = exchange.getResponseBody()) { responseBody.write(content); responseBody.flush(); } }); server.start(); localServerPort = server.getAddress().getPort(); // exposePort { Testcontainers.exposeHostPorts(localServerPort); // } }
private static void initHttpServer() throws Exception { // Setup default endpoints final HttpServer server = HttpServer.create(); server.createContext("/echo", new EchoHandler()); // Hook to allow for graceful exit final Closeable c = () -> { PollScheduler.getInstance().stop(); server.stop(5); }; server.createContext("/exit", new ExitHandler(c)); // Bind and start server server.bind(new InetSocketAddress(Config.getPort()), 0); server.start(); }
@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); } }