@Test void testEvents() { HelidonContainer instance = HelidonContainer.instance(); BeanManager beanManager = CDI.current().getBeanManager(); TestExtension extension = beanManager.getExtension(TestExtension.class); assertThat(extension.runtimeConfig(), nullValue()); assertThat(extension.events(), contains(TestExtension.BUILD_TIME_START, TestExtension.BUILD_TIME_END)); Config config = ConfigProviderResolver.instance() .getBuilder() .withSources(MpConfigSources.create(Map.of("key", "value"))) .build(); ConfigProviderResolver.instance() .registerConfig(config, Thread.currentThread().getContextClassLoader()); instance.start(); Object runtimeConfig = extension.runtimeConfig(); assertThat(runtimeConfig, instanceOf(MpConfigProviderResolver.ConfigDelegate.class)); assertThat(((MpConfigProviderResolver.ConfigDelegate) runtimeConfig).delegate(), sameInstance(config)); instance.shutdown(); assertThat(extension.events(), is(List.of(TestExtension.BUILD_TIME_START, TestExtension.BUILD_TIME_END, TestExtension.RUNTIME_INIT, TestExtension.APPLICATION_INIT, TestExtension.APPLICATION_BEFORE_DESTROYED, TestExtension.APPLICATION_DESTROYED))); }
public static void shutdown() { if (null != inUse && MAIN_CALLED.get()) { LOGGER.finest("Shutting down container from cdi.Main"); MAIN_CALLED.set(false); inUse.shutdown(); } else { try { ((SeContainer) CDI.current()).close(); } catch (IllegalStateException e) { LOGGER.log(Level.FINEST, "Failed to obtain a CDI instance to shut down, probably duplicate call", e); } } }
Main { public static void shutdown() { if (null != inUse && MAIN_CALLED.get()) { LOGGER.finest("Shutting down container from cdi.Main"); MAIN_CALLED.set(false); inUse.shutdown(); } else { try { ((SeContainer) CDI.current()).close(); } catch (IllegalStateException e) { LOGGER.log(Level.FINEST, "Failed to obtain a CDI instance to shut down, probably duplicate call", e); } } } }
Main { public static void shutdown() { if (null != inUse && MAIN_CALLED.get()) { LOGGER.finest("Shutting down container from cdi.Main"); MAIN_CALLED.set(false); inUse.shutdown(); } else { try { ((SeContainer) CDI.current()).close(); } catch (IllegalStateException e) { LOGGER.log(Level.FINEST, "Failed to obtain a CDI instance to shut down, probably duplicate call", e); } } } private  Main(); }
Main { public static void shutdown() { if (null != inUse && MAIN_CALLED.get()) { LOGGER.finest("Shutting down container from cdi.Main"); MAIN_CALLED.set(false); inUse.shutdown(); } else { try { ((SeContainer) CDI.current()).close(); } catch (IllegalStateException e) { LOGGER.log(Level.FINEST, "Failed to obtain a CDI instance to shut down, probably duplicate call", e); } } } private  Main(); static void main(String[] args); static void shutdown(); }
Main { public static void shutdown() { if (null != inUse && MAIN_CALLED.get()) { LOGGER.finest("Shutting down container from cdi.Main"); MAIN_CALLED.set(false); inUse.shutdown(); } else { try { ((SeContainer) CDI.current()).close(); } catch (IllegalStateException e) { LOGGER.log(Level.FINEST, "Failed to obtain a CDI instance to shut down, probably duplicate call", e); } } } private  Main(); static void main(String[] args); static void shutdown();  }