public synchronized ConversationEntry updateConversationId(String oldId, String newId) { ConversationEntry entry = conversationIdEntryMap.remove(oldId); if (entry==null) { return null; } else { entry.setId(newId); entry.getConversationIdStack().set(0, newId); conversationIdEntryMap.put(newId, entry); setDirty(); return entry; } }
public synchronized ConversationEntry createConversationEntry(String id, List<String> stack) { ConversationEntry entry = new ConversationEntry(id, stack, this); conversationIdEntryMap.put(id, entry); setDirty(); return entry; }
private void endNestedConversations(String id) { for ( ConversationEntry ce: ConversationEntries.instance().getConversationEntries() ) { if ( ce.getConversationIdStack().contains(id) ) { ce.end(); } } }
public boolean isDisplayable() { return !isEnded() && !isRemoveAfterRedirect() && getDescription()!=null; }
public int compareTo(ConversationEntry entry) { int result = new Long ( getLastRequestTime() ).compareTo( entry.getLastRequestTime() ); return - ( result==0 ? getId().compareTo( entry.getId() ) : result ); }
return false; else if ( ce.lock() ) touchConversationStack( ce.getConversationIdStack() ); log.debug("Restoring conversation with id: " + ce.getId()); setLongRunningConversation(true); setCurrentConversationId( ce.getId() ); setCurrentConversationIdStack( ce.getConversationIdStack() ); boolean removeAfterRedirect = ce.isRemoveAfterRedirect() && !Pages.isDebugPage(); //TODO: hard dependency to JSF!! if (removeAfterRedirect) ce.setRemoveAfterRedirect(false);
for (ConversationEntry conversationEntry: entries) boolean locked = conversationEntry.lockNoWait(); //we had better not wait for it, or we would be waiting for ALL other requests try long delta = currentTime - conversationEntry.getLastRequestTime(); if ( delta > conversationEntry.getTimeout() ) log.debug("conversation timeout for conversation: " + conversationEntry.getId()); log.debug("destroying conversation with garbage lock: " + conversationEntry.getId()); Events.instance().raiseEvent(EVENT_CONVERSATION_TIMEOUT, conversationEntry.getId()); destroyConversation( conversationEntry.getId(), session ); if (locked) conversationEntry.unlock();
private String getConversationPropagationSuffix() { String suffix = ""; if (!conversationManager.getCurrentConversationEntry().isNested()) { String cId = conversationManager.getCurrentConversationId(); // tmp hack to handle the case when the logo is rendered // just after the page existed the conversation cId = getLastOrMainConversationId(cId); suffix += conversationManager.getConversationIdParameter() + '=' + cId; /** * if (conversationManager.isLongRunningConversation()) { suffix += '&' + * conversationManager.getConversationIsLongRunningParameter() + "true"; lastMainConversation = cId; } **/ } else { ConversationEntry conv = conversationManager.getCurrentConversationEntry(); String convId = conv.getConversationIdStack().get(0); convId = getLastOrMainConversationId(convId); suffix += conversationManager.getConversationIdParameter() + '=' + convId; /** * suffix += '&' + conversationManager.getConversationIsLongRunningParameter() + "true"; * lastMainConversation = convId; **/ } return suffix; }
private void destroyNestedConversationContexts(Map<String, Object> session, String conversationId) { List<ConversationEntry> entries = new ArrayList<ConversationEntry>( ConversationEntries.instance().getConversationEntries() ); for ( ConversationEntry ce: entries ) { if ( ce.getConversationIdStack().contains(conversationId) ) { String entryConversationId = ce.getId(); log.debug("destroying nested conversation: " + entryConversationId); destroyConversation(entryConversationId, session); } } }
private ConversationEntry createConversationEntry() { ConversationEntry entry = ConversationEntries.instance() .createConversationEntry( getCurrentConversationId(), getCurrentConversationIdStack() ); if ( !entry.isNested() ) { //if it is a newly created nested //conversation, we already own the //lock entry.lock(); } return entry; }
@Create public void createSelectItems() { ConversationEntries conversationEntries = ConversationEntries.getInstance(); if (conversationEntries==null) { selectItems = Collections.EMPTY_LIST; } else { Set<ConversationEntry> orderedEntries = new TreeSet<ConversationEntry>(); orderedEntries.addAll( conversationEntries.getConversationEntries() ); selectItems = new ArrayList<SelectItem>( conversationEntries.size() ); for ( ConversationEntry entry: orderedEntries ) { if ( entry.isDisplayable() && !Session.instance().isInvalid() ) { selectItems.add( new SelectItem( entry.getId(), entry.getDescription() ) ); } } } }
List<String> idStack = currentConversationEntry.getConversationIdStack(); List<ConversationEntry> conversationEntryStack = new ArrayList<ConversationEntry>( conversationEntries.size() ); ListIterator<String> ids = idStack.listIterator( idStack.size() ); if ( entry.isDisplayable() && !Session.instance().isInvalid() )
conversationEntry.getId())) + conversationEntry.getId()); boolean locked = conversationEntry.lockNoWait(); // we had better log.debug("conversation killed manually: " + conversationEntry.getId()); + conversationEntry.getId()); destroyConversation(conversationEntry.getId(), getSessionMap()); conversationEntry.unlock();
if (ce!=null) if ( ce.lock() ) setCurrentConversationIdStack( ce.getConversationIdStack() ); if (promote)
public String select() { boolean isOutcome = conversationIdOrOutcome==null || (!Character.isDigit(conversationIdOrOutcome.charAt(0)) && conversationIdOrOutcome.indexOf(':') < 0); String actualOutcome; if (isOutcome) { resultingConversationIdOrOutcome = conversationIdOrOutcome; actualOutcome = conversationIdOrOutcome; } else { ConversationEntry ce = ConversationEntries.instance().getConversationEntry(conversationIdOrOutcome); if (ce!=null) { resultingConversationIdOrOutcome = ce.getId(); ce.redirect(); } actualOutcome = null; } return actualOutcome; }
setCurrentConversationIdStack( ce.getConversationIdStack() );
public boolean lock() //not synchronized! { try { return lock.tryLock( getConcurrentRequestTimeout(), TimeUnit.MILLISECONDS ); } catch (InterruptedException ie) { throw new RuntimeException(ie); } }
public String getCurrentConversationDescription() { ConversationEntry ce = getCurrentConversationEntry(); if ( ce==null ) return null; return ce.getDescription(); }
public Integer getCurrentConversationTimeout() { ConversationEntry ce = getCurrentConversationEntry(); if ( ce==null ) return null; return ce.getTimeout(); }