Class AttributeBeanStore
java.lang.Object
org.jboss.weld.contexts.beanstore.AttributeBeanStore
- All Implemented Interfaces:
Iterable<org.jboss.weld.serialization.spi.BeanIdentifier>,BeanStore,BoundBeanStore
- Direct Known Subclasses:
MapBeanStore
A bound bean store backed by attributes. This bean store is "write-through" - if attached it will write any modifications to the backing store immediately. If detached modifications will not be written through. If the bean store is reattached, then any local modifications will be written to the underlying store.
This construct is not thread safe.
- Author:
- Pete Muir, Nicklas Karlsson, David Allen
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeBeanStore(NamingScheme namingScheme, boolean attributeLazyFetchingEnabled) -
Method Summary
Modifier and TypeMethodDescriptionbooleanattach()Attach the bean store, any updates from now on will be written through to the underlying store.voidclear()Clears the store of contextual instancesbooleancontains(org.jboss.weld.serialization.spi.BeanIdentifier id) Check if the store contains an instancebooleandetach()Detach the bean store, causing updates to longer be written through to the underlying store.voidFetch all relevant attributes from the backing store and copy instances which are not present in the local bean store.<T> org.jboss.weld.context.api.ContextualInstance<T>get(org.jboss.weld.serialization.spi.BeanIdentifier id) Gets an instance of a contextual from the storeprotected abstract ObjectgetAttribute(String prefixedId) Gets an attribute from the underlying storageGets an enumeration of the attribute names present in the underlying storage.protected abstract LockStoreprotected NamingSchemeprotected Collection<String>Gets an enumeration of the attribute names present in the underlying storagebooleanReturn true if the bean store is attachedbooleanprotected booleanIterator<org.jboss.weld.serialization.spi.BeanIdentifier>iterator()lock(org.jboss.weld.serialization.spi.BeanIdentifier id) Gets a creation lock for the given bean id.<T> voidput(org.jboss.weld.serialization.spi.BeanIdentifier id, org.jboss.weld.context.api.ContextualInstance<T> instance) Adds a bean instance to the storage<T> org.jboss.weld.context.api.ContextualInstance<T>remove(org.jboss.weld.serialization.spi.BeanIdentifier id) Removes a bean instance identified by the given id.protected abstract voidremoveAttribute(String prefixedId) Removes an attribute from the underlying storageprotected abstract voidsetAttribute(String prefixedId, Object instance) Sets an instance under a key in the underlying storageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
AttributeBeanStore
- Parameters:
namingScheme-attributeLazyFetchingEnabled-
-
-
Method Details
-
detach
public boolean detach()Detach the bean store, causing updates to longer be written through to the underlying store.- Specified by:
detachin interfaceBoundBeanStore- Returns:
- true if the bean store was detached, or false if the bean store is already detached
-
attach
public boolean attach()Attach the bean store, any updates from now on will be written through to the underlying store.
When the bean store is attached, the detached state is assumed to be authoritative if there are any conflicts.
- Specified by:
attachin interfaceBoundBeanStore- Returns:
- true if the bean store was attached, or false if the bean store is already attached
-
fetchUninitializedAttributes
public void fetchUninitializedAttributes()Fetch all relevant attributes from the backing store and copy instances which are not present in the local bean store. -
isAttached
public boolean isAttached()Description copied from interface:BoundBeanStoreReturn true if the bean store is attached- Specified by:
isAttachedin interfaceBoundBeanStore- Returns:
- true if the bean store is attached or false if the bean store has been detached
-
get
public <T> org.jboss.weld.context.api.ContextualInstance<T> get(org.jboss.weld.serialization.spi.BeanIdentifier id) Description copied from interface:BeanStoreGets an instance of a contextual from the store -
put
public <T> void put(org.jboss.weld.serialization.spi.BeanIdentifier id, org.jboss.weld.context.api.ContextualInstance<T> instance) Description copied from interface:BeanStoreAdds a bean instance to the storage -
remove
public <T> org.jboss.weld.context.api.ContextualInstance<T> remove(org.jboss.weld.serialization.spi.BeanIdentifier id) Description copied from interface:BeanStoreRemoves a bean instance identified by the given id. -
clear
public void clear()Description copied from interface:BeanStoreClears the store of contextual instances -
contains
public boolean contains(org.jboss.weld.serialization.spi.BeanIdentifier id) Description copied from interface:BeanStoreCheck if the store contains an instance -
getNamingScheme
-
iterator
-
getAttribute
Gets an attribute from the underlying storage- Parameters:
prefixedId- The (prefixed) id of the attribute- Returns:
- The data
-
removeAttribute
Removes an attribute from the underlying storage- Parameters:
prefixedId- The (prefixed) id of the attribute to remove
-
getAttributeNames
Gets an enumeration of the attribute names present in the underlying storage. The collection must guarantee non-interference with other threads when iterating over it using iterator.- Returns:
- The attribute names
-
getPrefixedAttributeNames
Gets an enumeration of the attribute names present in the underlying storage- Returns:
- The attribute names
-
setAttribute
Sets an instance under a key in the underlying storage- Parameters:
prefixedId- The (prefixed) id of the attribute to setinstance- The instance
-
lock
Description copied from interface:BeanStoreGets a creation lock for the given bean id. -
getLockStore
-
isLocalBeanStoreSyncNeeded
protected boolean isLocalBeanStoreSyncNeeded()- Returns:
trueif a bean store synchronization is required duringattach()invocation,falseotherwise
-
isAttributeLazyFetchingEnabled
public boolean isAttributeLazyFetchingEnabled()- Returns:
trueif attributes should be fetched lazily,falseotherwise
-