public Iterator<BeanIdentifier> iterator() { Iterator<BeanIdentifier> iterator; if (isAttributeLazyFetchingEnabled()) { // Merge the bean identifiers from the local bean store and the backing store Set<BeanIdentifier> identifiers = new HashSet<>(); for (BeanIdentifier id : beanStore) { identifiers.add(id); } for (String prefixedId : getPrefixedAttributeNames()) { identifiers.add(getNamingScheme().deprefix(prefixedId)); } iterator = identifiers.iterator(); } else { iterator = beanStore.iterator(); } return iterator; }
@Override public <T> ContextualInstance<T> get(BeanIdentifier id) { ContextualInstance<T> instance = beanStore.get(id); if(instance == null && isAttached() && isAttributeLazyFetchingEnabled()) { instance = cast(getAttribute(namingScheme.prefix(id))); if(instance != null) { beanStore.put(id, instance); } } ContextLogger.LOG.contextualInstanceFound(id, instance, this); return instance; }
public boolean destroy(HttpSession session) { final BoundBeanStore beanStore = getBeanStore(); if (beanStore == null) { try { HttpConversationContext conversationContext = getConversationContext(); setBeanStore(new EagerSessionBeanStore(namingScheme, session, getServiceRegistry())); activate(); invalidate(); conversationContext.destroy(session); deactivate(); setBeanStore(null); return true; } finally { cleanup(); } } else { // We are in a request, invalidate it invalidate(); if (beanStore instanceof AttributeBeanStore) { AttributeBeanStore attributeBeanStore = ((AttributeBeanStore) beanStore); if (attributeBeanStore.isAttributeLazyFetchingEnabled()) { // At this moment we have to sync the local bean store and the backing store attributeBeanStore.fetchUninitializedAttributes(); } } getConversationContext().destroy(session); return false; } }