K
- the key type.V
- the value type.public class DefaultJPAEntityValueManager<K extends Serializable,V extends Serializable> extends AbstractPersistenceValueManager<K,V>
CachedJPAEntityRepository
.Constructor and Description |
---|
DefaultJPAEntityValueManager(CachedJPAEntityRepository<K,V> repository,
PersistencesRestoreMethod persistencesRestoreMethod)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected CachedJPAEntity<K,V> |
constructEntity(K key,
V value,
Date expireDateTime)
Constructs an instance of "CachedGroupJPAEntity" clazz.
|
AbstractValueWrapper<K,V> |
constructWrapper(K key,
V value)
Construct a ValueWrapper for the value, but do not sets the value, this is done either in "restore" or "storeValue"
|
void |
flush()
This is ensures that any memory data that needs to be persisted is flushed.
|
CachedJPAEntityRepository<K,V> |
getRepository()
An instance of CachedJPAEntityRepository.
|
int |
removeAll()
Remove all persisted values from the value "storage".
|
void |
removeValue(AbstractValueWrapper<K,V> valueWrapper)
Removes the value
|
void |
restore(LRUCachingMap<K,V> map)
Restores any persisted key/values to the LRUCachingMap when the map is constructed.
|
V |
retrieveValue(AbstractValueWrapper<K,V> valueWrapper)
Retrives value via the data contained in the ValueWrapper
|
void |
storeValue(AbstractValueWrapper<K,V> valueWrapper,
K key,
V value,
Date expireDateTime)
Stores the value and giving the ValueWrapper enough information to retrieve/remove it again.
|
void |
updateExpireTime(AbstractValueWrapper<K,V> valueWrapper,
Date expireDateTime)
Update the expiration date time for a value.
|
getLogger, getPersistencesRestoreMethod, isPersisted
public DefaultJPAEntityValueManager(CachedJPAEntityRepository<K,V> repository, PersistencesRestoreMethod persistencesRestoreMethod) throws IllegalArgumentException, NullPointerException
repository
- which handles JPA access. (Like a DAO)persistencesRestoreMethod
- the restore method.IllegalArgumentException
- if the repository is invalid.NullPointerException
- if the repository is null
.public CachedJPAEntityRepository<K,V> getRepository()
public final void restore(LRUCachingMap<K,V> map)
ValueManager
map
- the map instance.LRUCachingMap.restoreCacheElement(Object, AbstractValueWrapper, Date)
,
PersistencesRestoreMethod
,
AbstractPersistenceValueManager
,
ValueManager.flush()
public final int removeAll()
ValueManager
public final AbstractValueWrapper<K,V> constructWrapper(K key, V value)
ValueManager
key
- the keyvalue
- the valueValueManager.restore(LRUCachingMap)
,
ValueManager.storeValue(AbstractValueWrapper, Object, Object, Date)
public final void removeValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManager
RuntimeException
- if for any reason the value could not be removed.public final V retrieveValue(AbstractValueWrapper<K,V> valueWrapper) throws RuntimeException
ValueManager
valueWrapper
- theRuntimeException
- if for any reason the value could not be retrieved.public final void storeValue(AbstractValueWrapper<K,V> valueWrapper, K key, V value, Date expireDateTime) throws RuntimeException
ValueManager
valueWrapper
- the wrapper instance to store the value or information about the value, this can be used to minimize the memory footprint.key
- the keyvalue
- the valueexpireDateTime
- the expiration datetime for the key, this can be stored on a persisted key/value and used in case of a restore.RuntimeException
- if for any reason the value could not be store.public void updateExpireTime(AbstractValueWrapper<K,V> valueWrapper, Date expireDateTime) throws RuntimeException
ValueManager
valueWrapper
- the wrapper which holds enough information to get the value.expireDateTime
- the new expireDateTimeRuntimeException
- if this for any reasons fails.public void flush()
protected CachedJPAEntity<K,V> constructEntity(K key, V value, Date expireDateTime) throws RuntimeException
key
- the keyvalue
- the valueexpireDateTime
- the expiration datetime.RuntimeException
- if the instance could not be created.Copyright © 2016. All rights reserved.