@Override public boolean destroy(HttpSession session) { if (isAssociated()) { checkContextInitialized(); } return super.destroy(session); }
@Override public void deactivate() { try { if (isInitialized()) { try { super.deactivate(); } finally { this.initialized.set(null); } } else { // Only deactivate the context, i.e. remove state threadlocal removeState(); } } finally { this.transientConversationInitializationCallback.set(null); } }
/** * * @param transientConversationInitializationCallback This callback will be executed during initialization */ public void activateLazily(Consumer<HttpServletRequest> transientConversationInitializationCallback) { activate(); // Always set the callback - the deactivation might not be performed properly this.transientConversationInitializationCallback.set(transientConversationInitializationCallback); }
@Override public void activate() { if (!isAssociated()) { throw ConversationLogger.LOG.mustCallAssociateBeforeActivate(); } if (!isActive()) { super.setActive(true); } else { ConversationLogger.LOG.contextAlreadyActive(getRequest()); } // Reset the initialized flag - a thread which is not cleaned up properly (e.g. async processing on // Tomcat) may break the lazy initialization otherwise this.initialized.set(null); }
@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)); } }
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 protected void initialize(String cid) { this.initialized.set(Boolean.TRUE); super.initialize(cid); }
@Override public void activate() { if (!isAssociated()) { throw ConversationLogger.LOG.mustCallAssociateBeforeActivate(); } if (!isActive()) { super.setActive(true); } else { ConversationLogger.LOG.contextAlreadyActive(getRequest()); } // Reset the initialized flag - a thread which is not cleaned up properly (e.g. async processing on // Tomcat) may break the lazy initialization otherwise this.initialized.set(null); }
@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 destroy(HttpSession session) { if (isAssociated()) { checkContextInitialized(); } return super.destroy(session); }
private void deactivateSessionDestructionContext(HttpSession session) { HttpSessionDestructionContext context = getSessionDestructionContext(); if (context.isActive()) { context.deactivate(); context.dissociate(session); } }
@Override public void deactivate() { try { if (isInitialized()) { try { super.deactivate(); } finally { this.initialized.set(null); } } else { // Only deactivate the context, i.e. remove state threadlocal removeState(); } } finally { this.transientConversationInitializationCallback.set(null); } }
@Override public boolean associate(HttpSession session) { if (getBeanStore() == null) { // Don't reassociate setBeanStore(new EagerSessionBeanStore(namingScheme, session, getServiceRegistry())); return true; } else { return false; } }
/** * * @param transientConversationInitializationCallback This callback will be executed during initialization */ public void activateLazily(Consumer<HttpServletRequest> transientConversationInitializationCallback) { activate(); // Always set the callback - the deactivation might not be performed properly this.transientConversationInitializationCallback.set(transientConversationInitializationCallback); }
@Override protected void initialize(String cid) { this.initialized.set(Boolean.TRUE); super.initialize(cid); }
@Override public boolean destroy(HttpSession session) { if (isAssociated()) { checkContextInitialized(); } return super.destroy(session); }
private void deactivateSessionDestructionContext(HttpSession session) { HttpSessionDestructionContext context = getSessionDestructionContext(); if (context.isActive()) { context.deactivate(); context.dissociate(session); } }
/** * * @param transientConversationInitializationCallback This callback will be executed during initialization */ public void activateLazily(Consumer<HttpServletRequest> transientConversationInitializationCallback) { activate(); // Always set the callback - the deactivation might not be performed properly this.transientConversationInitializationCallback.set(transientConversationInitializationCallback); }
@Override protected void initialize(String cid) { this.initialized.set(Boolean.TRUE); super.initialize(cid); }