/** * * @param namingScheme * @param attributeLazyFetchingEnabled */ public AttributeBeanStore(NamingScheme namingScheme, boolean attributeLazyFetchingEnabled) { this.namingScheme = namingScheme; this.beanStore = new HashMapBeanStore(); this.attributeLazyFetchingEnabled = attributeLazyFetchingEnabled; }
@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; }
/** * Fetch all relevant attributes from the backing store and copy instances which are not present in the local bean store. */ public void fetchUninitializedAttributes() { for (String prefixedId : getPrefixedAttributeNames()) { BeanIdentifier id = getNamingScheme().deprefix(prefixedId); if (!beanStore.contains(id)) { ContextualInstance<?> instance = (ContextualInstance<?>) getAttribute(prefixedId); beanStore.put(id, instance); ContextLogger.LOG.addingDetachedContextualUnderId(instance, id); } } }
@Override public <T> void put(BeanIdentifier id, ContextualInstance<T> instance) { beanStore.put(id, instance); // moved due to WELD-892 if (isAttached()) { setAttribute(namingScheme.prefix(id), instance); } ContextLogger.LOG.contextualInstanceAdded(instance.getContextual(), id, this); }
@Override public <T> ContextualInstance<T> remove(BeanIdentifier id) { ContextualInstance<T> instance = beanStore.remove(id); if (instance != null) { if (isAttached()) { removeAttribute(namingScheme.prefix(id)); } ContextLogger.LOG.contextualInstanceRemoved(id, this); } return instance; }
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; }
/** * Fetch all relevant attributes from the backing store and copy instances which are not present in the local bean store. */ public void fetchUninitializedAttributes() { for (String prefixedId : getPrefixedAttributeNames()) { BeanIdentifier id = getNamingScheme().deprefix(prefixedId); if (!beanStore.contains(id)) { ContextualInstance<?> instance = (ContextualInstance<?>) getAttribute(prefixedId); beanStore.put(id, instance); ContextLogger.LOG.addingDetachedContextualUnderId(instance, id); } } }
@Override public <T> void put(BeanIdentifier id, ContextualInstance<T> instance) { beanStore.put(id, instance); // moved due to WELD-892 if (isAttached()) { setAttribute(namingScheme.prefix(id), instance); } ContextLogger.LOG.contextualInstanceAdded(instance.getContextual(), id, this); }
@Override public <T> ContextualInstance<T> remove(BeanIdentifier id) { ContextualInstance<T> instance = beanStore.remove(id); if (instance != null) { if (isAttached()) { removeAttribute(namingScheme.prefix(id)); } ContextLogger.LOG.contextualInstanceRemoved(id, this); } return instance; }
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; }
/** * * @param namingScheme * @param attributeLazyFetchingEnabled */ public AttributeBeanStore(NamingScheme namingScheme, boolean attributeLazyFetchingEnabled) { this.namingScheme = namingScheme; this.beanStore = new HashMapBeanStore(); this.attributeLazyFetchingEnabled = attributeLazyFetchingEnabled; }
@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; }
/** * Fetch all relevant attributes from the backing store and copy instances which are not present in the local bean store. */ public void fetchUninitializedAttributes() { for (String prefixedId : getPrefixedAttributeNames()) { BeanIdentifier id = getNamingScheme().deprefix(prefixedId); if (!beanStore.contains(id)) { ContextualInstance<?> instance = (ContextualInstance<?>) getAttribute(prefixedId); beanStore.put(id, instance); ContextLogger.LOG.addingDetachedContextualUnderId(instance, id); } } }
@Override public <T> void put(BeanIdentifier id, ContextualInstance<T> instance) { beanStore.put(id, instance); // moved due to WELD-892 if (isAttached()) { setAttribute(namingScheme.prefix(id), instance); } ContextLogger.LOG.contextualInstanceAdded(instance.getContextual(), id, this); }
@Override public <T> ContextualInstance<T> remove(BeanIdentifier id) { ContextualInstance<T> instance = beanStore.remove(id); if (instance != null) { if (isAttached()) { removeAttribute(namingScheme.prefix(id)); } ContextLogger.LOG.contextualInstanceRemoved(id, this); } return instance; }
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; }