public List<Thread> run() { register.ifPresent( reg -> reg.register( apps.stream().map(app -> app.getServerData()) .collect(Collectors.toList()) .toArray(new ServerData[0]))); Map<ServerApplication,CompletableFuture> mapFutures = new HashMap<>(); apps.stream().forEach(app -> mapFutures.put(app,new CompletableFuture())); List<Thread> threads = apps.stream().map(app -> start(app, app.getServerData().getModule(),mapFutures.get(app))).collect(Collectors.toList()); mapFutures.values().forEach(future -> get(future)); logger.info("Started {} Rest applications ", apps.size()); return threads; }
private Thread start(ServerApplication next, Module module, CompletableFuture start) { Thread t = new Thread(() -> { ServerThreadLocalVariables.getContext().set(module.getContext()); next.run(start,new JaxRsServletConfigurer(), end); }); t.setName(module.getContext()); t.start(); return t; }
private Thread start(ServerApplication next, Module module, CompletableFuture start) { Thread t = new Thread(() -> { ServerThreadLocalVariables.getContext().set(module.getContext()); next.run(start,new JaxRsServletConfigurer(), end); }); t.setName(module.getContext()); t.start(); return t; }
public List<Thread> run() { register.ifPresent( reg -> reg.register( apps.stream().map(app -> app.getServerData()) .collect(Collectors.toList()) .toArray(new ServerData[0]))); Map<ServerApplication,CompletableFuture> mapFutures = new HashMap<>(); apps.stream().forEach(app -> mapFutures.put(app,new CompletableFuture())); List<Thread> threads = apps.stream().map(app -> start(app, app.getServerData().getModule(),mapFutures.get(app))).collect(Collectors.toList()); mapFutures.values().forEach(future -> get(future)); logger.info("Started {} Rest applications ", apps.size()); return threads; }