Class AbstractConversationContext<R,​S>

  • All Implemented Interfaces:
    jakarta.enterprise.context.spi.AlterableContext, jakarta.enterprise.context.spi.Context, org.jboss.weld.context.BoundContext<R>, org.jboss.weld.context.ConversationContext, org.jboss.weld.context.ManagedContext, org.jboss.weld.context.WeldAlterableContext
    Direct Known Subclasses:
    BoundConversationContextImpl

    public abstract class AbstractConversationContext<R,​S>
    extends AbstractBoundContext<R>
    implements org.jboss.weld.context.ConversationContext
    The base of the conversation context, which can use a variety of storage forms
    Author:
    Pete Muir, Jozef Hartinger, George Sapountzis, Marko Luksa
    • Field Detail

      • CONVERSATIONS_ATTRIBUTE_NAME

        public static final String CONVERSATIONS_ATTRIBUTE_NAME
      • DESTRUCTION_QUEUE_ATTRIBUTE_NAME

        public static final String DESTRUCTION_QUEUE_ATTRIBUTE_NAME
    • Constructor Detail

      • AbstractConversationContext

        public AbstractConversationContext​(String contextId,
                                           org.jboss.weld.bootstrap.api.ServiceRegistry services)
    • Method Detail

      • getParameterName

        public String getParameterName()
        Specified by:
        getParameterName in interface org.jboss.weld.context.ConversationContext
      • setParameterName

        public void setParameterName​(String cid)
        Specified by:
        setParameterName in interface org.jboss.weld.context.ConversationContext
      • setConcurrentAccessTimeout

        public void setConcurrentAccessTimeout​(long timeout)
        Specified by:
        setConcurrentAccessTimeout in interface org.jboss.weld.context.ConversationContext
      • getConcurrentAccessTimeout

        public long getConcurrentAccessTimeout()
        Specified by:
        getConcurrentAccessTimeout in interface org.jboss.weld.context.ConversationContext
      • setDefaultTimeout

        public void setDefaultTimeout​(long timeout)
        Specified by:
        setDefaultTimeout in interface org.jboss.weld.context.ConversationContext
      • getDefaultTimeout

        public long getDefaultTimeout()
        Specified by:
        getDefaultTimeout in interface org.jboss.weld.context.ConversationContext
      • associate

        public boolean associate​(R request)
        Specified by:
        associate in interface org.jboss.weld.context.BoundContext<R>
      • dissociate

        public boolean dissociate​(R request)
        Specified by:
        dissociate in interface org.jboss.weld.context.BoundContext<R>
        Overrides:
        dissociate in class AbstractBoundContext<R>
      • copyConversationIdGeneratorAndConversationsToSession

        protected void copyConversationIdGeneratorAndConversationsToSession()
      • sessionCreated

        public void sessionCreated()
      • associateRequestWithNewConversation

        protected void associateRequestWithNewConversation()
      • associateRequest

        protected void associateRequest​(org.jboss.weld.context.ManagedConversation conversation)
      • 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 AbstractBoundContext<R>
      • activate

        public void activate​(String cid)
        Specified by:
        activate in interface org.jboss.weld.context.ConversationContext
      • initialize

        protected void initialize​(String cid)
      • deactivate

        public void deactivate()
        Specified by:
        deactivate in interface org.jboss.weld.context.ManagedContext
        Overrides:
        deactivate in class AbstractBoundContext<R>
      • conversationPromotedToLongRunning

        public void conversationPromotedToLongRunning​(ConversationImpl conversation)
      • invalidate

        public void invalidate()
        Specified by:
        invalidate in interface org.jboss.weld.context.ConversationContext
        Specified by:
        invalidate in interface org.jboss.weld.context.ManagedContext
        Overrides:
        invalidate in class AbstractManagedContext
      • destroy

        public boolean destroy​(S session)
      • destroyConversation

        protected void destroyConversation​(S session,
                                           String id,
                                           boolean fireEvents)
      • generateConversationId

        public String generateConversationId()
        Specified by:
        generateConversationId in interface org.jboss.weld.context.ConversationContext
      • getConversation

        public org.jboss.weld.context.ManagedConversation getConversation​(String id)
        Specified by:
        getConversation in interface org.jboss.weld.context.ConversationContext
      • getConversations

        public Collection<org.jboss.weld.context.ManagedConversation> getConversations()
        Specified by:
        getConversations in interface org.jboss.weld.context.ConversationContext
      • getCurrentConversation

        public org.jboss.weld.context.ManagedConversation getCurrentConversation()
        Specified by:
        getCurrentConversation in interface org.jboss.weld.context.ConversationContext
      • getScope

        public Class<? extends Annotation> getScope()
        Specified by:
        getScope in interface jakarta.enterprise.context.spi.Context
      • setSessionAttribute

        protected abstract void setSessionAttribute​(R request,
                                                    String name,
                                                    Object value,
                                                    boolean create)
        Set an attribute in the session.
        Parameters:
        request - the request to set the session attribute in
        name - the name of the attribute
        value - the value of the attribute
        create - if false, the attribute will only be set if the session already exists, otherwise it will always be set
        Throws:
        IllegalStateException - if create is true, and the session can't be created
      • getSessionAttribute

        protected abstract Object getSessionAttribute​(R request,
                                                      String name,
                                                      boolean create)
        Get an attribute value from the session.
        Parameters:
        request - the request to get the session attribute from
        name - the name of the attribute
        create - if false, the attribute will only be retrieved if the session already exists, other wise it will always be retrieved
        Returns:
        attribute
        Throws:
        IllegalStateException - if create is true, and the session can't be created
      • getSessionAttributeFromSession

        protected abstract Object getSessionAttributeFromSession​(S session,
                                                                 String name)
        Get an attribute value from the session.
        Parameters:
        session - the session to get the session attribute from
        name - the name of the attribute
        Returns:
        attribute
        Throws:
        IllegalStateException - if create is true, and the session can't be created
      • removeRequestAttribute

        protected abstract void removeRequestAttribute​(R request,
                                                       String name)
        Remove an attribute from the request.
        Parameters:
        request - the request to remove the attribute from
        name - the name of the attribute
      • setRequestAttribute

        protected abstract void setRequestAttribute​(R request,
                                                    String name,
                                                    Object value)
        Set an attribute in the request.
        Parameters:
        request - the request to set the attribute from
        name - the name of the attribute
        value - the value of the attribute
      • getRequestAttribute

        protected abstract Object getRequestAttribute​(R request,
                                                      String name)
        Retrieve an attribute value from the request
        Parameters:
        request - the request to get the attribute from
        name - the name of the attribute to get
        Returns:
        the value of the attribute
      • getSessionFromRequest

        protected abstract S getSessionFromRequest​(R request,
                                                   boolean create)
      • getNamingSchemePrefix

        protected abstract String getNamingSchemePrefix()
      • isAssociated

        protected boolean isAssociated()
        Check if the context is currently associated
        Returns:
        true if the context is associated
      • getRequest

        protected R getRequest()
        Get the associated store
        Returns:
        the request
      • getSessionAttributeNames

        protected abstract Iterator<String> getSessionAttributeNames​(S session)