use of org.apache.deltaspike.core.api.scope.ConversationSubGroup in project deltaspike by apache.
the class ConversationUtils method getDeclaredConversationGroup.
public static Class<?> getDeclaredConversationGroup(Class<?> conversationGroup) {
ConversationSubGroup conversationSubGroup = conversationGroup.getAnnotation(ConversationSubGroup.class);
if (conversationSubGroup == null) {
return conversationGroup;
}
Class<?> result = conversationSubGroup.of();
if (!ConversationSubGroup.class.equals(result)) {
return result;
}
result = conversationGroup.getSuperclass();
if ((result == null || Object.class.getName().equals(result.getName())) && conversationGroup.getInterfaces().length == 1) {
return conversationGroup.getInterfaces()[0];
}
if (result == null) {
//TODO move validation to the bootstrapping process
throw new IllegalStateException(conversationGroup.getName() + " hosts an invalid usage of @" + ConversationSubGroup.class.getName());
}
return result;
}
use of org.apache.deltaspike.core.api.scope.ConversationSubGroup 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