use of org.apache.deltaspike.core.util.context.ContextualStorage in project deltaspike by apache.
the class GroupedConversationContext method tryToDestroySubGroup.
private void tryToDestroySubGroup(Set<Class<?>> subGroups, Map.Entry<ConversationKey, ContextualStorage> entry) {
ContextualStorage storage = entry.getValue();
for (Map.Entry<Object, ContextualInstanceInfo<?>> storageEntry : storage.getStorage().entrySet()) {
for (Class<?> subGroup : subGroups) {
Class classOfEntry = storageEntry.getValue().getContextualInstance().getClass();
if (subGroup.equals(classOfEntry) || (subGroup.isInterface() && subGroup.isAssignableFrom(classOfEntry))) {
Contextual bean = storage.getBean(storageEntry.getKey());
AbstractContext.destroyBean(bean, storageEntry.getValue());
//ok due to ConcurrentHashMap
storage.getStorage().remove(storageEntry.getKey());
break;
}
}
}
}
use of org.apache.deltaspike.core.util.context.ContextualStorage in project deltaspike by apache.
the class GroupedConversationContext method closeConversation.
@Override
public ContextualStorage closeConversation(Class<?> conversationGroup, Annotation... qualifiers) {
ConversationKey conversationKey = new ConversationKey(conversationGroup, qualifiers);
ContextualStorage contextualStorage = this.conversationBeanHolder.getStorageMap().remove(conversationKey);
if (contextualStorage != null) {
AbstractContext.destroyAllActive(contextualStorage);
}
return contextualStorage;
}
use of org.apache.deltaspike.core.util.context.ContextualStorage in project deltaspike by apache.
the class ViewAccessContext method destroyExpiredBeans.
private void destroyExpiredBeans(boolean force) {
ContextualStorage storage = viewAccessBeanHolder.getContextualStorage(beanManager, KEY, false);
if (storage != null) {
for (Map.Entry<Object, ContextualInstanceInfo<?>> storageEntry : storage.getStorage().entrySet()) {
if (force || !viewAccessBeanAccessHistory.getAccessedBeans().contains((String) storageEntry.getKey())) {
Contextual bean = storage.getBean(storageEntry.getKey());
AbstractContext.destroyBean(bean, storageEntry.getValue());
//ok due to ConcurrentHashMap
storage.getStorage().remove(storageEntry.getKey());
}
}
}
}
use of org.apache.deltaspike.core.util.context.ContextualStorage in project deltaspike by apache.
the class ViewScopedContext method getContextualStorage.
@Override
protected ContextualStorage getContextualStorage(Contextual<?> contextual, boolean createIfNotExists) {
Map<String, Object> viewMap = getViewMap();
ContextualStorage storage = (ContextualStorage) viewMap.get(CONTEXTUAL_MAP_NAME);
if (storage == null && createIfNotExists) {
storage = new ContextualStorage(beanManager, false, isPassivatingScope());
viewMap.put(CONTEXTUAL_MAP_NAME, storage);
}
return storage;
}
use of org.apache.deltaspike.core.util.context.ContextualStorage in project deltaspike by apache.
the class AbstractBeanHolder method createContextualStorage.
protected synchronized ContextualStorage createContextualStorage(BeanManager beanManager, K key) {
ContextualStorage contextualStorage = storageMap.get(key);
if (contextualStorage == null) {
contextualStorage = new ContextualStorage(beanManager, useConcurrentStorage, usePassivationCapableStorage);
storageMap.put(key, contextualStorage);
}
return contextualStorage;
}
Aggregations