Class LazyHttpConversationContextImpl

All Implemented Interfaces:
jakarta.enterprise.context.spi.AlterableContext, jakarta.enterprise.context.spi.Context, org.jboss.weld.context.BoundContext<jakarta.servlet.http.HttpServletRequest>, org.jboss.weld.context.ConversationContext, org.jboss.weld.context.http.HttpConversationContext, org.jboss.weld.context.ManagedContext, org.jboss.weld.context.WeldAlterableContext

public class LazyHttpConversationContextImpl extends HttpConversationContextImpl
An implementation of HttpConversationContext that is capable of lazy initialization. By default, the context is associated with a request and the active flag is set to true in the beginning of the request processing but the context is not initialized (cid not read and the state not restored) until the conversation context is first accessed. As a result, BusyConversationException or NonexistentConversationException may be thrown late in the request processing and any component invoking methods on ConversationScoped beans should be ready to catch these exceptions. Lazy initialization is mostly a workaround for https://issues.jboss.org/browse/CDI-411.
Author:
Jozef Hartinger
  • Constructor Details

    • LazyHttpConversationContextImpl

      public LazyHttpConversationContextImpl(String contextId, org.jboss.weld.bootstrap.api.ServiceRegistry services)
  • Method Details

    • activateLazily

      public void activateLazily(Consumer<jakarta.servlet.http.HttpServletRequest> transientConversationInitializationCallback)
      Parameters:
      transientConversationInitializationCallback - This callback will be executed during initialization
    • activate

      public void activate()
      Specified by:
      activate in interface org.jboss.weld.context.ConversationContext
      Specified by:
      activate in interface org.jboss.weld.context.ManagedContext
      Overrides:
      activate in class AbstractConversationContext<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpSession>
    • isInitialized

      public boolean isInitialized()
    • initialize

      protected void initialize(String cid)
      Overrides:
      initialize in class AbstractConversationContext<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpSession>
    • deactivate

      public void deactivate()
      Specified by:
      deactivate in interface org.jboss.weld.context.ManagedContext
      Overrides:
      deactivate in class AbstractConversationContext<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpSession>
    • destroy

      public boolean destroy(jakarta.servlet.http.HttpSession session)
      Specified by:
      destroy in interface org.jboss.weld.context.http.HttpConversationContext
      Overrides:
      destroy in class AbstractConversationContext<jakarta.servlet.http.HttpServletRequest,jakarta.servlet.http.HttpSession>
    • checkContextInitialized

      protected void checkContextInitialized()
      Overrides:
      checkContextInitialized in class AbstractContext