private void cleanUpConversationMap() { Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { Iterator<Entry<String, ManagedConversation>> entryIterator = conversations.entrySet().iterator(); S session = getSessionFromRequest(getRequest(), false); while (entryIterator.hasNext()) { Entry<String, ManagedConversation> entry = entryIterator.next(); if (entry.getValue().isTransient()) { destroyConversation(session, entry.getKey()); entryIterator.remove(); } } } }
private void cleanUpConversationMap() { Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { Iterator<Entry<String, ManagedConversation>> entryIterator = conversations.entrySet().iterator(); S session = getSessionFromRequest(getRequest(), false); while (entryIterator.hasNext()) { Entry<String, ManagedConversation> entry = entryIterator.next(); if (entry.getValue().isTransient()) { destroyConversation(session, entry.getKey()); entryIterator.remove(); } } } }
private void cleanUpConversationMap() { Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { Iterator<Entry<String, ManagedConversation>> entryIterator = conversations.entrySet().iterator(); S session = getSessionFromRequest(getRequest(), false); while (entryIterator.hasNext()) { Entry<String, ManagedConversation> entry = entryIterator.next(); if (entry.getValue().isTransient()) { destroyConversation(session, entry.getKey()); entryIterator.remove(); } } } }
private void cleanUpConversationMap() { Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { Iterator<Entry<String, ManagedConversation>> entryIterator = conversations.entrySet().iterator(); S session = getSessionFromRequest(getRequest(), false); while (entryIterator.hasNext()) { Entry<String, ManagedConversation> entry = entryIterator.next(); if (entry.getValue().isTransient()) { destroyConversation(session, entry.getKey()); entryIterator.remove(); } } } }
private void cleanUpConversationMap() { Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { Iterator<Entry<String, ManagedConversation>> entryIterator = conversations.entrySet().iterator(); S session = getSessionFromRequest(getRequest(), false); while (entryIterator.hasNext()) { Entry<String, ManagedConversation> entry = entryIterator.next(); if (entry.getValue().isTransient()) { destroyConversation(session, entry.getKey()); entryIterator.remove(); } } } }
private void cleanUpConversationMap() { Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { Iterator<Entry<String, ManagedConversation>> entryIterator = conversations.entrySet().iterator(); S session = getSessionFromRequest(getRequest(), false); while (entryIterator.hasNext()) { Entry<String, ManagedConversation> entry = entryIterator.next(); if (entry.getValue().isTransient()) { destroyConversation(session, entry.getKey()); entryIterator.remove(); } } } }
private void setDestructionQueue(Map<String, ManagedConversation> conversations, S session) { Map<String, List<ContextualInstance<?>>> contexts = new HashMap<>(); for (Entry<String, ManagedConversation> entry : conversations.entrySet()) { ManagedConversation conversation = entry.getValue(); // First make all conversations transient if (!conversation.isTransient()) { conversation.end(); } // Extract contextual instances List<ContextualInstance<?>> contextualInstances = new ArrayList<>(); for (String id : new ConversationNamingScheme(getNamingSchemePrefix(), entry.getKey(), beanIdentifierIndex) .filterIds(getSessionAttributeNames(session))) { contextualInstances.add((ContextualInstance<?>) getSessionAttributeFromSession(session, id)); } contexts.put(entry.getKey(), contextualInstances); } // Store remaining conversation contexts for later destruction setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts)); }
private void setDestructionQueue(Map<String, ManagedConversation> conversations, S session) { Map<String, List<ContextualInstance<?>>> contexts = new HashMap<>(); for (Entry<String, ManagedConversation> entry : conversations.entrySet()) { ManagedConversation conversation = entry.getValue(); // First make all conversations transient if (!conversation.isTransient()) { conversation.end(); } // Extract contextual instances List<ContextualInstance<?>> contextualInstances = new ArrayList<>(); for (String id : new ConversationNamingScheme(getNamingSchemePrefix(), entry.getKey(), beanIdentifierIndex) .filterIds(getSessionAttributeNames(session))) { contextualInstances.add((ContextualInstance<?>) getSessionAttributeFromSession(session, id)); } contexts.put(entry.getKey(), contextualInstances); } // Store remaining conversation contexts for later destruction setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts)); }
private void setDestructionQueue(Map<String, ManagedConversation> conversations, S session) { Map<String, List<ContextualInstance<?>>> contexts = new HashMap<>(); for (Entry<String, ManagedConversation> entry : conversations.entrySet()) { ManagedConversation conversation = entry.getValue(); // First make all conversations transient if (!conversation.isTransient()) { conversation.end(); } // Extract contextual instances List<ContextualInstance<?>> contextualInstances = new ArrayList<>(); for (String id : new ConversationNamingScheme(getNamingSchemePrefix(), entry.getKey(), beanIdentifierIndex) .filterIds(getSessionAttributeNames(session))) { contextualInstances.add((ContextualInstance<?>) getSessionAttributeFromSession(session, id)); } contexts.put(entry.getKey(), contextualInstances); } // Store remaining conversation contexts for later destruction setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts)); }
private void setDestructionQueue(Map<String, ManagedConversation> conversations, S session) { Map<String, List<ContextualInstance<?>>> contexts = new HashMap<>(); for (Entry<String, ManagedConversation> entry : conversations.entrySet()) { ManagedConversation conversation = entry.getValue(); // First make all conversations transient if (!conversation.isTransient()) { conversation.end(); } // Extract contextual instances List<ContextualInstance<?>> contextualInstances = new ArrayList<>(); for (String id : new ConversationNamingScheme(getNamingSchemePrefix(), entry.getKey(), beanIdentifierIndex) .filterIds(getSessionAttributeNames(session))) { contextualInstances.add((ContextualInstance<?>) getSessionAttributeFromSession(session, id)); } contexts.put(entry.getKey(), contextualInstances); } // Store remaining conversation contexts for later destruction setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts)); }
private void setDestructionQueue(Map<String, ManagedConversation> conversations, S session) { Map<String, List<ContextualInstance<?>>> contexts = new HashMap<>(); for (Entry<String, ManagedConversation> entry : conversations.entrySet()) { ManagedConversation conversation = entry.getValue(); // First make all conversations transient if (!conversation.isTransient()) { conversation.end(); } // Extract contextual instances List<ContextualInstance<?>> contextualInstances = new ArrayList<>(); for (String id : new ConversationNamingScheme(getNamingSchemePrefix(), entry.getKey(), beanIdentifierIndex) .filterIds(getSessionAttributeNames(session))) { contextualInstances.add((ContextualInstance<?>) getSessionAttributeFromSession(session, id)); } contexts.put(entry.getKey(), contextualInstances); } // Store remaining conversation contexts for later destruction setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts)); }
private void setDestructionQueue(Map<String, ManagedConversation> conversations, S session) { Map<String, List<ContextualInstance<?>>> contexts = new HashMap<>(); for (Entry<String, ManagedConversation> entry : conversations.entrySet()) { ManagedConversation conversation = entry.getValue(); // First make all conversations transient if (!conversation.isTransient()) { conversation.end(); } // Extract contextual instances List<ContextualInstance<?>> contextualInstances = new ArrayList<>(); for (String id : new ConversationNamingScheme(getNamingSchemePrefix(), entry.getKey(), beanIdentifierIndex) .filterIds(getSessionAttributeNames(session))) { contextualInstances.add((ContextualInstance<?>) getSessionAttributeFromSession(session, id)); } contexts.put(entry.getKey(), contextualInstances); } // Store remaining conversation contexts for later destruction setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts)); }
@Override public void deactivateContext() { final ConversationState conversationState = CURRENT_CONVERSATION_STATE.get(); final ManagedConversation currentConversation = boundConversationContext.getCurrentConversation(); if (!currentConversation.isTransient() && !conversationState.isLongRunning()) { startLongRunningConversation(conversationState, currentConversation); } else if (currentConversation.isTransient() && conversationState.isLongRunning()) { endLongRunningConversation(conversationState); } else if (currentConversation.getId() != null && !currentConversation.getId().equals(conversationState.getConversationId())) { LOGGER.warn("current conversation id: {} and registered: {}. There shouldn't be two activated conversations", currentConversation.getId(), conversationState.getConversationId()); } boundConversationContext.deactivate(); boundConversationContext.dissociate(CURRENT_BOUND_REQUEST.get()); CURRENT_BOUND_REQUEST.remove(); CURRENT_CONVERSATION_STATE.remove(); }
@Override public void invalidate() { ManagedConversation currentConversation = getCurrentConversation(); Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { for (Entry<String, ManagedConversation> stringManagedConversationEntry : conversations.entrySet()) { ManagedConversation conversation = stringManagedConversationEntry.getValue(); if (!currentConversation.equals(conversation) && !conversation.isTransient() && isExpired(conversation)) { // Try to lock the conversation and log warning if not successful - unlocking should not be necessary if (!conversation.lock(0)) { ConversationLogger.LOG.endLockedConversation(conversation.getId()); } conversation.end(); } } } }
@Override public void invalidate() { ManagedConversation currentConversation = getCurrentConversation(); Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { for (Entry<String, ManagedConversation> stringManagedConversationEntry : conversations.entrySet()) { ManagedConversation conversation = stringManagedConversationEntry.getValue(); if (!currentConversation.equals(conversation) && !conversation.isTransient() && isExpired(conversation)) { // Try to lock the conversation and log warning if not successful - unlocking should not be necessary if (!conversation.lock(0)) { ConversationLogger.LOG.endLockedConversation(conversation.getId()); } conversation.end(); } } } }
@Override public void invalidate() { ManagedConversation currentConversation = getCurrentConversation(); Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { for (Entry<String, ManagedConversation> stringManagedConversationEntry : conversations.entrySet()) { ManagedConversation conversation = stringManagedConversationEntry.getValue(); if (!currentConversation.equals(conversation) && !conversation.isTransient() && isExpired(conversation)) { // Try to lock the conversation and log warning if not successful - unlocking should not be necessary if (!conversation.lock(0)) { ConversationLogger.LOG.endLockedConversation(conversation.getId()); } conversation.end(); } } } }
@Override public void invalidate() { ManagedConversation currentConversation = getCurrentConversation(); Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { for (Entry<String, ManagedConversation> stringManagedConversationEntry : conversations.entrySet()) { ManagedConversation conversation = stringManagedConversationEntry.getValue(); if (!currentConversation.equals(conversation) && !conversation.isTransient() && isExpired(conversation)) { // Try to lock the conversation and log warning if not successful - unlocking should not be necessary if (!conversation.lock(0)) { ConversationLogger.LOG.endLockedConversation(conversation.getId()); } conversation.end(); } } } }
@Override public void invalidate() { ManagedConversation currentConversation = getCurrentConversation(); Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { for (Entry<String, ManagedConversation> stringManagedConversationEntry : conversations.entrySet()) { ManagedConversation conversation = stringManagedConversationEntry.getValue(); if (!currentConversation.equals(conversation) && !conversation.isTransient() && isExpired(conversation)) { // Try to lock the conversation and log warning if not successful - unlocking should not be necessary if (!conversation.lock(0)) { ConversationLogger.LOG.endLockedConversation(conversation.getId()); } conversation.end(); } } } }
@Override public void invalidate() { ManagedConversation currentConversation = getCurrentConversation(); Map<String, ManagedConversation> conversations = getConversationMap(); synchronized (conversations) { for (Entry<String, ManagedConversation> stringManagedConversationEntry : conversations.entrySet()) { ManagedConversation conversation = stringManagedConversationEntry.getValue(); if (!currentConversation.equals(conversation) && !conversation.isTransient() && isExpired(conversation)) { // Try to lock the conversation and log warning if not successful - unlocking should not be necessary if (!conversation.lock(0)) { ConversationLogger.LOG.endLockedConversation(conversation.getId()); } conversation.end(); } } } }
public void callback(Context context, Event event) throws Exception { WeldManager manager = context.get(WeldManager.class); BoundConversationContext conversationContext = manager.instance().select(BoundConversationContext.class).get(); if (!conversationContext.getCurrentConversation().isTransient()) { context.add(CDIConversationID.class, new CDIConversationID(conversationContext.getCurrentConversation().getId())); } else { context.add(CDIConversationID.class, new CDIConversationID(null)); } BoundRequest request = context.get(BoundRequest.class); try { conversationContext.invalidate(); conversationContext.deactivate(); } finally { conversationContext.dissociate(request); } } }