@Override public void activateContext(HttpSession httpSession) { HttpSessionContext sessionContext = beanManager.instance().select(HttpSessionContext.class).get(); simulatedHttpRequest.set(new FakeHttpServletRequest(httpSession)); SessionHolder.requestInitialized(simulatedHttpRequest.get()); sessionContext.associate(simulatedHttpRequest.get()); sessionContext.activate(); getOrCreateBeanStore(httpSession); }
@Override public void sessionDestroyed(HttpSessionEvent event) { final ServletContext ctx = event.getSession().getServletContext(); // First try to use the context id obtained from the servlet context (OSGi, Servlet containers, etc.) if (beanManager == null) { synchronized (this) { if (beanManager == null) { String contextId = ctx.getInitParameter(Container.CONTEXT_ID_KEY); if (contextId != null) { List<BeanManagerImpl> managers = new ArrayList<BeanManagerImpl>(Container.instance(contextId).beanDeploymentArchives().values()); Collections.sort(managers, BeanManagers.ID_COMPARATOR); beanManager = managers.get(0); } } // servlet containers may not be able to inject fields in a servlet listener if (beanManager == null) { beanManager = BeanManagerProxy.unwrap(CDI.current().getBeanManager()); } } } if (!getSessionContext().isActive()) { HttpSessionDestructionContext context = getHttpSessionDestructionContext(); context.associate(event.getSession()); context.activate(); } }
@Override public void deactivateContext() { HttpSessionContext sessionContext = beanManager.instance().select(HttpSessionContext.class).get(); SessionHolder.clear(); sessionContext.dissociate(simulatedHttpRequest.get()); }
public void sessionDestroyed(HttpSession session) { // Mark the session context and conversation contexts to destroy // instances when appropriate deactivateSessionDestructionContext(session); boolean destroyed = getSessionContext().destroy(session); SessionHolder.clear(); RequestScopedCache.endRequest(); if (destroyed) { // we are outside of a request (the session timed out) and therefore the session was destroyed immediately // we can fire the @Destroyed(SessionScoped.class) event immediately sessionDestroyedEvent.fire(session); } else { // the old session won't be available at the time we destroy this request // let's store its reference until then if (getRequestContext() instanceof HttpRequestContextImpl) { HttpServletRequest request = Reflections.<HttpRequestContextImpl> cast(getRequestContext()).getHttpServletRequest(); request.setAttribute(HTTP_SESSION, session); } } }
public void sessionDestroyed(HttpSession session) { // Mark the session context and conversation contexts to destroy // instances when appropriate deactivateSessionDestructionContext(session); boolean destroyed = getSessionContext().destroy(session); SessionHolder.clear(); RequestScopedCache.endRequest(); if (destroyed) { // we are outside of a request (the session timed out) and therefore the session was destroyed immediately // we can fire the @Destroyed(SessionScoped.class) event immediately sessionDestroyedEvent.fire(session); } else { // the old session won't be available at the time we destroy this request // let's store its reference until then if (getRequestContext() instanceof HttpRequestContextImpl) { HttpServletRequest request = Reflections.<HttpRequestContextImpl> cast(getRequestContext()).getHttpServletRequest(); request.setAttribute(HTTP_SESSION, session); } } }
public void sessionDestroyed(HttpSession session) { // Mark the session context and conversation contexts to destroy // instances when appropriate deactivateSessionDestructionContext(session); boolean destroyed = getSessionContext().destroy(session); SessionHolder.clear(); RequestScopedCache.endRequest(); if (destroyed) { // we are outside of a request (the session timed out) and therefore the session was destroyed immediately // we can fire the @Destroyed(SessionScoped.class) event immediately sessionDestroyedEvent.fire(session); } else { // the old session won't be available at the time we destroy this request // let's store its reference until then if (getRequestContext() instanceof HttpRequestContextImpl) { HttpServletRequest request = Reflections.<HttpRequestContextImpl> cast(getRequestContext()).getHttpServletRequest(); request.setAttribute(HTTP_SESSION, session); } } }
@Override public void sessionDestroyed(HttpSessionEvent event) { final ServletContext ctx = event.getSession().getServletContext(); // First try to use the context id obtained from the servlet context (OSGi, Servlet containers, etc.) if (beanManager == null) { synchronized (this) { if (beanManager == null) { String contextId = ctx.getInitParameter(Container.CONTEXT_ID_KEY); if (contextId != null) { List<BeanManagerImpl> managers = new ArrayList<BeanManagerImpl>(Container.instance(contextId).beanDeploymentArchives().values()); Collections.sort(managers, BeanManagers.ID_COMPARATOR); beanManager = managers.get(0); } } // servlet containers may not be able to inject fields in a servlet listener if (beanManager == null) { beanManager = BeanManagerProxy.unwrap(CDI.current().getBeanManager()); } } } if (!getSessionContext().isActive()) { HttpSessionDestructionContext context = getHttpSessionDestructionContext(); context.associate(event.getSession()); context.activate(); } }
public void sessionDestroyed(HttpSession session) { // Mark the session context and conversation contexts to destroy // instances when appropriate deactivateSessionDestructionContext(session); boolean destroyed = getSessionContext().destroy(session); SessionHolder.clear(); RequestScopedCache.endRequest(); if (destroyed) { // we are outside of a request (the session timed out) and therefore the session was destroyed immediately // we can fire the @Destroyed(SessionScoped.class) event immediately sessionDestroyedEvent.fire(session); } else { // the old session won't be available at the time we destroy this request // let's store its reference until then if (getRequestContext() instanceof HttpRequestContextImpl) { HttpServletRequest request = Reflections.<HttpRequestContextImpl> cast(getRequestContext()).getHttpServletRequest(); request.setAttribute(HTTP_SESSION, session); } } }
@Override public void sessionDestroyed(HttpSessionEvent event) { final ServletContext ctx = event.getSession().getServletContext(); // First try to use the context id obtained from the servlet context (OSGi, Servlet containers, etc.) if (beanManager == null) { synchronized (this) { if (beanManager == null) { String contextId = ctx.getInitParameter(Container.CONTEXT_ID_KEY); if (contextId != null) { List<BeanManagerImpl> managers = new ArrayList<BeanManagerImpl>(Container.instance(contextId).beanDeploymentArchives().values()); Collections.sort(managers, BeanManagers.ID_COMPARATOR); beanManager = managers.get(0); } } // servlet containers may not be able to inject fields in a servlet listener if (beanManager == null) { beanManager = BeanManagerProxy.unwrap(CDI.current().getBeanManager()); } } } if (!getSessionContext().isActive()) { HttpSessionDestructionContext context = getHttpSessionDestructionContext(); context.associate(event.getSession()); context.activate(); } }
@Override public void sessionDestroyed(HttpSessionEvent event) { final ServletContext ctx = event.getSession().getServletContext(); // First try to use the context id obtained from the servlet context (OSGi, Servlet containers, etc.) if (beanManager == null) { synchronized (this) { if (beanManager == null) { String contextId = ctx.getInitParameter(Container.CONTEXT_ID_KEY); if (contextId != null) { List<BeanManagerImpl> managers = new ArrayList<BeanManagerImpl>(Container.instance(contextId).beanDeploymentArchives().values()); Collections.sort(managers, BeanManagers.ID_COMPARATOR); beanManager = managers.get(0); } } // servlet containers may not be able to inject fields in a servlet listener if (beanManager == null) { beanManager = BeanManagerProxy.unwrap(CDI.current().getBeanManager()); } } } if (!getSessionContext().isActive()) { HttpSessionDestructionContext context = getHttpSessionDestructionContext(); context.associate(event.getSession()); context.activate(); } }