@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(); }
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); } } }
if (!conversationContext.getCurrentConversation().isTransient()) conversationId.set(new CDIConversationID(conversationContext.getCurrentConversation().getId()));