|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.datastore.engine.EntityPersister org.springframework.datastore.engine.LockableEntityPersister org.springframework.datastore.keyvalue.engine.AbstractKeyValueEntityPesister<T,K>
public abstract class AbstractKeyValueEntityPesister<T,K>
Abstract implementation of the EntityPersister abstract class for key/value style stores
Field Summary | |
---|---|
protected ClassMapping |
classMapping
|
protected String |
entityFamily
|
Fields inherited from class org.springframework.datastore.engine.LockableEntityPersister |
---|
DEFAULT_TIMEOUT |
Fields inherited from class org.springframework.datastore.engine.EntityPersister |
---|
interceptors, proxyFactory, session |
Constructor Summary | |
---|---|
AbstractKeyValueEntityPesister(MappingContext context,
PersistentEntity entity,
Session session)
|
Method Summary | |
---|---|
protected Serializable |
convertToNativeKey(Serializable nativeKey)
|
protected EntityAccess |
createEntityAccess(PersistentEntity persistentEntity,
Object obj)
|
protected EntityAccess |
createEntityAccess(PersistentEntity persistentEntity,
Object obj,
T nativeEntry)
|
protected abstract T |
createNewEntry(String family)
Creates a new entry for the given family. |
protected Object |
createObjectFromNativeEntry(PersistentEntity persistentEntity,
Serializable nativeKey,
T nativeEntry)
|
protected void |
deleteEntities(PersistentEntity persistentEntity,
Iterable objects)
|
protected void |
deleteEntity(PersistentEntity persistentEntity,
Object obj)
|
protected abstract void |
deleteEntries(String family,
List<K> keys)
Deletes one or many entries for the given list of Keys |
protected abstract void |
deleteEntry(String family,
K key)
Deletes a single entry |
protected PersistentEntity |
discriminatePersistentEntity(PersistentEntity persistentEntity,
T nativeEntry)
Subclasses should override to customize how entities in hierarchies are discriminated |
protected abstract K |
generateIdentifier(PersistentEntity persistentEntity,
T id)
|
abstract AssociationIndexer |
getAssociationIndexer(Association association)
Obtains an indexer for the given association |
ClassMapping |
getClassMapping()
|
String |
getEntityFamily()
|
protected abstract Object |
getEntryValue(T nativeEntry,
String property)
Reads a value for the given key from the native entry |
protected String |
getFamily(PersistentEntity persistentEntity,
ClassMapping<Family> cm)
|
protected String |
getIdentifierName(ClassMapping cm)
|
protected String |
getKeyspace(ClassMapping<Family> cm,
String defaultValue)
|
abstract PropertyValueIndexer |
getPropertyIndexer(PersistentProperty property)
Obtains an indexer for a particular property |
protected K |
inferNativeKey(String family,
Object identifier)
Used to establish the native key to use from the identifier defined by the object |
boolean |
isLocked(Object o)
Subclasses can override to provide locking semantics |
Object |
lock(Serializable id)
Locks an object for the given identifier returning the locked instance |
Object |
lock(Serializable id,
int timeout)
Acquire a lock using the given identifier and timeout delay |
protected void |
lockEntry(PersistentEntity persistentEntity,
String entityFamily,
Serializable id,
int timeout)
Subclasses can override to provide locking semantics |
protected List<Serializable> |
persistEntities(PersistentEntity persistentEntity,
Iterable objs)
This is a rather simplistic and unoptimized implementation. |
protected Serializable |
persistEntity(PersistentEntity persistentEntity,
Object obj)
Persist the given persistent entity |
Object |
proxy(Serializable key)
Creates a proxy for the given key |
protected K |
readObjectIdentifier(EntityAccess entityAccess,
ClassMapping<Family> cm)
|
Serializable |
refresh(Object o)
Refreshes the given objects state |
protected void |
refreshObjectStateFromNativeEntry(PersistentEntity persistentEntity,
Object obj,
Serializable nativeKey,
T nativeEntry)
|
protected List<Object> |
retrieveAllEntities(PersistentEntity persistentEntity,
Iterable<Serializable> keys)
Simplistic default implementation of retrieveAllEntities that iterates over each key and retrieves the entities one-by-one. |
protected List<Object> |
retrieveAllEntities(PersistentEntity persistentEntity,
Serializable[] keys)
Simplistic default implementation of retrieveAllEntities that iterates over each key and retrieves the entities one-by-one. |
protected Object |
retrieveEntity(PersistentEntity persistentEntity,
Serializable nativeKey)
Retrieve a PersistentEntity for the given mappingContext and key |
protected abstract T |
retrieveEntry(PersistentEntity persistentEntity,
String family,
Serializable key)
Reads the native form of a Key/value datastore entry. |
protected abstract void |
setEntryValue(T nativeEntry,
String key,
Object value)
Sets a value on an entry |
protected abstract K |
storeEntry(PersistentEntity persistentEntity,
K storeId,
T nativeEntry)
Stores the native form of a Key/value datastore to the actual data store |
void |
unlock(Object o)
Unlocks a locked object |
protected void |
unlockEntry(PersistentEntity persistentEntity,
String entityFamily,
Serializable id)
Subclasses to override to provide locking semantics |
protected abstract void |
updateEntry(PersistentEntity persistentEntity,
K key,
T entry)
Updates an existing entry to the actual datastore |
Methods inherited from class org.springframework.datastore.engine.EntityPersister |
---|
addEntityInterceptor, delete, delete, getMappingContext, getObjectIdentifier, getPersistentEntity, getProxyFactory, getType, persist, persist, retrieve, retrieveAll, retrieveAll, setEntityInterceptors |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.springframework.datastore.engine.Persister |
---|
createQuery |
Field Detail |
---|
protected String entityFamily
protected ClassMapping classMapping
Constructor Detail |
---|
public AbstractKeyValueEntityPesister(MappingContext context, PersistentEntity entity, Session session)
Method Detail |
---|
public String getEntityFamily()
public ClassMapping getClassMapping()
protected String getFamily(PersistentEntity persistentEntity, ClassMapping<Family> cm)
protected String getKeyspace(ClassMapping<Family> cm, String defaultValue)
protected void deleteEntity(PersistentEntity persistentEntity, Object obj)
deleteEntity
in class EntityPersister
protected EntityAccess createEntityAccess(PersistentEntity persistentEntity, Object obj)
createEntityAccess
in class EntityPersister
protected EntityAccess createEntityAccess(PersistentEntity persistentEntity, Object obj, T nativeEntry)
protected abstract void deleteEntry(String family, K key)
family
- The familykey
- The keyprotected final void deleteEntities(PersistentEntity persistentEntity, Iterable objects)
deleteEntities
in class EntityPersister
public final Object lock(Serializable id) throws org.springframework.dao.CannotAcquireLockException
LockableEntityPersister
lock
in class LockableEntityPersister
id
- The identifier
org.springframework.dao.CannotAcquireLockException
- Thrown if a lock couldn't be acquired before the default timeout elapsedpublic final Object lock(Serializable id, int timeout) throws org.springframework.dao.CannotAcquireLockException
LockableEntityPersister
lock
in class LockableEntityPersister
id
- the identifiertimeout
- the amount of time to wait before giving up
org.springframework.dao.CannotAcquireLockException
protected void lockEntry(PersistentEntity persistentEntity, String entityFamily, Serializable id, int timeout)
persistentEntity
- The PesistentEntity instnaceentityFamily
- The familyid
- The identifertimeout
- The lock timeout in secondspublic boolean isLocked(Object o)
isLocked
in class LockableEntityPersister
o
- The object
public void unlock(Object o)
LockableEntityPersister
unlock
in class LockableEntityPersister
o
- The object to unlockprotected void unlockEntry(PersistentEntity persistentEntity, String entityFamily, Serializable id)
persistentEntity
- The persistent entityentityFamily
- The entity familyid
- The identiferprotected final Object retrieveEntity(PersistentEntity persistentEntity, Serializable nativeKey)
EntityPersister
retrieveEntity
in class EntityPersister
persistentEntity
- The entitynativeKey
- The key
protected Serializable convertToNativeKey(Serializable nativeKey)
public Object proxy(Serializable key)
Persister
key
- The key
public Serializable refresh(Object o)
Persister
o
- The object to refresh
protected Object createObjectFromNativeEntry(PersistentEntity persistentEntity, Serializable nativeKey, T nativeEntry)
protected void refreshObjectStateFromNativeEntry(PersistentEntity persistentEntity, Object obj, Serializable nativeKey, T nativeEntry)
protected PersistentEntity discriminatePersistentEntity(PersistentEntity persistentEntity, T nativeEntry)
persistentEntity
- The PersistentEntitynativeEntry
- The native entry
protected final Serializable persistEntity(PersistentEntity persistentEntity, Object obj)
EntityPersister
persistEntity
in class EntityPersister
persistentEntity
- The PersistentEntity
protected abstract K generateIdentifier(PersistentEntity persistentEntity, T id)
public abstract PropertyValueIndexer getPropertyIndexer(PersistentProperty property)
property
- The property to index
public abstract AssociationIndexer getAssociationIndexer(Association association)
association
- The association
protected K readObjectIdentifier(EntityAccess entityAccess, ClassMapping<Family> cm)
protected String getIdentifierName(ClassMapping cm)
protected List<Serializable> persistEntities(PersistentEntity persistentEntity, Iterable objs)
persistEntities
in class EntityPersister
persistentEntity
- The persistent entityobjs
- The objext to persist
protected List<Object> retrieveAllEntities(PersistentEntity persistentEntity, Iterable<Serializable> keys)
retrieveAllEntities
in class EntityPersister
persistentEntity
- The persist entitykeys
- The keys
protected List<Object> retrieveAllEntities(PersistentEntity persistentEntity, Serializable[] keys)
retrieveAllEntities
in class EntityPersister
persistentEntity
- The persist entitykeys
- The keys
protected K inferNativeKey(String family, Object identifier)
family
- The familyidentifier
- The identifier specified by the object
protected abstract T createNewEntry(String family)
family
- The family
protected abstract Object getEntryValue(T nativeEntry, String property)
nativeEntry
- The native entry. Could be a ColumnFamily, a BigTable entity, a Map etc.property
- The property key
protected abstract void setEntryValue(T nativeEntry, String key, Object value)
nativeEntry
- The native entry such as a BigTable Entity, ColumnFamily etc.key
- The keyvalue
- The valueprotected abstract T retrieveEntry(PersistentEntity persistentEntity, String family, Serializable key)
persistentEntity
- The persistent entityfamily
- The familykey
- The key
protected abstract K storeEntry(PersistentEntity persistentEntity, K storeId, T nativeEntry)
persistentEntity
- The persistent entitystoreId
- nativeEntry
- The native form. Could be a a ColumnFamily, BigTable Entity etc.
protected abstract void updateEntry(PersistentEntity persistentEntity, K key, T entry)
persistentEntity
- The PersistentEntitykey
- The key of the object to updateentry
- The entryprotected abstract void deleteEntries(String family, List<K> keys)
family
- The familykeys
- The keys
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |