[weld-dev] A ConversationManager API

Pete Muir pmuir at redhat.com
Fri Jan 29 11:41:59 EST 2010


Otherwise comments in line.

On 29 Jan 2010, at 07:56, Nicklas Karlsson wrote:

> Hi,
> 
>    There has been many requests for a standard ConversationManager
> API that could be used by other frameworks (SE, GraniteDS, Seam
> Remoting etc) so there was a short brainstorming session and we came
> up with the following proposal on which I now request your feedback.
> 
> public interface ConversationManager
> {
>   /**
>    * Activates the conversation context
>    *
>    * @return The conversation manager
>    * @throws IllegalStateException if the context is already active
>    */
>   public abstract ConversationManager activateContext();
> 
>   /**
>    * Deactivates the conversation context
>    *
>    * @return The conversation manager
>    * @throws IllegalStateException if the context is already deactivated
>    */
>   public abstract ConversationManager deactivateContext();
> 
>   /**
>    * Checks the state of the conversation context
>    *
>    * @return true if the conversation context is active, false otherwise
>    */
>   public abstract boolean isContextActive();
> 
>   /**
>    * Starts a new, transient conversation
>    *
>    * @return The conversation manager
>    * @throws IllegalStateException if there is already an active
> conversation or if the conversation context is not active
>    */
>   public abstract ConversationManager createTransientConversation();
> 
>   /**
>    * Ends the current transient conversation
>    *
>    * @return The conversation manager
>    * @throws IllegalStateException if the current transaction is not
> transient or if the conversation context is not active
>    */
>   public abstract ConversationManager endTransientConversation();

I wonder if this should be destroy, not end to preserve the semantics of end as demoting a conversation

> 
>   /**
>    * Restores a long-running conversation.
>    *
>    * @param cid The id of the conversation to restore
>    * @return The conversation manager
>    * @throws NonexistentConversationException if the conversation id
> is null or not a known long-running conversation
>    * @throws IllegalStateException if there already an active
> conversation or if the conversation context is not active
>    */
>   public abstract ConversationManager restoreConversation(String cid);
> 
>   /**
>    * Marks a long-running conversation transient
>    *
>    * @param cid The id of the conversation to make transient
>    * @return The conversation manager
>    * @throws NonexistentConversationException if the conversation id
> is null or not a known long-running conversation
>    * @throws IllegalStateException if the conversation context is not active
>    */
>   public abstract ConversationManager endConversation(String cid);

I wonder if this is needed, as you can achieve it by restoring the conversation and then calling Conversation.end()... Do you see this as a particularly common use case?

> 
>   /**
>    * Marks all long-running conversations as transient and destroys them
>    *
>    * @return The conversation manager
>    * @throws IllegalStateException if the conversation context is not active
>    */
>   public abstract ConversationManager endAllConversations();

Whats the use case for this?

> 
>   /**
>    * Returns the long-running conversation IDs
>    *
>    * @return The long-running conversations IDs
>    * @throws IllegalStateException if the conversation context is not active
>    */
>   public abstract Set<String> getConversations();

This in the current session right? If so the javadoc should say that :-)

> 
>   /**
>    * Returns a new, unused conversation ID
>    *
>    * @return A new, unused conversation ID
>    * @throws IllegalStateException if the conversation context is not active
>    */
>   public abstract String getNewConversationId();

What is the use case for this?

> 
> 
>   /**
>    * Checks if a conversation ID is in use for any other conversation
> than the current one
>    *
>    * @return True if the conversation ID is in use, false otherwise
>    * @throws IllegalStateException if the conversation context is not active
>    */
>   public abstract boolean isConversationIdInUse(String id);

IMO this should just check if the conversation id is in use regardless of the current conversation. This is a much simpler contract to understand.





More information about the weld-dev mailing list