@Override public void requestDestroyed(ServletRequestEvent servletRequestEvent) { LOG.log(Level.FINER,"Request done."); ContextControl contextControl = (ContextControl)servletRequestEvent.getServletRequest() .getAttribute(CDI_REQ_CONTEXT); contextControl.stopContext(RequestScoped.class); }
ctxCtrl.stopContext(ConversationScoped.class); ctxCtrl.stopContext(RequestScoped.class); ctxCtrl.stopContext(SessionScoped.class); ctxCtrlBean.destroy(ctxCtrl, ctxCtrlCreationalContext);
ctxCtrl.stopContext(ConversationScoped.class); ctxCtrl.stopContext(RequestScoped.class); ctxCtrl.stopContext(SessionScoped.class); ctxCtrlBean.destroy(ctxCtrl, ctxCtrlCreationalContext);
private void stopStartedScopes(CdiContainer container) { while (!this.startedScopes.empty()) { Class<? extends Annotation> scopeAnnotation = this.startedScopes.pop(); //TODO check if context was started by parent try { container.getContextControl().stopContext(scopeAnnotation); onScopeStopped(scopeAnnotation); } catch (RuntimeException e) { Logger logger = Logger.getLogger(CdiCucumberTestRunner.class.getName()); logger.setLevel(Level.SEVERE); logger.log(Level.SEVERE, "failed to stop scope @" + scopeAnnotation.getName(), e); } } }
private void stopStartedScopes() { if (this.contextControl == null) { return; } while (!this.scopes.empty()) { this.contextControl.get().stopContext(this.scopes.pop()); } this.contextControl.destroy(); } }
private void stopStartedScopes(CdiContainer container) { try { automaticScopeHandlingActive.set(TRUE); while (!this.startedScopes.empty()) { Class<? extends Annotation> scopeAnnotation = this.startedScopes.pop(); //TODO check if context was started by parent try { container.getContextControl().stopContext(scopeAnnotation); onScopeStopped(scopeAnnotation); } catch (RuntimeException e) { Logger logger = Logger.getLogger(CdiTestRunner.class.getName()); logger.setLevel(Level.SEVERE); logger.log(Level.SEVERE, "failed to stop scope @" + scopeAnnotation.getName(), e); } } } finally { automaticScopeHandlingActive.remove(); automaticScopeHandlingActive.set(null); } }
@Override public void stopContext(Class<? extends Annotation> scopeClass) { wrapped.stopContext(scopeClass); if (isManuallyHandledRequest(scopeClass)) { for (ExternalContainer externalContainer : CdiTestRunner.getActiveExternalContainers()) { externalContainer.stopScope(scopeClass); } } }
@Override public void run() { try { contextControl.startContext(SessionScoped.class); contextControl.startContext(RequestScoped.class); 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); for (int i = 0; i < 100000; i++) { // we need the threads doing something ;) Assert.assertNotNull(carRepair.getCar()); Assert.assertNotNull(carRepair.getCar().getUser()); Assert.assertNull(carRepair.getCar().getUser().getName()); } contextControl.stopContext(RequestScoped.class); contextControl.stopContext(SessionScoped.class); } catch (Throwable e) { log.log(Level.SEVERE, "An exception happened on a new worker thread", e); numErrors.incrementAndGet(); } } };
contextControl.stopContext(scopeAnnotation);
contextControl.stopContext(scopeAnnotation);
Assert.assertEquals("tck-tester", testUser.getName()); cdiContainer.getContextControl().stopContext(RequestScoped.class); cdiContainer.getContextControl().startContext(RequestScoped.class);