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;
}
Aggregations