@Override protected void doStop() throws Exception { super.doStop(); if (cdiContainer != null) { cdiContainer.shutdown(); } } }
@Override public void stop() { if (container != null && isValid) { LOG.debug("stopping OpenWebBeans container"); container.getContextControl().stopContexts(); container.shutdown(); unsetProbeClassLoader(); } }
public static void main(String[] args) { CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer(); cdiContainer.boot(); ContextControl contextControl = cdiContainer.getContextControl(); contextControl.startContext(ApplicationScoped.class); ServiceLoader<Showcase> showcaseLoader = ServiceLoader.load(Showcase.class); Iterator<Showcase> showcaseIterator = showcaseLoader.iterator(); if (!showcaseIterator.hasNext()) { throw new RuntimeException("No showcases found"); } while (showcaseIterator.hasNext()) { BeanProvider.injectFields(showcaseIterator.next()).run(); } cdiContainer.shutdown(); }
void applyAfterFeatureConfig() { ProjectStageProducer.setProjectStage(previousProjectStage); previousProjectStage = null; CdiContainer container = CdiContainerLoader.getCdiContainer(); stopStartedScopes(container); if (this.containerStarted) { if (isStopContainerAllowed()) { shutdownExternalContainers(); container.shutdown(); //stop the container on the same level which started it containerStarted = false; } } }
void applyAfterClassConfig() { CdiContainer container = CdiContainerLoader.getCdiContainer(); stopStartedScopes(container); if (this.containerStarted) { if (CdiTestSuiteRunner.isStopContainerAllowed()) { shutdownExternalContainers(); container.shutdown(); //stop the container on the same level which started it CdiTestSuiteRunner.setContainerStarted(false); } } }
@Test public void testContainerBoot() { CdiContainer cc = CdiContainerLoader.getCdiContainer(); Assert.assertNotNull(cc); cc.boot(); cc.getContextControl().startContexts(); BeanManager bm = cc.getBeanManager(); Assert.assertNotNull(bm); Set<Bean<?>> beans = bm.getBeans(CarRepair.class); Bean<?> bean = bm.resolve(beans); CarRepair carRepair = (CarRepair) bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean)); Assert.assertNotNull(carRepair); Assert.assertNotNull(carRepair.getCar()); Assert.assertNotNull(carRepair.getCar().getUser()); cc.shutdown(); }
@Override public void run(RunNotifier notifier) { if (this.testSuiteClass == null) { throw new IllegalStateException("no test-suite class found"); } CdiContainer container = CdiContainerLoader.getCdiContainer(); if (!containerStarted) { applyTestSpecificMetaData(getTestClass().getJavaClass()); container.boot(getTestContainerConfig()); containerStarted = true; } notifier.addListener(new LogRunListener()); try { super.run(notifier); } finally { if (STOP_CONTAINER) { container.shutdown(); containerStarted = false; } } }
Assert.assertTrue(TestUser.isPreDestroyCalled()); cdiContainer.shutdown();
Assert.assertNull(carRepair.getCar().getUser().getName()); cdiContainer.shutdown();
cdiContainer.shutdown();