Search in sources :

Example 1 with ContextualStorage

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;
            }
        }
    }
}
Also used : Contextual(javax.enterprise.context.spi.Contextual) ContextualStorage(org.apache.deltaspike.core.util.context.ContextualStorage) ContextualInstanceInfo(org.apache.deltaspike.core.util.context.ContextualInstanceInfo) Map(java.util.Map)

Example 2 with ContextualStorage

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;
}
Also used : ContextualStorage(org.apache.deltaspike.core.util.context.ContextualStorage)

Example 3 with 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());
            }
        }
    }
}
Also used : Contextual(javax.enterprise.context.spi.Contextual) ContextualStorage(org.apache.deltaspike.core.util.context.ContextualStorage) ContextualInstanceInfo(org.apache.deltaspike.core.util.context.ContextualInstanceInfo) Map(java.util.Map)

Example 4 with ContextualStorage

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;
}
Also used : ContextualStorage(org.apache.deltaspike.core.util.context.ContextualStorage)

Example 5 with ContextualStorage

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;
}
Also used : ContextualStorage(org.apache.deltaspike.core.util.context.ContextualStorage)

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