Class SessionBindingConversationManager

java.lang.Object
org.springframework.webflow.conversation.impl.SessionBindingConversationManager
All Implemented Interfaces:
ConversationManager

public class SessionBindingConversationManager extends Object implements ConversationManager
Simple implementation of a conversation manager that stores conversations in the session attribute map.

Using the maxConversations property, you can limit the number of concurrently active conversations allowed in a single session. If the maximum is exceeded, the conversation manager will automatically end the oldest conversation. The default is 5, which should be fine for most situations. Set it to -1 for no limit. Setting maxConversations to 1 allows easy resource cleanup in situations where there should only be one active conversation per session.

Author:
Erwin Vervaet
  • Constructor Details

    • SessionBindingConversationManager

      public SessionBindingConversationManager()
  • Method Details

    • getSessionKey

      public String getSessionKey()
      Returns the key this conversation manager uses to store conversation data in the session.
      Returns:
      the session key
    • setSessionKey

      public void setSessionKey(String sessionKey)
      Sets the key this conversation manager uses to store conversation data in the session. If multiple session binding conversation managers are used in the same web application to back independent flow executors, this value should be unique among them.
      Parameters:
      sessionKey - the session key
    • getMaxConversations

      public int getMaxConversations()
      Returns the maximum number of allowed concurrent conversations. The default is 5.
    • setMaxConversations

      public void setMaxConversations(int maxConversations)
      Set the maximum number of allowed concurrent conversations. Set to -1 for no limit. The default is 5.
    • getLockTimeoutSeconds

      public int getLockTimeoutSeconds()
      Returns the time period that can elapse before a timeout occurs on an attempt to acquire a conversation lock. The default is 30 seconds.
    • setLockTimeoutSeconds

      public void setLockTimeoutSeconds(int lockTimeoutSeconds)
      Sets the time period that can elapse before a timeout occurs on an attempt to acquire a conversation lock. The default is 30 seconds.
      Parameters:
      lockTimeoutSeconds - the timeout period in seconds
    • beginConversation

      public Conversation beginConversation(ConversationParameters conversationParameters) throws ConversationException
      Description copied from interface: ConversationManager
      Begin a new conversation.
      Specified by:
      beginConversation in interface ConversationManager
      Parameters:
      conversationParameters - descriptive conversation parameters
      Returns:
      a service interface allowing access to the conversation context
      Throws:
      ConversationException - an exception occured
    • getConversation

      public Conversation getConversation(ConversationId id) throws ConversationException
      Description copied from interface: ConversationManager
      Get the conversation with the provided id.

      Implementors should take care to manage conversation identity correctly. Although it is not strictly required to return the same (==) Conversation object every time this method is called with a particular conversation id in a single execution thread, callers will expect to recieve an object that allows them to manipulate the identified conversation. In other words, the following is legal ConversationManager client code:

              ConversationManager manager = ...;
              ConversationId id = ...;
              Conversation conv = manager.getConversation(id);
        conv.lock();
        try {
              Conversation localReference = manager.getConversation(id);
              // no need to lock since conversation 'id' is already locked
              // even though possibly conv != localReference
              localReference.putAttribute("foo", "bar");
              Object foo = conv.getAttribute("foo");
              }
              finally {
                      conv.unlock();
              }
       
      Specified by:
      getConversation in interface ConversationManager
      Parameters:
      id - the conversation id
      Returns:
      the conversation
      Throws:
      NoSuchConversationException - the id provided was invalid
      ConversationException
    • parseConversationId

      public ConversationId parseConversationId(String encodedId) throws ConversationException
      Description copied from interface: ConversationManager
      Parse the string-encoded conversationId into its object form. Essentially, the reverse of ConversationId.toString().
      Specified by:
      parseConversationId in interface ConversationManager
      Parameters:
      encodedId - the encoded id
      Returns:
      the parsed conversation id
      Throws:
      ConversationException - an exception occured parsing the id
    • createConversationContainer

      protected ConversationContainer createConversationContainer()
    • getConversationContainer

      protected final ConversationContainer getConversationContainer()
      Obtain the conversation container from the session. Create a new empty container and add it to the session if no existing container can be found.