public class DirectWriteMapDbStore extends AbstractDirectWriteStore<MapDbPersistenceBackend>
AbstractDirectWriteStore that translates model-level operations to MapDB operations.
This class implements the PersistentStore interface that defines a set of operations to implement in order to
allow EMF persistence delegation. If this store is used, every method call and property access on PersistentEObject is forwarded to this class, that takes care of the database serialization and deserialization
using its embedded MapDbPersistenceBackend.
This store can be used as a base store that can be complemented by plugging decorator stores on top of it (see AbstractPersistentStoreDecorator subclasses) to provide additional features such as caching or logging.
| Modifier and Type | Field and Description |
|---|---|
protected static int |
DEFAULT_CACHE_SIZE
The default cache size (10 000).
|
protected com.github.benmanes.caffeine.cache.Cache<Id,PersistentEObject> |
persistentObjectsCache
In-memory cache that holds recently loaded
PersistentEObjects, identified by their Id. |
backendNO_INDEX| Constructor and Description |
|---|
DirectWriteMapDbStore(Resource.Internal resource,
MapDbPersistenceBackend backend)
Constructs a new
DirectWriteMapDbStore between the given resource and
the backend. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAttribute(PersistentEObject object,
EAttribute attribute,
int index,
Object value)
Adds the
value at the index in the content of the attribute of the object. |
protected void |
addReference(PersistentEObject object,
EReference reference,
int index,
PersistentEObject value)
Adds the
value at the index in the content of the reference of the object. |
void |
clear(InternalEObject internalObject,
EStructuralFeature feature)
Removes all values form the
content of the object's feature |
boolean |
contains(InternalEObject internalObject,
EStructuralFeature feature,
Object value)
Returns whether the
content of the object's feature contains the given value. |
EObject |
eObject(Id id)
|
protected Object |
getAttribute(PersistentEObject object,
EAttribute attribute,
int index)
Returns the value at the
index in the content of the attribute of the object. |
InternalEObject |
getContainer(InternalEObject internalObject)
Returns the object's
container. |
EStructuralFeature |
getContainingFeature(InternalEObject internalObject)
Returns the object's
containing feature. |
protected Object |
getFromMap(FeatureKey featureKey)
Returns the value associated to the
featureKey in the underlying database. |
protected Object |
getFromMap(PersistentEObject object,
EStructuralFeature feature)
Returns the value associated to (
object, feature) in the underlying database. |
protected Object |
getReference(PersistentEObject object,
EReference reference,
int index)
Returns the value at the
index in the content of the reference of the object. |
int |
indexOf(InternalEObject internalObject,
EStructuralFeature feature,
Object value)
Returns the first index of the given value in the
content of the object's feature. |
boolean |
isSet(InternalEObject internalObject,
EStructuralFeature feature)
Returns whether the object's feature is considered set.
|
int |
lastIndexOf(InternalEObject internalObject,
EStructuralFeature feature,
Object value)
Returns the last index of the given value in the
content of the object's feature. |
protected Object |
removeAttribute(PersistentEObject object,
EAttribute attribute,
int index)
Removes the value at the
index in the content of the attribute of the object. |
protected Object |
removeReference(PersistentEObject object,
EReference reference,
int index)
Removes the value at the
index in the content of the reference of the object. |
protected Object |
setAttribute(PersistentEObject object,
EAttribute attribute,
int index,
Object value)
Sets the value at the
index in the content of the attribute of the object. |
protected Object |
setReference(PersistentEObject object,
EReference reference,
int index,
PersistentEObject value)
Sets the value at the
index in the content of the reference of the object. |
int |
size(InternalEObject internalObject,
EStructuralFeature feature)
Returns the number of values in the
content of the object's feature. |
void |
unset(InternalEObject internalObject,
EStructuralFeature feature)
Unsets the feature of the object.
|
protected void |
updateContainment(PersistentEObject object,
EReference reference,
PersistentEObject referencedObject)
Tells the underlying database to put the
referencedObject in the containment list of the object. |
protected void |
updateInstanceOf(PersistentEObject object)
Computes the type of the
object in a ClassInfo object and persists it in the database. |
add, clearAttribute, clearReference, containsAttribute, containsReference, create, get, hashCode, indexOfAttribute, indexOfReference, isEmpty, isSetAttribute, isSetReference, lastIndexOfAttribute, lastIndexOfReference, move, parseProperty, remove, resource, save, serializeToProperty, set, toArray, toArray, unsetAttribute, unsetReferenceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllInstancesprotected static final int DEFAULT_CACHE_SIZE
protected final com.github.benmanes.caffeine.cache.Cache<Id,PersistentEObject> persistentObjectsCache
PersistentEObjects, identified by their Id.public DirectWriteMapDbStore(Resource.Internal resource, MapDbPersistenceBackend backend)
DirectWriteMapDbStore between the given resource and
the backend.resource - the resource to persist and accessbackend - the persistence back-end used to store the modelpublic boolean isSet(InternalEObject internalObject, EStructuralFeature feature)
AbstractDirectWriteStore
By default, calls the associated methods depending on the type of the feature.
isSet in interface InternalEObject.EStoreisSet in class AbstractDirectWriteStore<MapDbPersistenceBackend>internalObject - the object in question.feature - a feature of the object.true if the object's feature is considered set.AbstractDirectWriteStore.isSetAttribute(PersistentEObject, EAttribute),
AbstractDirectWriteStore.isSetReference(PersistentEObject, EReference)public void unset(InternalEObject internalObject, EStructuralFeature feature)
AbstractDirectWriteStore
By default, calls the associated methods depending on the type of the feature.
unset in interface InternalEObject.EStoreunset in class AbstractDirectWriteStore<MapDbPersistenceBackend>internalObject - the object in question.feature - a feature of the object.AbstractDirectWriteStore.unsetAttribute(PersistentEObject, EAttribute),
AbstractDirectWriteStore.unsetReference(PersistentEObject, EReference)public boolean contains(InternalEObject internalObject, EStructuralFeature feature, Object value)
AbstractDirectWriteStorecontent of the object's feature contains the given value.
By default, calls the associated methods depending on the type of the feature.
contains in interface InternalEObject.EStorecontains in class AbstractDirectWriteStore<MapDbPersistenceBackend>internalObject - the object in question.feature - a many-valued feature of the object.value - the value in question.true if the content of the object's feature contains the given value.AbstractDirectWriteStore.containsAttribute(PersistentEObject, EAttribute, Object),
AbstractDirectWriteStore.containsReference(PersistentEObject, EReference, PersistentEObject)public int indexOf(InternalEObject internalObject, EStructuralFeature feature, Object value)
AbstractDirectWriteStorecontent of the object's feature.
By default, calls the associated methods depending on the type of the feature.
indexOf in interface InternalEObject.EStoreindexOf in class AbstractDirectWriteStore<MapDbPersistenceBackend>internalObject - the object in question.feature - a many-valued feature of the object.value - the value in question.AbstractDirectWriteStore.indexOfAttribute(PersistentEObject, EAttribute, Object),
AbstractDirectWriteStore.indexOfReference(PersistentEObject, EReference, PersistentEObject)public int lastIndexOf(InternalEObject internalObject, EStructuralFeature feature, Object value)
AbstractDirectWriteStorecontent of the object's feature.
By default, calls the associated methods depending on the type of the feature.
lastIndexOf in interface InternalEObject.EStorelastIndexOf in class AbstractDirectWriteStore<MapDbPersistenceBackend>internalObject - the object in question.feature - a many-valued feature of the object.value - the value in question.AbstractDirectWriteStore.lastIndexOfAttribute(PersistentEObject, EAttribute, Object),
AbstractDirectWriteStore.lastIndexOfReference(PersistentEObject, EReference, PersistentEObject)public void clear(InternalEObject internalObject, EStructuralFeature feature)
AbstractDirectWriteStorecontent of the object's feature
By default, calls the associated methods depending on the type of the feature.
clear in interface InternalEObject.EStoreclear in class AbstractDirectWriteStore<MapDbPersistenceBackend>internalObject - the object in question.feature - a many-valued feature of the object.AbstractDirectWriteStore.clearAttribute(PersistentEObject, EAttribute),
AbstractDirectWriteStore.clearReference(PersistentEObject, EReference)protected Object getAttribute(PersistentEObject object, EAttribute attribute, int index)
AbstractDirectWriteStoreindex in the content of the attribute of the object.getAttribute in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectattribute - an attribute of the objectindex - an index within the content or PersistentStore.NO_INDEXAbstractDirectWriteStore.get(InternalEObject, EStructuralFeature, int)protected Object getReference(PersistentEObject object, EReference reference, int index)
AbstractDirectWriteStoreindex in the content of the reference of the object.getReference in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectreference - a reference of the objectindex - an index within the content or PersistentStore.NO_INDEXAbstractDirectWriteStore.get(InternalEObject, EStructuralFeature, int)protected Object setAttribute(PersistentEObject object, EAttribute attribute, int index, Object value)
AbstractDirectWriteStoreindex in the content of the attribute of the object.setAttribute in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectattribute - an attribute of the objectindex - an index within the content or PersistentStore.NO_INDEXvalue - the new valueAbstractDirectWriteStore.set(InternalEObject, EStructuralFeature, int, Object)protected Object setReference(PersistentEObject object, EReference reference, int index, PersistentEObject value)
AbstractDirectWriteStoreindex in the content of the reference of the object.setReference in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectreference - a reference of the objectindex - an index within the content or PersistentStore.NO_INDEXvalue - the new valueAbstractDirectWriteStore.set(InternalEObject, EStructuralFeature, int, Object)protected void addAttribute(PersistentEObject object, EAttribute attribute, int index, Object value)
AbstractDirectWriteStorevalue at the index in the content of the attribute of the object.addAttribute in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectattribute - a many-valued attribute of the objectindex - an index within the contentvalue - the value to addAbstractDirectWriteStore.add(InternalEObject, EStructuralFeature, int, Object)protected void addReference(PersistentEObject object, EReference reference, int index, PersistentEObject value)
AbstractDirectWriteStorevalue at the index in the content of the reference of the object.addReference in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectreference - a many-valued reference of the objectindex - an index within the contentvalue - the value to addAbstractDirectWriteStore.add(InternalEObject, EStructuralFeature, int, Object)protected Object removeAttribute(PersistentEObject object, EAttribute attribute, int index)
AbstractDirectWriteStoreindex in the content of the attribute of the object.removeAttribute in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectattribute - a many-valued attribute of the objectindex - the index within the content of the value to removeAbstractDirectWriteStore.remove(InternalEObject, EStructuralFeature, int)protected Object removeReference(PersistentEObject object, EReference reference, int index)
AbstractDirectWriteStoreindex in the content of the reference of the object.removeReference in class AbstractDirectWriteStore<MapDbPersistenceBackend>object - the objectreference - a many-valued reference of the objectindex - the index within the content of the value to removeAbstractDirectWriteStore.remove(InternalEObject, EStructuralFeature, int)public int size(InternalEObject internalObject, EStructuralFeature feature)
org.eclipse.emf.ecore.InternalEObject.EStorecontent of the object's feature.internalObject - the object in question.feature - a many-valued feature of the object.public InternalEObject getContainer(InternalEObject internalObject)
org.eclipse.emf.ecore.InternalEObject.EStorecontainer.EObject.eContainer()public EStructuralFeature getContainingFeature(InternalEObject internalObject)
org.eclipse.emf.ecore.InternalEObject.EStorecontaining feature.EObject.eContainingFeature()public EObject eObject(Id id)
PersistentStoreprotected void updateContainment(PersistentEObject object, EReference reference, PersistentEObject referencedObject)
referencedObject in the containment list of the object.
Containment and containers information are persisted in a dedicated Map. The method checks if an existing
container is stored and update it if needed.
object - the container PersistentEObjectreference - the containment EReferencereferencedObject - the PersistentEObject to add in the containment list of objectprotected void updateInstanceOf(PersistentEObject object)
object in a ClassInfo object and persists it in the database.
As for updateContainment(PersistentEObject, EReference, PersistentEObject), instance-of information are
handled in a dedicated Map, easing their access. The method checks that the Map doesn't contain
another type information for object and save it.
The type is not updated if object was previously mapped to another type.
object - the PersistentEObject to store the instance-of information fromprotected Object getFromMap(FeatureKey featureKey)
featureKey in the underlying database.featureKey - the FeatureKey to look forObject stored in the database if it exists, null otherwise. The returned Object can be a single element or a Collection.protected Object getFromMap(PersistentEObject object, EStructuralFeature feature)
object, feature) in the underlying database.
This method behaves like: getFromMap(FeatureKey.from(object, feature).
object - the PersistentEObject to look forfeature - the EStructuralFeature of object to look forObject stored in the database if it exists, null otherwise. The returned Object can be a single element or a Collection.getFromMap(FeatureKey)Copyright © 2013–2017 Atlanmod INRIA LINA Mines Nantes. All rights reserved.