<div>Right for the ConversationManager.beginConversation, there is already Conversation.begin. I've been mistaken by the ConversationManager.endConversation of Niklas' proposal.</div><div><br></div>I can maybe explain how we use the currently existing API, and in fact we are relatively happy with what exists today, except for one thing :<div>
<br></div><div>start() {</div><div> ConversatonManager manager = { get from BeanManager };</div><div> manager.beginOrRestoreConversation(cid);</div><div> Conversation conversation = { get from BeanManager };</div>
<div><br></div><div> // Beginning of the ugly part !!</div><div> String cid = ((ConversationImpl)conversation).getUnderlyingId();</div><div> ConversationContext ctx = Container.instance().deploymentServices().get(ContextLifecycle.class).getConversationContext();</div>
<div> ctx.setBeanStore(new ConversationBeanStore(httpSession, cid));</div><div> ctx.setActive(true);</div><div> // End of the ugly part<br><div><br></div><div> if (cid != null && conversation.isTransient()) // Don't remember why I need this, beginOrRestore should be enough</div>
<div> conversation.begin(cid);<br><div>}</div><div><br></div><div>end() {</div><div> ConversationManager manager = { get from BeanManager };</div><div> manager.cleanupConversation();</div><div>}</div><div><br>
</div><div>The main thing is that I would prefer not having to mess with bean stores and contexts, so the manager.activateContext() looks fine. Ideally here what I would like to do (I know, I'm too lazy :-)) : </div>
<div>
<br></div><div><div>start() {</div><div> ConversatonManager manager = { get from BeanManager };</div><div> manager.startupConversation();</div><div><br></div><div> if (cid != null && conversation.isTransient())</div>
<div> conversation.beginOrRestoreConversation(cid);<br></div><div>}</div><div><div><div><br></div><div>end() {</div><div> ConversationManager manager = { get from BeanManager };</div><div> manager.cleanupConversation();</div>
<div>}</div><div><br></div><div>From Flex, there is no need to switch the conversation in a particular request, but getting the list of the currently existing conversations with ConversationManager.getCurrentConversationIds() can be useful.</div>
<div><br></div><div>Finally I really think it's necessary to be able to share a conversation instance between different UIs and use the same ConversationContext implementation for all. We could obviously ship a FlexConversationContext with GraniteDS/CDI but we want to make possible to build applications where a part of the UI uses JSF, another part uses Flex and why not another uses ZK or the iPhone SDK.</div>
<div><br></div><div>William</div><div><br></div></div></div><br><div class="gmail_quote"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let's try it the other way around. I toss you the minimal JSF-centric API and the <b>framework reps of ZK, GraniteDS, SE and Remoting can speak up on what they need more control of along with their usecase</b> then Pete can comment and I just act as a secretary ;-) That way we don't end up with too many "nice to haves" in the API that could be worked around more or less easy.<br>
<br>public interface ConversationManager<div><br>{<br> /**<br> * Checks the state of the conversation context<br> * <br> * @return true if the conversation context is active, false otherwise<br> */<br>
public abstract boolean isContextActive(); <br></div>
// usecase: the conversation checks for active context before running methods<div><br> <br> /**<br> * Activates the conversation context<br> * <br> * @return The conversation manager<br> * <br>
* @throws IllegalStateException if the context is already active<br>
*/ <br> public abstract ConversationManager activateContext();<br></div>// usecase: any non-JSF framework will want to run this themselves<div><br> <br> /**<br> * Deactivates the conversation context<br>
* <br> * @return The conversation manager<br>
* <br></div> * @throws IllegalStateException if the context is already deactive<br> */ <br> public abstract ConversationManager deactivateContext();<br>// usecase: any non-JSF framework will want to run this themselves<br>
<br> /**<br> * Resumes a long running conversation. If the cid is null, nothing is done and the current<br> * transient conversation is resumed<br> * <br> * <br> * @param cid The conversation id to restore<br>
* @return The conversation manager<br> * @throws NonexistentConversationException If the non-transient conversation is not known<br> * @throws BusyConversationException If the conversation is locked and not released while waiting <br>
<div>
* @throws IllegalStateException if the conversation context is not active<br> */<br></div> public abstract ConversationManager beginOrRestoreConversation(String cid);<br>// usecase: start of the conversation lifecycle.<br>
<br> /**<br> * Destroys the current conversation if it's transient. Stores it for conversation <br> * propagation if it's non-transient<br> * <br> * @return<div><br> * @throws IllegalStateException if the conversation context is not active<br>
*/<br></div> public abstract ConversationManager cleanupConversation();<br>// usecase: end of the conversation lifecycle.<br> <br> /**<br> * Gets the current non-transient conversations<br> * <br> * @return The conversations mapped by id<div>
<br>
* @throws IllegalStateException if the conversation context is not active<br> */<br></div> public abstract Map<String, Conversation> getConversations();<br>// usecase: Conversation checks if begin(String) was called with a known cid (no need for a isCidInUse, actually)<br>
<br> /**<br> * Returns a new, session-unique conversation ID<br> * <br> * @return The conversation id<div><br> * @throws IllegalStateException if the conversation context is not active<br> */ <br>
</div> public abstract String generateConversationId();<br>
// usecase: Conversation gets a cid for begin() <br><br>Notice that the begin and end of lifecycle are big chunks. Speak up where you need more granularity. Also speak up if you want fancy switching stuff etc ;-) <b>Re-submit any wishes/suggestions you've done in the past</b> in this thread (method signature + usecase) so we can keep stuff together.<br>
<br>---<br>Nik<br><br>
</blockquote></div><br></div>
</div></div>