Search in sources :

Example 1 with ConversationNamingScheme

use of org.jboss.weld.contexts.beanstore.ConversationNamingScheme in project core by weld.

the class AbstractConversationContext method associateRequestWithNewConversation.

protected void associateRequestWithNewConversation() {
    ManagedConversation conversation = new ConversationImpl(manager);
    lock(conversation);
    setRequestAttribute(getRequest(), CURRENT_CONVERSATION_ATTRIBUTE_NAME, conversation);
    // Set a temporary bean store, this will be attached at the end of the request if needed
    NamingScheme namingScheme = new ConversationNamingScheme(getNamingSchemePrefix(), "transient", beanIdentifierIndex);
    setBeanStore(createRequestBeanStore(namingScheme, getRequest()));
    setRequestAttribute(getRequest(), ConversationNamingScheme.PARAMETER_NAME, namingScheme);
}
Also used : ConversationNamingScheme(org.jboss.weld.contexts.beanstore.ConversationNamingScheme) NamingScheme(org.jboss.weld.contexts.beanstore.NamingScheme) ConversationNamingScheme(org.jboss.weld.contexts.beanstore.ConversationNamingScheme) ManagedConversation(org.jboss.weld.context.ManagedConversation) ConversationImpl(org.jboss.weld.contexts.conversation.ConversationImpl)

Example 2 with ConversationNamingScheme

use of org.jboss.weld.contexts.beanstore.ConversationNamingScheme in project core by weld.

the class AbstractConversationContext method associateRequest.

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();
}
Also used : ConversationNamingScheme(org.jboss.weld.contexts.beanstore.ConversationNamingScheme) NamingScheme(org.jboss.weld.contexts.beanstore.NamingScheme) ConversationNamingScheme(org.jboss.weld.contexts.beanstore.ConversationNamingScheme)

Example 3 with ConversationNamingScheme

use of org.jboss.weld.contexts.beanstore.ConversationNamingScheme in project core by weld.

the class AbstractConversationContext method setDestructionQueue.

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));
}
Also used : ContextualInstance(org.jboss.weld.context.api.ContextualInstance) HashMap(java.util.HashMap) ConversationNamingScheme(org.jboss.weld.contexts.beanstore.ConversationNamingScheme) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ManagedConversation(org.jboss.weld.context.ManagedConversation)

Aggregations

ConversationNamingScheme (org.jboss.weld.contexts.beanstore.ConversationNamingScheme)3 ManagedConversation (org.jboss.weld.context.ManagedConversation)2 NamingScheme (org.jboss.weld.contexts.beanstore.NamingScheme)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ContextualInstance (org.jboss.weld.context.api.ContextualInstance)1 ConversationImpl (org.jboss.weld.contexts.conversation.ConversationImpl)1