diff --git a/src/main/java/com/guicedee/guicedinjection/GuiceContext.java b/src/main/java/com/guicedee/guicedinjection/GuiceContext.java index 0c48e0d..5fe5371 100644 --- a/src/main/java/com/guicedee/guicedinjection/GuiceContext.java +++ b/src/main/java/com/guicedee/guicedinjection/GuiceContext.java @@ -812,7 +812,17 @@ private void loadPostStartups() { log.info("Starting Post Startup Group [" + key + "] in Parallel"); ExecutorService postStartup = null; - for (IGuicePostStartup iGuicePostStartup : value) + value.stream().forEach(a->{ + try + { + a.postLoad(); + } + catch (Throwable T) + { + log.log(Level.SEVERE, "Cannot execute post startup - ", T); + } + }); + /*for (IGuicePostStartup iGuicePostStartup : value) { postStartup = JobService.INSTANCE.addJob("PostStartup", () -> { try @@ -836,7 +846,7 @@ private void loadPostStartups() catch (Throwable e) { log.log(Level.SEVERE, "Cannot execute post startup - ", e); - } + }*/ } GuiceContext.log.fine("Completed with Post Startups Key [" + key + "]"); } diff --git a/src/main/java/com/guicedee/guicedinjection/JobService.java b/src/main/java/com/guicedee/guicedinjection/JobService.java index 8259d46..f03ecb0 100644 --- a/src/main/java/com/guicedee/guicedinjection/JobService.java +++ b/src/main/java/com/guicedee/guicedinjection/JobService.java @@ -86,6 +86,24 @@ public ExecutorService removeJob(String pool) serviceMap.remove(pool); return es; } + + /** + * Completes and Removes all jobs running from the given pool + * + * @param pool The pool to remove + */ + public ExecutorService removeJobNoWait(String pool) + { + ExecutorService es = serviceMap.get(pool); + if (es == null) + { + log.warning("Pool " + pool + " was not registered"); + return null; + } + waitForJob(pool,1L,TimeUnit.MILLISECONDS); + serviceMap.remove(pool); + return es; + } /** * Completes and Removes all jobs running from the given pool