public ConversationProducer(AnnotatedType<ConversationImpl> annotatedType, WebBeansContext webBeansContext) { super(annotatedType, Collections.<InjectionPoint>emptySet(), webBeansContext, null, null); this.contextsService = webBeansContext.getContextsService(); }
@Override public void deactivate() throws ContextNotActiveException { if (startParam != null) { context.getContextsService().endContext(RequestScoped.class, startParam); startParam = null; } } }
@Override public void init(FilterConfig filterConfig) throws ServletException { contextsService = WebBeansContext.currentInstance().getContextsService(); }
private ContextsService getContextsService() { WebBeansContext webBeansContext = WebBeansContext.currentInstance(); return webBeansContext.getContextsService(); }
/** * Default constructor */ public WebBeansConfigurationListener() { webBeansContext = WebBeansContext.getInstance(); contextsService = webBeansContext.getContextsService(); }
@Override public void beforeStartApplication(Object object) { webBeansContext.getContextsService().startContext(Singleton.class, null); webBeansContext.getContextsService().startContext(ApplicationScoped.class, null); }
@Override protected void afterStartApplication(Object startupObject) { // the ApplicationContext is already started, but we fire // the event again as the userland beans are only available now webBeansContext.getBeanManagerImpl().fireContextLifecyleEvent( new Object(), InitializedLiteral.INSTANCE_APPLICATION_SCOPED); webBeansContext.getContextsService().startContext(RequestScoped.class, null); webBeansContext.getContextsService().startContext(SessionScoped.class, null); webBeansContext.getContextsService().startContext(ConversationScoped.class, null); }
/** * Remove the given ConversationContext from the SessionContext storage. * This method usually will get called at {@link Conversation#end()} or during cleanup. * Not that this does <b>not</b> destroy the ConversationContext! * @return {@code true} if the conversationContext got removed */ public boolean removeConversationFromStorage(ConversationContext conversationContext) { Context sessionContext = webBeansContext.getContextsService().getCurrentContext(SessionScoped.class); Set<ConversationContext> sessionConversations = getSessionConversations(sessionContext, true); return sessionConversations.remove(conversationContext); }
@Override public void startApplicationScope() throws Exception { logger.log(Level.FINE, "starting the OWB ApplicationContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(ApplicationScoped.class, servletContext); }
@Override public void startRequestScope() throws Exception { logger.log(Level.FINE, "starting the OWB RequestContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(RequestScoped.class, null); }
@Override public void startSessionScope() throws Exception { logger.log(Level.FINE, "starting the OWB SessionContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(SessionScoped.class, session); }
@Override public void stopSessionScope() throws Exception { logger.log(Level.FINE, "stopping the OWB SessionContext"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.endContext(SessionScoped.class, session); }
@Override public void afterEach(final ExtensionContext extensionContext) { ofNullable(extensionContext.getStore(NAMESPACE).get(Holder.class, Holder.class)).map(h -> h.scopes).ifPresent(scopes -> { final ContextsService contextsService = WebBeansContext.currentInstance().getContextsService(); final List<Class<? extends Annotation>> list = new ArrayList<>(asList(scopes)); Collections.reverse(list); list.forEach(s -> contextsService.endContext(s, null)); }); }
private void ensureRequestScope() { final Context reqCtx = webBeansContext.getContextsService().getCurrentContext(RequestScoped.class); if (reqCtx == null || !webBeansContext.getContextsService().getCurrentContext(RequestScoped.class).isActive()) { requestInitialized(null); EndWebBeansListener.FAKE_REQUEST.set(true); } }
/** * {@inheritDoc} */ public void sessionDestroyed(HttpSessionEvent event) { if (logger.wblWillLogDebug()) { logger.debug("Destroying a session with session id : [{0}]", event.getSession().getId()); } this.webBeansContext.getContextsService().endContext(SessionScoped.class, event.getSession()); ConversationManager conversationManager = webBeansContext.getConversationManager(); conversationManager.destroyConversationContextWithSessionId(event.getSession().getId()); }
@Override public void beforeEach(final ExtensionContext extensionContext) { getScopes(extensionContext).ifPresent(scopes -> { final ContextsService contextsService = WebBeansContext.currentInstance().getContextsService(); Stream.of(scopes).forEach(s -> contextsService.startContext(s, null)); extensionContext.getStore(NAMESPACE).put(Holder.class, new Holder(scopes)); }); }
@Override public void startContexts() throws Exception { logger.log(Level.FINE, "starting all OWB Contexts"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(Singleton.class, servletContext); contextsService.startContext(ApplicationScoped.class, servletContext); contextsService.startContext(SessionScoped.class, session); contextsService.startContext(ConversationScoped.class, null); contextsService.startContext(RequestScoped.class, null); }
@Override public void stopContexts() throws Exception { logger.log(Level.FINE, "stopping all OWB Contexts"); WebBeansContext webBeansContext = WebBeansContext.currentInstance(); ContextsService contextsService = webBeansContext.getContextsService(); stopSessionScope(); stopConversationScope(); stopRequestScope(); stopApplicationScope(); contextsService.endContext(Singleton.class, null); }
public OpenEJBLifecycle(final WebBeansContext webBeansContext) { this.webBeansContext = webBeansContext; beforeInitApplication(null); this.beanManager = webBeansContext.getBeanManagerImpl(); this.xmlDeployer = new WebBeansXMLConfigurator(); this.deployer = new BeansDeployer(this.xmlDeployer, webBeansContext); this.jndiService = webBeansContext.getService(JNDIService.class); this.beanManager.setXMLConfigurator(this.xmlDeployer); this.scannerService = webBeansContext.getScannerService(); this.contextsService = webBeansContext.getContextsService(); initApplication(null); }
@Override public void beforeStartApplication(Object object) { this.mockHttpSession = new MockHttpSession(); this.servletContextEvent = new MockServletContextEvent(); WebBeansContext webBeansContext = getWebBeansContext(); ContextsService contextsService = webBeansContext.getContextsService(); contextsService.startContext(RequestScoped.class, null); contextsService.startContext(SessionScoped.class, mockHttpSession); contextsService.startContext(ConversationScoped.class, null); contextsService.startContext(ApplicationScoped.class, this.servletContextEvent.getServletContext()); }