/** * * @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 boolean destroy(HttpSession session) { if (isAssociated()) { checkContextInitialized(); } return super.destroy(session); }
@Override protected void checkContextInitialized() { if (!isInitialized()) { HttpServletRequest request = getRequest(); String cid = ConversationContextActivator.determineConversationId(request, getParameterName()); initialize(cid); if (cid == null) { // transient conversation Consumer<HttpServletRequest> callback = transientConversationInitializationCallback.get(); if (callback != null) { callback.accept(request); } } } } }
@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 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); }
if (!lazyConversationContext.isInitialized()) { lazyConversationContext.deactivate(); processDestructionQueue(request); return;
@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 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 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); } }
if (!lazyConversationContext.isInitialized()) { lazyConversationContext.deactivate(); processDestructionQueue(request); return;
@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 protected void checkContextInitialized() { if (!isInitialized()) { HttpServletRequest request = getRequest(); String cid = ConversationContextActivator.determineConversationId(request, getParameterName()); initialize(cid); if (cid == null) { // transient conversation Consumer<HttpServletRequest> callback = transientConversationInitializationCallback.get(); if (callback != null) { callback.accept(request); } } } } }
@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 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); } }
if (!lazyConversationContext.isInitialized()) { lazyConversationContext.deactivate(); processDestructionQueue(request); return;
/** * * @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 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 protected void checkContextInitialized() { if (!isInitialized()) { HttpServletRequest request = getRequest(); String cid = ConversationContextActivator.determineConversationId(request, getParameterName()); initialize(cid); if (cid == null) { // transient conversation Consumer<HttpServletRequest> callback = transientConversationInitializationCallback.get(); if (callback != null) { callback.accept(request); } } } } }
@Override public boolean destroy(HttpSession session) { if (isAssociated()) { checkContextInitialized(); } return super.destroy(session); }