List of usage examples for org.springframework.web.reactive DispatcherHandler setApplicationContext
@Override public void setApplicationContext(ApplicationContext applicationContext)
From source file:playground.Application.java
public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("playground"); DispatcherHandler dispatcherHandler = new DispatcherHandler(); dispatcherHandler.setApplicationContext(context); HttpServer server = new ReactorHttpServer(); server.setPort(8080);/*from www . j a v a 2 s . co m*/ server.setHandler(dispatcherHandler); server.afterPropertiesSet(); server.start(); CompletableFuture<Void> stop = new CompletableFuture<>(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { stop.complete(null); })); synchronized (stop) { stop.wait(); } }
From source file:playground.app.Application.java
public static HttpHandler createHttpHandler() throws IOException { Properties prop = new Properties(); prop.load(Application.class.getClassLoader().getResourceAsStream("application.properties")); String profiles = prop.getProperty("profiles"); if (profiles != null) { System.setProperty("spring.profiles.active", profiles); }/*from w w w . j a v a2 s . c o m*/ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("playground"); DispatcherHandler dispatcherHandler = new DispatcherHandler(); dispatcherHandler.setApplicationContext(context); Map<String, WebFilter> beanNameToFilters = context.getBeansOfType(WebFilter.class); WebFilter[] filters = beanNameToFilters.values().toArray(new WebFilter[0]); Arrays.sort(filters, AnnotationAwareOrderComparator.INSTANCE); return WebHttpHandlerBuilder.webHandler(dispatcherHandler) .exceptionHandlers(new ResponseStatusExceptionHandler()).filters(filters).build(); }