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();
if (!conversation.isTransient()) {
conversation.end();
}
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);
}
setRequestAttribute(getRequest(), DESTRUCTION_QUEUE_ATTRIBUTE_NAME, Collections.synchronizedMap(contexts));
}