public static void startContexts(final ContextsService contextsService, final ServletContext servletContext, final HttpSession session) throws Exception { contextsService.startContext(Singleton.class, null); contextsService.startContext(ApplicationScoped.class, null); contextsService.startContext(SessionScoped.class, session); contextsService.startContext(RequestScoped.class, null); contextsService.startContext(ConversationScoped.class, null); }
@Override public void requestDestroyed(final ServletRequestEvent sre) { owb.endContext(RequestScoped.class, sre); } }
@Override public boolean activate() { if (startParam != null) { return false; } Context ctx = context.getContextsService().getCurrentContext(RequestScoped.class); if (ctx == null) { startParam = new Object(); context.getContextsService().startContext(RequestScoped.class, startParam); return true; } return false; }
@Override public void evaluate() throws Throwable { final ContextsService contextsService = WebBeansContext.currentInstance().getContextsService(); try { scopes.forEach(s -> contextsService.startContext(s, null)); base.evaluate(); } finally { Collections.reverse(scopes); scopes.forEach(s -> contextsService.endContext(s, null)); Collections.reverse(scopes); } } };
webBeansContext.getContextsService().endContext(RequestScoped.class, endObject); webBeansContext.getContextsService().endContext(ConversationScoped.class, endObject); webBeansContext.getContextsService().endContext(SessionScoped.class, endObject); webBeansContext.getContextsService().endContext(ApplicationScoped.class, endObject); webBeansContext.getContextsService().endContext(Singleton.class, endObject); this.contextsService.destroy(endObject);
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { // just touch the conversation. contextsService.getCurrentContext(ConversationScoped.class, true); // otherwise business as usual... chain.doFilter(request, response); }
contextsService.destroy(endObject);
contextsService.init(startupObject);
public void withRequestContext(final ServletRequest requestContext, final Runnable task) { final ServletRequestEvent event = new ServletRequestEvent(requestContext.getServletContext(), requestContext); final ContextsService service = context.getContextsService(); service.startContext(RequestScoped.class, event); try { task.run(); } finally { service.endContext(RequestScoped.class, event); } }
public static void ensureRequestScope(final ContextsService cs, final ServletRequestListener listener) { final Context reqCtx = cs.getCurrentContext(RequestScoped.class); if (reqCtx == null || !cs.getCurrentContext(RequestScoped.class).isActive()) { listener.requestInitialized(null); FAKE_REQUEST.set(true); } }
public void stop() throws OpenEJBException { final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); try { // Setting context class loader for cleaning Thread.currentThread().setContextClassLoader(classLoader); // Fire shut down webBeansContext.getBeanManagerImpl().fireEvent(new BeforeShutdownImpl()); // Destroys context webBeansContext.getContextsService().destroy(null); // Free all plugin resources webBeansContext.getPluginLoader().shutDown(); // Clear extensions webBeansContext.getExtensionLoader().clear(); // Delete Resolutions Cache webBeansContext.getBeanManagerImpl().getInjectionResolver().clearCaches(); // Delete AnnotateTypeCache webBeansContext.getAnnotatedElementFactory().clear(); // Clear the resource injection service final CdiResourceInjectionService injectionServices = (CdiResourceInjectionService) webBeansContext.getService(ResourceInjectionService.class); injectionServices.clear(); // Clear singleton list WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader()); } catch (final Exception e) { throw new OpenEJBException(e); } finally { Thread.currentThread().setContextClassLoader(oldCl); } }
this.contextsService.init(startupObject);
public static void startContexts(final ContextsService contextsService, final ServletContext servletContext, final HttpSession session) throws Exception { contextsService.startContext(SessionScoped.class, session); contextsService.startContext(RequestScoped.class, null); contextsService.startContext(ConversationScoped.class, null); }
public static void stopContexts(final ContextsService contextsService, final ServletContext servletContext, final HttpSession session) throws Exception { contextsService.endContext(Singleton.class, null); contextsService.endContext(ApplicationScoped.class, null); contextsService.endContext(SessionScoped.class, session); contextsService.endContext(RequestScoped.class, null); contextsService.endContext(ConversationScoped.class, null); if (CdiAppContextsService.class.isInstance(contextsService)) { CdiAppContextsService.class.cast(contextsService).removeThreadLocals(); } } }
@Override public void evaluate() throws Throwable { final ContextsService contextsService = WebBeansContext.currentInstance().getContextsService(); try { scopes.forEach(s -> contextsService.startContext(s, null)); base.evaluate(); } finally { Collections.reverse(scopes); scopes.forEach(s -> contextsService.endContext(s, null)); Collections.reverse(scopes); } } };
@Override public void contextEntered(final ThreadContext oldContext, final ThreadContext newContext) { final BeanContext beanContext = newContext.getBeanContext(); final WebBeansContext webBeansContext = beanContext.getModuleContext().getAppContext().getWebBeansContext(); if (webBeansContext == null) { return; } final ContextsService contextsService = webBeansContext.getContextsService(); final Context requestContext = contextsService.getCurrentContext(RequestScoped.class); if (requestContext == null) { contextsService.startContext(RequestScoped.class, null); newContext.set(DestroyContext.class, new DestroyContext(contextsService, newContext)); } }
/** * 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); }
this.contextsService.destroy(null);
contextsService.init(startupObject); // fire app event and also starts SingletonContext and ApplicationContext } catch (final Exception e1) { SystemInstance.get().getComponent(Assembler.class).logger.error("CDI Beans module deployment failed", e1);
@Override public void requestInitialized(final ServletRequestEvent sre) { owb.startContext(RequestScoped.class, sre); }