net.sourceforge.domian.repository
Interface Repository<T extends Entity>

All Known Subinterfaces:
BinaryFormatRepository<T>, FakeRepository<T>, HumanReadableFormatRepository<T>, PartitionRepository<T>, PersistentRepository<T>, TextualFormatRepository<T>, VolatileRepository<T>
All Known Implementing Classes:
AbstractRepository, HashSetRepository, InMemoryRepository, NotImplementedRepository, NullRepository, PartitionRepositoryInvocationHandler, PartitionRepositoryReuseInvocationHandler, UnsupportedRepository

public interface Repository<T extends Entity>

Interface defining a repository for storing and retrieving Entity objects.

Since:
0.4
Author:
Eirik Torske

Method Summary
<V extends T>
java.lang.Long
count(Specification<V> specification)
          Alias of countAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.lang.Long
countAll(Specification<V> specification)
          Alias of countAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.lang.Long
countAllEntitiesSpecifiedBy(Specification<V> specification)
          Counts the number of entities approved by the given specification.
<V extends T>
java.util.Collection<V>
find(Specification<V> specification)
          Alias of findAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Collection<V>
findAll(Specification<V> specification)
          Alias of findAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Collection<V>
findAllEntitiesSpecifiedBy(Specification<V> specification)
          Finds and returns all entities approved by the given specification.
<V extends T>
V
findSingle(Specification<V> specification)
          Alias of findSingleEntitySpecifiedBy(Specification).
<V extends T>
V
findSingleEntitySpecifiedBy(Specification<V> specification)
          Finds and returns one single entity approved by the given specification.
 java.lang.Boolean isDoingNativePartitioning()
          When true, the repository utilizes some sort of native partitioning mechanism, e.g.
 java.lang.Boolean isDoingRecursiveEntityAdding()
           
<V extends T>
java.util.Iterator<V>
iterate(Specification<V> specification)
          Alias of iterateAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Iterator<V>
iterateAll(Specification<V> specification)
          Alias of iterateAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.util.Iterator<V>
iterateAllEntitiesSpecifiedBy(Specification<V> specification)
          Finds and returns all entities approved by the given specification.
<V extends T>
void
put(V entity)
          Puts the given entity into this repository.
<V extends T>
void
putAll(java.util.Collection<? extends V> collectionOfEntities)
          Puts the given entities into this repository.
<V extends T>
java.lang.Long
remove(Specification<V> specification)
          Alias of removeAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.lang.Boolean
remove(V entity)
          Removes the given entity from this repository.
<V extends T>
java.lang.Long
removeAll(Specification<V> specification)
          Alias of removeAllEntitiesSpecifiedBy(Specification).
<V extends T>
java.lang.Long
removeAllEntitiesSpecifiedBy(Specification<V> specification)
          Removes all entities approved by the given specification.
 void setSynchronizer(Synchronizer synchronizer)
          A synchronizer used to control concurrent and exclusive access to repository methods.
<V extends T>
void
update(V entity)
          Updates an entity.
<V extends T>
void
update(V entity, CompositeSpecification<?> deltaSpecification)
          Updates an entity.
 

Method Detail

countAllEntitiesSpecifiedBy

<V extends T> java.lang.Long countAllEntitiesSpecifiedBy(Specification<V> specification)
Counts the number of entities approved by the given specification.

Parameters:
specification - the entity specification
Returns:
the number of entities approved by the specification argument
Throws:
java.lang.IllegalArgumentException - if parameter is null

countAll

<V extends T> java.lang.Long countAll(Specification<V> specification)
Alias of countAllEntitiesSpecifiedBy(Specification).


count

<V extends T> java.lang.Long count(Specification<V> specification)
Alias of countAllEntitiesSpecifiedBy(Specification).


iterateAllEntitiesSpecifiedBy

<V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification. An iterator is returned for lazy retrieval of the entities.

Parameters:
specification - the entity specification
Returns:
an iterator with all entities approved by the specification argument
Throws:
java.lang.IllegalArgumentException - if parameter is null

iterateAll

<V extends T> java.util.Iterator<V> iterateAll(Specification<V> specification)
Alias of iterateAllEntitiesSpecifiedBy(Specification).


iterate

<V extends T> java.util.Iterator<V> iterate(Specification<V> specification)
Alias of iterateAllEntitiesSpecifiedBy(Specification).


findAllEntitiesSpecifiedBy

<V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
Finds and returns all entities approved by the given specification.

Parameters:
specification - the entity specification
Returns:
a collection of all entities approved by the specification argument, or an empty set if no entities are found and approved
Throws:
java.lang.IllegalArgumentException - if parameter is null

findAll

<V extends T> java.util.Collection<V> findAll(Specification<V> specification)
Alias of findAllEntitiesSpecifiedBy(Specification).


find

<V extends T> java.util.Collection<V> find(Specification<V> specification)
Alias of findAllEntitiesSpecifiedBy(Specification).


findSingleEntitySpecifiedBy

<V extends T> V findSingleEntitySpecifiedBy(Specification<V> specification)
Finds and returns one single entity approved by the given specification.

Parameters:
specification - the entity specification
Returns:
the sole entity specified by the specification argument, or null if no entity is found
Throws:
java.lang.IllegalArgumentException - if parameter is null
java.lang.IllegalArgumentException - if more then one entity is specified by the given specification

findSingle

<V extends T> V findSingle(Specification<V> specification)
Alias of findSingleEntitySpecifiedBy(Specification).


put

<V extends T> void put(V entity)
Puts the given entity into this repository.

Parameters:
entity - the entity to be stored

putAll

<V extends T> void putAll(java.util.Collection<? extends V> collectionOfEntities)
Puts the given entities into this repository.

Parameters:
collectionOfEntities - the entities to be stored
Throws:
java.lang.IllegalArgumentException - if parameter is null

update

<V extends T> void update(V entity)
Updates an entity. When an entity is (re)-retrieved, all state changes will be visible, no matter what kinds of repository implementations beeing involved. Do notice that for all memory-based repositories, entity updates are of course immediately visible.

(Only applicable for persistent repositories doing explicit data writes, like 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

<V extends T> void update(V entity,
                          CompositeSpecification<?> deltaSpecification)
Updates an entity. When an entity is (re)-retrieved, all state changes will be visible, no matter what kinds of repository implementations beeing involved. Do notice that for all memory-based repositories, entity updates are of course immediately visible.

(Only applicable for persistent repositories doing direct data writes, like 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.

Type Parameters:
V - the entity type
Parameters:
entity - the entity
deltaSpecification - for optimistic locking schemes: a specification specifying the differences/added state between this update and the previously retrieved entity version The specification should be a conjuction of field bound equality specifications only, or null if optimistic locking with automatic retries is completely out of scope

removeAllEntitiesSpecifiedBy

<V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
Removes all entities approved by the given specification.

Parameters:
specification - the entity specification
Returns:
the number of removed entities
Throws:
java.lang.IllegalArgumentException - if parameter is null

removeAll

<V extends T> java.lang.Long removeAll(Specification<V> specification)
Alias of removeAllEntitiesSpecifiedBy(Specification).


remove

<V extends T> java.lang.Long remove(Specification<V> specification)
Alias of removeAllEntitiesSpecifiedBy(Specification).


remove

<V extends T> java.lang.Boolean remove(V entity)
Removes the given entity from this repository.

Parameters:
entity - the entity to be removed
Returns:
true if the entity is found and removed, otherwise false

isDoingNativePartitioning

java.lang.Boolean isDoingNativePartitioning()
When true, the repository utilizes some sort of native partitioning mechanism, e.g. RDBMS indices. If true, partition repositories may be reusing the same repository instance.

Returns:
true if repository utilizes some sort of native partitioning mechanism, e.g. RDBMS indices.

isDoingRecursiveEntityAdding

java.lang.Boolean isDoingRecursiveEntityAdding()
Returns:
true if member entities are stored recursively, and made searchable - false if only aggregate root is stored.

setSynchronizer

void setSynchronizer(Synchronizer synchronizer)
A synchronizer used to control concurrent and exclusive access to repository methods. E.g. all methods dealing with partitioning should be run in an exclusive manner.



Copyright © 2006-2009. All Rights Reserved.