private void deactivateSessionDestructionContext(HttpSession session) { HttpSessionDestructionContext context = getSessionDestructionContext(); if (context.isActive()) { context.deactivate(); context.dissociate(session); } }
@Override public boolean associate(HttpSession session) { if (getBeanStore() == null) { // Don't reassociate setBeanStore(new EagerSessionBeanStore(namingScheme, session, getServiceRegistry())); return true; } else { return false; } }
@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 postContextRegistration(PostContextRegistrationContext ctx) { final BeanIdentifierIndex index = ctx.getServices().get(BeanIdentifierIndex.class); final String contextId = ctx.getContextId(); if (Reflections.isClassLoadable(ServletApiAbstraction.SERVLET_CONTEXT_CLASS_NAME, WeldClassLoaderResourceLoader.INSTANCE)) { // Register the Http contexts if not in Set<Annotation> httpQualifiers = ImmutableSet.<Annotation> builder().addAll(Bindings.DEFAULT_QUALIFIERS).add(HttpLiteral.INSTANCE).build(); ctx.addContext(new ContextHolder<HttpSessionContext>(new HttpSessionContextImpl(contextId, index), HttpSessionContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpSessionDestructionContext>(new HttpSessionDestructionContext(contextId, index), HttpSessionDestructionContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpConversationContext>(new LazyHttpConversationContextImpl(contextId, ctx.getServices()), HttpConversationContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpRequestContext>(new HttpRequestContextImpl(contextId), HttpRequestContext.class, httpQualifiers)); } }
@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 postContextRegistration(PostContextRegistrationContext ctx) { final BeanIdentifierIndex index = ctx.getServices().get(BeanIdentifierIndex.class); final String contextId = ctx.getContextId(); if (Reflections.isClassLoadable(ServletApiAbstraction.SERVLET_CONTEXT_CLASS_NAME, WeldClassLoaderResourceLoader.INSTANCE)) { // Register the Http contexts if not in Set<Annotation> httpQualifiers = ImmutableSet.<Annotation> builder().addAll(Bindings.DEFAULT_QUALIFIERS).add(HttpLiteral.INSTANCE).build(); ctx.addContext(new ContextHolder<HttpSessionContext>(new HttpSessionContextImpl(contextId, index), HttpSessionContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpSessionDestructionContext>(new HttpSessionDestructionContext(contextId, index), HttpSessionDestructionContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpConversationContext>(new LazyHttpConversationContextImpl(contextId, ctx.getServices()), HttpConversationContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpRequestContext>(new HttpRequestContextImpl(contextId), HttpRequestContext.class, httpQualifiers)); } }
@Override public boolean associate(HttpSession session) { if (getBeanStore() == null) { // Don't reassociate setBeanStore(new EagerSessionBeanStore(namingScheme, session, getServiceRegistry())); return true; } else { return false; } }
private void deactivateSessionDestructionContext(HttpSession session) { HttpSessionDestructionContext context = getSessionDestructionContext(); if (context.isActive()) { context.deactivate(); context.dissociate(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 postContextRegistration(PostContextRegistrationContext ctx) { final BeanIdentifierIndex index = ctx.getServices().get(BeanIdentifierIndex.class); final String contextId = ctx.getContextId(); if (Reflections.isClassLoadable(ServletApiAbstraction.SERVLET_CONTEXT_CLASS_NAME, WeldClassLoaderResourceLoader.INSTANCE)) { // Register the Http contexts if not in Set<Annotation> httpQualifiers = ImmutableSet.<Annotation> builder().addAll(Bindings.DEFAULT_QUALIFIERS).add(HttpLiteral.INSTANCE).build(); ctx.addContext(new ContextHolder<HttpSessionContext>(new HttpSessionContextImpl(contextId, index), HttpSessionContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpSessionDestructionContext>(new HttpSessionDestructionContext(contextId, index), HttpSessionDestructionContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpConversationContext>(new LazyHttpConversationContextImpl(contextId, ctx.getServices()), HttpConversationContext.class, httpQualifiers)); ctx.addContext(new ContextHolder<HttpRequestContext>(new HttpRequestContextImpl(contextId), HttpRequestContext.class, httpQualifiers)); } }
@Override public boolean associate(HttpSession session) { if (getBeanStore() == null) { // Don't reassociate setBeanStore(new EagerSessionBeanStore(namingScheme, session, getServiceRegistry())); return true; } else { return false; } }
private void deactivateSessionDestructionContext(HttpSession session) { HttpSessionDestructionContext context = getSessionDestructionContext(); if (context.isActive()) { context.deactivate(); context.dissociate(session); } }