|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.domian.repository.AbstractRepository<T> net.sourceforge.domian.repository.AbstractDomianCoreRepository<T> net.sourceforge.domian.repository.InMemoryRepository<T>
public class InMemoryRepository<T extends Entity>
Volatile repository for concurrent environments.
This repository is suitable for all applications with no need for persistent objects. This repository is backed by aConcurrentHashMap
.
Only the Map
keys are used, not the values.
Resource usage | |
---|---|
Storing | O(1) |
Counting | O(N) |
Finding | O(N) |
Removing | O(N) |
Nested Class Summary | |
---|---|
protected static class |
InMemoryRepository.InMemoryRepositoryIterator<V extends Entity,T extends Entity>
Inner iterator class for InMemoryRepository . |
Field Summary | |
---|---|
protected java.util.concurrent.ConcurrentMap<T,java.lang.Object> |
db
|
protected static java.lang.Object |
DUMMY_ELEMENT
|
Fields inherited from class net.sourceforge.domian.repository.AbstractDomianCoreRepository |
---|
DEFAULT_DOMIAN_ROOT_DIR_NAME, DEFAULT_DOMIAN_ROOT_PATH, log, synchronizer |
Fields inherited from class net.sourceforge.domian.repository.AbstractRepository |
---|
supportsRecursiveIndexing, usesNativePartitioningSupport |
Constructor Summary | |
---|---|
InMemoryRepository()
|
Method Summary | ||
---|---|---|
java.lang.Long |
countAllEntities()
Extra method Counts all entities in repository in the quickest possible way. |
|
|
findAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. |
|
|
iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. |
|
|
put(V entity)
Puts the given entity into this repository. |
|
|
remove(V entity)
Removes the given entity from this repository. |
|
|
removeAllEntitiesSpecifiedBy(Specification<V> specification)
Removes all entities approved by the given specification. |
|
void |
removeAllEntitites()
Extra method Purges all entities in repository withour no further ado. |
|
|
update(V entity)
Updates an entity. |
Methods inherited from class net.sourceforge.domian.repository.AbstractDomianCoreRepository |
---|
createUniqueSpecificationFor, getSynchronizer, makePartition, onMakePartition, setSynchronizer |
Methods inherited from class net.sourceforge.domian.repository.AbstractRepository |
---|
contains, count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, findSingleEntitySpecifiedBy, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, putAll, remove, removeAll, update |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface net.sourceforge.domian.repository.Repository |
---|
count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findSingle, findSingleEntitySpecifiedBy, isIndexingEntitiesRecursively, isPartitioningNatively, iterate, iterateAll, makePartition, putAll, remove, removeAll, update |
Field Detail |
---|
protected static final java.lang.Object DUMMY_ELEMENT
protected java.util.concurrent.ConcurrentMap<T extends Entity,java.lang.Object> db
Constructor Detail |
---|
public InMemoryRepository()
Method Detail |
---|
public java.lang.Long countAllEntities()
public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
iterateAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
findAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public <V extends T> void put(V entity)
Repository
put
in interface Repository<T extends Entity>
entity
- the entity to be storedpublic <V extends T> void update(V entity)
Repository
PersistenceDefinition.FILE
, and possibly PersistenceDefinition.DELEGATED
...
For all other persistence definitions, this method is redundant/not applicable.
Anyway, by applying this method in a consistent manner, an eventual repository migration will not need any code changes.
update
in interface Repository<T extends Entity>
public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
Repository
removeAllEntitiesSpecifiedBy
in interface Repository<T extends Entity>
specification
- the entity specification
public void removeAllEntitites()
public <V extends T> java.lang.Boolean remove(V entity)
Repository
remove
in interface Repository<T extends Entity>
entity
- the entity to be removed
true
if the entity is found and removed, otherwise false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |