Search in sources :

Example 1 with ContextualInstanceInfo

use of org.apache.deltaspike.core.util.context.ContextualInstanceInfo 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 ContextualInstanceInfo

use of org.apache.deltaspike.core.util.context.ContextualInstanceInfo 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)

Aggregations

Map (java.util.Map)2 Contextual (javax.enterprise.context.spi.Contextual)2 ContextualInstanceInfo (org.apache.deltaspike.core.util.context.ContextualInstanceInfo)2 ContextualStorage (org.apache.deltaspike.core.util.context.ContextualStorage)2