I have fixed a small error in the last version.

@Name("stickyConversationManager")
  | @Scope(ScopeType.SESSION)
  | public class StickyConversationManager
  | {
  |     private Stack<String> conversationStack = new Stack<String>();
  |     
  |     @Logger
  |     private Log log;
  |     
  |     @In(create = true)
  |     @Out
  |     private CartHome cartHome;
  | 
  |     public String stick()
  |     {
  |             Manager manager = Manager.instance(); 
  |             HttpServletRequest httpServletRequest = (HttpServletRequest) 
FacesContext.getCurrentInstance().getExternalContext().getRequest();
  |             String conversationIdRequestParameter = 
httpServletRequest.getParameter(manager.getConversationIdParameter());
  | 
  |             if(! manager.isLongRunningOrNestedConversation())
  |             {
  |                     ConversationEntries conversationEntries = 
ConversationEntries.instance();
  | 
  |                     if(conversationEntries.getConversationEntries().size() 
== 0)
  |                     {
  |                             manager.beginConversation();
  | 
  |                             // the following change to the conversation 
timeout
  |                             // is gone on the next page submission
  |                             Conversation.instance().setTimeout(24 * 60 * 60 
* 1000);
  |                             
conversationStack.push(Conversation.instance().getId());
  |                     }
  |                     else if(conversationIdRequestParameter == null)
  |                     {
  |                             while(conversationStack.size() > 0)
  |                             {
  |                                     ConversationEntry conversationEntry = 
conversationEntries.getConversationEntry(conversationStack.peek());
  |                                     if(conversationEntry != null)
  |                                     {
  |                                             conversationEntry.redirect();
  |                                             break;
  |                                     }
  |                                     else
  |                                     {
  |                                             conversationStack.pop();
  |                                     }
  |                             }
  |                     }
  |             }
  |             else if(manager.isLongRunningConversation())
  |             {
  |                     try
  |                     {
  |                             if(conversationStack.peek() != 
Conversation.instance().getId())
  |                             {
  |                                     
conversationStack.remove(Conversation.instance().getId());
  |                                     
conversationStack.push(Conversation.instance().getId());
  |                             }
  |                     }
  |                     catch(EmptyStackException e){}
  |             }
  | 
  |             log.debug(toString());
  |             return null;
  |     }
  |     
  |     @Override
  |     public String toString()
  |     {
  |             StringBuffer stringBuffer = new StringBuffer();
  |             stringBuffer
  |                     .append("<ConversationManager>")
  |                     .append("<Stack>");
  |             for(String conversationId : conversationStack)
  |             {
  |                     stringBuffer
  |                             .append("<ConversationId>")
  |                             .append(conversationId)
  |                             .append("</ConversationId>");
  |             }
  |             stringBuffer
  |                     .append("</Stack>")
  |                     .append("</ConversationManager>");
  |             return stringBuffer.toString();
  |     }
  | }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4082639#4082639

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4082639
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to