Search in sources :

Example 1 with ContextualInstance

use of org.jboss.weld.context.api.ContextualInstance in project core by weld.

the class AttributeBeanStore method fetchUninitializedAttributes.

/**
 * Fetch all relevant attributes from the backing store and copy instances which are not present in the local bean store.
 */
public void fetchUninitializedAttributes() {
    for (String prefixedId : getPrefixedAttributeNames()) {
        BeanIdentifier id = getNamingScheme().deprefix(prefixedId);
        if (!beanStore.contains(id)) {
            ContextualInstance<?> instance = (ContextualInstance<?>) getAttribute(prefixedId);
            beanStore.put(id, instance);
            ContextLogger.LOG.addingDetachedContextualUnderId(instance, id);
        }
    }
}
Also used : ContextualInstance(org.jboss.weld.context.api.ContextualInstance) BeanIdentifier(org.jboss.weld.serialization.spi.BeanIdentifier)

Example 2 with ContextualInstance

use of org.jboss.weld.context.api.ContextualInstance 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

ContextualInstance (org.jboss.weld.context.api.ContextualInstance)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ManagedConversation (org.jboss.weld.context.ManagedConversation)1 ConversationNamingScheme (org.jboss.weld.contexts.beanstore.ConversationNamingScheme)1 BeanIdentifier (org.jboss.weld.serialization.spi.BeanIdentifier)1