Search in sources :

Example 6 with ContextualStorage

use of org.apache.deltaspike.core.util.context.ContextualStorage in project deltaspike by apache.

the class GroupedConversationContext method closeConversationGroup.

@Override
public Set<ContextualStorage> closeConversationGroup(Class<?> conversationGroup) {
    Set<ContextualStorage> result = new HashSet<ContextualStorage>();
    ConversationSubGroup conversationSubGroup = conversationGroup.getAnnotation(ConversationSubGroup.class);
    Set<Class<?>> subGroups = null;
    if (conversationSubGroup != null) {
        conversationGroup = ConversationUtils.getDeclaredConversationGroup(conversationGroup);
        subGroups = new HashSet<Class<?>>(conversationSubGroup.subGroup().length);
        Collections.addAll(subGroups, conversationSubGroup.subGroup());
    }
    Map<ConversationKey, ContextualStorage> storageMap = this.conversationBeanHolder.getStorageMap();
    for (Map.Entry<ConversationKey, ContextualStorage> entry : storageMap.entrySet()) {
        if (entry.getKey().getConversationGroup().equals(conversationGroup)) {
            if (subGroups == null) {
                AbstractContext.destroyAllActive(entry.getValue());
                result.add(entry.getValue());
                //ok due to ConcurrentHashMap
                storageMap.remove(entry.getKey());
            } else {
                tryToDestroySubGroup(subGroups, entry);
                if (entry.getValue().getStorage().isEmpty()) {
                    //ok due to ConcurrentHashMap
                    storageMap.remove(entry.getKey());
                }
            }
        }
    }
    return result;
}
Also used : ContextualStorage(org.apache.deltaspike.core.util.context.ContextualStorage) ConversationSubGroup(org.apache.deltaspike.core.api.scope.ConversationSubGroup) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

ContextualStorage (org.apache.deltaspike.core.util.context.ContextualStorage)6 Map (java.util.Map)3 Contextual (javax.enterprise.context.spi.Contextual)2 ContextualInstanceInfo (org.apache.deltaspike.core.util.context.ContextualInstanceInfo)2 HashSet (java.util.HashSet)1 ConversationSubGroup (org.apache.deltaspike.core.api.scope.ConversationSubGroup)1