@Bean public Server jettyServer(ApplicationContext context) throws Exception { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); Servlet servlet = new JettyHttpHandlerAdapter(handler); Server server = new Server(); ServletContextHandler contextHandler = new ServletContextHandler(server, ""); contextHandler.addServlet(new ServletHolder(servlet), "/"); contextHandler.start(); ServerConnector connector = new ServerConnector(server); connector.setHost("localhost"); connector.setPort(port); server.addConnector(connector); return server; }
@Bean public Tomcat embededTomcatServer(ApplicationContext context) throws Exception { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); // Tomcat and Jetty (also see notes below) Servlet servlet = new TomcatHttpHandlerAdapter(handler); Tomcat tomcatServer = new Tomcat(); tomcatServer.setHostname("localhost"); tomcatServer.setPort(this.port); Context rootContext = tomcatServer.addContext("", System.getProperty("java.io.tmpdir")); Tomcat.addServlet(rootContext, "httpHandlerServlet", servlet); rootContext.addServletMappingDecoded("/", "httpHandlerServlet"); return tomcatServer; }
@Bean public HttpHandler handler() { return WebHttpHandlerBuilder .webHandler((WebHandler) toHttpHandler(routing())) .filter(limitFilter) // .filter(validateFilter) .build(); }
@Bean public HttpServer httpServer(RouterFunction<?> routerFunction) { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler); HttpServer server = HttpServer .create(serverConfigBean.getAddress(), serverConfigBean.getPort()); server.newHandler(adapter); return server; }
private void startReactorServer() { RouterFunction<?> route = routingFunction(); HttpHandler httpHandler = toHttpHandler(route); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler); HttpServer server = HttpServer.create(HOST, PORT); server.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8095")); return httpServer.newHandler(adapter).block(); }
public ServletRegistrationBean routeServlet1(RouterFunction<?> routerFunction) throws Exception { HttpHandler httpHandler = RouterFunctions.toHttpHandler(routerFunction ); ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(httpHandler); ServletRegistrationBean registrationBean = new ServletRegistrationBean<>(servlet, "/flux" + "/*"); registrationBean.setLoadOnStartup(1); registrationBean.setAsyncSupported(true); System.out.println("starts server"); return registrationBean; }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8908")); return httpServer.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8901")); return httpServer.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9007")); return httpServer.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9006")); return httpServer.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8909")); return httpServer.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("8125")); return httpServer.newHandler(adapter).block(); }
@Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", Integer.valueOf("9008")); return httpServer.newHandler(adapter).block(); }
@Bean public HttpServer reactorServer(){ HttpHandler handler = DispatcherHandler.toHttpHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create(port); httpServer.newHandler(adapter).block(); return httpServer; }
@Bean public HttpServer reactorServer(){ HttpHandler handler = routingHandler(); //HttpHandler handler = dispatcherHandler(context); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create(port); httpServer.newHandler(adapter).block(); return httpServer; }
@Profile("default") @Bean public NettyContext nettyContext(ApplicationContext context) { HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create("localhost", this.port); return httpServer.newHandler(adapter).block(); }