/** * Create a new Prefixer. * * @param prefix The prefix * @param delimiter The delimiter to use between the prefix and the * identifier. */ public AbstractNamingScheme(String delimiter) { this.delimiter = delimiter; this.deprefixerFunction = new DeprefixerFunction(); this.prefixerFunction = new PrefixerFunction(); }
/** * Gets an enumeration of the attribute names present in the underlying * storage * * @return The attribute names */ protected Collection<String> getPrefixedAttributeNames() { return getNamingScheme().filterIds(getAttributeNames()); }
public LockedBean lock(final BeanIdentifier id) { LockStore lockStore = getLockStore(); if(lockStore == null) { //if the lockstore is null then no locking is necessary, as the underlying //context is single threaded return null; } return lockStore.lock(id); }
/** * 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> 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; }
@Override public <T> ContextualInstance<T> get(BeanIdentifier id) { ContextualInstance<T> instance = super.get(id); if (instance == null && isAttached()) { String prefixedId = getNamingScheme().prefix(id); instance = cast(getAttribute(prefixedId)); } return instance; }
@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; }
@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 LockStore getLockStore() { LockStore lockStore = this.lockStore; if (lockStore == null) { lockStore = (LockStore) getAttribute(LOCK_STORE_KEY); if (lockStore == null) { synchronized (SessionMapBeanStore.class) { lockStore = (LockStore) getAttribute(LOCK_STORE_KEY); if (lockStore == null) { lockStore = new LockStore(); setAttribute(LOCK_STORE_KEY, lockStore); } } } this.lockStore = lockStore; } return lockStore; }
/** * * @param namingScheme * @param attributeLazyFetchingEnabled */ public AttributeBeanStore(NamingScheme namingScheme, boolean attributeLazyFetchingEnabled) { this.namingScheme = namingScheme; this.beanStore = new HashMapBeanStore(); this.attributeLazyFetchingEnabled = attributeLazyFetchingEnabled; }
public boolean associate(Map<String, Object> storage) { if (getBeanStore() == null) { setBeanStore(new MapBeanStore(namingScheme, storage, true)); getBeanStore().attach(); return true; } else { return false; } }
public HttpSessionContextImpl(String contextId, BeanIdentifierIndex index) { super(contextId, true); this.namingScheme = new SimpleBeanIdentifierIndexNamingScheme(NAMING_SCHEME_PREFIX, index); this.contextId = contextId; }
/** * Constructor */ protected AbstractSharedContext(String contextId) { super(contextId, true); this.beanStore = new ConcurrentHashMapBeanStore(); }
@Override protected BoundBeanStore createSessionBeanStore(NamingScheme namingScheme, Map<String, Object> session) { return new SessionMapBeanStore(namingScheme, session); }
public LockStore getLockStore() { LockStore lockStore = this.lockStore; if(lockStore == null) { synchronized (this) { lockStore = this.lockStore; if(lockStore == null) { this.lockStore = lockStore = new LockStore(); } } } return lockStore; } }
public String apply(BeanIdentifier from) { return AbstractNamingScheme.this.prefix(from); }
public boolean contains(BeanIdentifier id) { return get(id) != null; }
public BoundSessionContextImpl(String contextId, BeanIdentifierIndex index) { super(contextId, true); this.namingScheme = new SimpleBeanIdentifierIndexNamingScheme(NAMING_SCHEME_PREFIX, index); }
public HttpSessionDestructionContext(String contextId, BeanIdentifierIndex index) { super(contextId, true); this.namingScheme = new SimpleBeanIdentifierIndexNamingScheme(HttpSessionContextImpl.NAMING_SCHEME_PREFIX, index); }