/** * Tasks when a long running conversation has started during this event. * * @param conversationState * @param managedConversation */ private void startLongRunningConversation(ConversationState conversationState, ManagedConversation managedConversation) { conversationState.registerLongRunningConversaton(managedConversation.getId()); LOGGER.trace("register long running conversation: {}", managedConversation.getId()); }
@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(); } } } }
protected void associateRequest(ManagedConversation conversation) { setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation); NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), conversation.getId(), beanIdentifierIndex); setBeanStore(createRequestBeanStore(namingScheme, getRequest())); getBeanStore().attach(); }
protected void associateRequest(ManagedConversation conversation) { setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation); NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), conversation.getId(), beanIdentifierIndex); setBeanStore(createRequestBeanStore(namingScheme, getRequest())); getBeanStore().attach(); }
protected void associateRequest(ManagedConversation conversation) { setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation); NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), conversation.getId(), beanIdentifierIndex); setBeanStore(createRequestBeanStore(namingScheme, getRequest())); getBeanStore().attach(); }
protected void associateRequest(ManagedConversation conversation) { setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation); NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), conversation.getId(), beanIdentifierIndex); setBeanStore(createRequestBeanStore(namingScheme, getRequest())); getBeanStore().attach(); }
protected void associateRequest(ManagedConversation conversation) { setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation); NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), conversation.getId(), beanIdentifierIndex); setBeanStore(createRequestBeanStore(namingScheme, getRequest())); getBeanStore().attach(); }
protected void associateRequest(ManagedConversation conversation) { setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation); NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), conversation.getId(), beanIdentifierIndex); setBeanStore(createRequestBeanStore(namingScheme, getRequest())); getBeanStore().attach(); }
/** * Allow the delegate to produce the action URL. If the conversation is * long-running, append the conversation id request parameter to the query * string part of the URL, but only if the request parameter is not already * present. * <p/> * This covers form actions Ajax calls, and redirect URLs (which we want) and * link hrefs (which we don't) * * @see {@link ViewHandler#getActionURL(FacesContext, String)} */ @Override public String getActionURL(FacesContext facesContext, String viewId) { if (contextId == null) { if (facesContext.getAttributes().containsKey(Container.CONTEXT_ID_KEY)) { contextId = (String) facesContext.getAttributes().get(Container.CONTEXT_ID_KEY); } else { contextId = RegistrySingletonProvider.STATIC_INSTANCE; } } String actionUrl = super.getActionURL(facesContext, viewId); final ConversationContext ctx = getConversationContext(contextId); if (ctx!= null && ctx.isActive() && !getSource().equals(Source.BOOKMARKABLE) && !ctx.getCurrentConversation().isTransient()) { return new FacesUrlTransformer(actionUrl, facesContext) .appendConversationIdIfNecessary(getConversationContext(contextId).getParameterName(), ctx.getCurrentConversation().getId()) .getUrl(); } else { return actionUrl; } }
/** * Allow the delegate to produce the action URL. If the conversation is * long-running, append the conversation id request parameter to the query * string part of the URL, but only if the request parameter is not already * present. * <p/> * This covers form actions Ajax calls, and redirect URLs (which we want) and * link hrefs (which we don't) * * @see {@link ViewHandler#getActionURL(FacesContext, String)} */ @Override public String getActionURL(FacesContext facesContext, String viewId) { if (contextId == null) { if (facesContext.getAttributes().containsKey(Container.CONTEXT_ID_KEY)) { contextId = (String) facesContext.getAttributes().get(Container.CONTEXT_ID_KEY); } else { contextId = RegistrySingletonProvider.STATIC_INSTANCE; } } String actionUrl = super.getActionURL(facesContext, viewId); final ConversationContext ctx = getConversationContext(contextId); if (ctx != null && ctx.isActive() && !getSource().equals(Source.BOOKMARKABLE) && !ctx.getCurrentConversation().isTransient()) { return new FacesUrlTransformer(actionUrl, facesContext) .appendConversationIdIfNecessary(getConversationContext(contextId).getParameterName(), ctx.getCurrentConversation().getId()) .getUrl(); } else { return actionUrl; } }
/** * Allow the delegate to produce the action URL. If the conversation is * long-running, append the conversation id request parameter to the query * string part of the URL, but only if the request parameter is not already * present. * <p/> * This covers form actions Ajax calls, and redirect URLs (which we want) and * link hrefs (which we don't) * * @see {@link ViewHandler#getActionURL(FacesContext, String)} */ @Override public String getActionURL(FacesContext facesContext, String viewId) { if (contextId == null) { if (facesContext.getAttributes().containsKey(Container.CONTEXT_ID_KEY)) { contextId = (String) facesContext.getAttributes().get(Container.CONTEXT_ID_KEY); } else { contextId = RegistrySingletonProvider.STATIC_INSTANCE; } } String actionUrl = super.getActionURL(facesContext, viewId); final ConversationContext ctx = getConversationContext(contextId); if (ctx!= null && ctx.isActive() && !getSource().equals(Source.BOOKMARKABLE) && !ctx.getCurrentConversation().isTransient()) { return new FacesUrlTransformer(actionUrl, facesContext) .appendConversationIdIfNecessary(getConversationContext(contextId).getParameterName(), ctx.getCurrentConversation().getId()) .getUrl(); } else { return actionUrl; } }
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); } } }
conversationId.set(new CDIConversationID(conversationContext.getCurrentConversation().getId()));
ConversationLogger.LOG.cleaningUpTransientConversation(); } else { ConversationLogger.LOG.cleaningUpConversation(conversationContext.getCurrentConversation().getId());