net.sourceforge.domian.repository
Class AbstractRepository<T extends Entity>

java.lang.Object
  extended by net.sourceforge.domian.repository.AbstractRepository<T>
All Implemented Interfaces:
Repository<T>
Direct Known Subclasses:
AbstractDomianCoreRepository

public abstract class AbstractRepository<T extends Entity>
extends java.lang.Object
implements Repository<T>

All Repository classes should extend this abstract class. It makes sure that all aliased methods behaves like specified in the Repository interface. Also, some default method implementations are included in this class.

Since:
0.4
Author:
Eirik Torske

Field Summary
protected  java.lang.Boolean supportsRecursiveIndexing
          Flag to indicate whether or not this particular repository instance add entity members as first class entities in the repository.
protected  java.lang.Boolean usesNativePartitioningSupport
          Flag to indicate whether or not this particular repository instance inhibits and uses its own mechanism for indexing entities.
 
Constructor Summary
AbstractRepository()
           
 
Method Summary
protected  java.lang.Boolean contains(T entity)
           
 java.lang.Long count(Specification<? extends T> specification)
          Alias of countAllEntitiesSpecifiedBy(Specification).
 java.lang.Long countAll(Specification<? extends T> specification)
          Alias of countAllEntitiesSpecifiedBy(Specification).
 java.lang.Long countAllEntitiesSpecifiedBy(Specification<? extends T> specification)
          Counts the number of entities approved by the given specification.
protected abstract  Specification<T> createUniqueSpecificationFor(T entity)
          Template method for creating unique specification for given entity
<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>
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 isIndexingEntitiesRecursively()
           
 java.lang.Boolean isPartitioningNatively()
          When true, the repository utilizes some sort of native partitioning mechanism, e.g.
<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).
protected abstract  void onMakePartition()
          Template method for partitioning callbacks.
 void putAll(java.util.Collection<? extends T> 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.Long
removeAll(Specification<V> specification)
          Alias of removeAllEntitiesSpecifiedBy(Specification).
<V extends T>
void
update(V entity, Specification<?> deltaSpecification)
          Updates an entity.
 
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
findAllEntitiesSpecifiedBy, iterateAllEntitiesSpecifiedBy, makePartition, put, remove, removeAllEntitiesSpecifiedBy, update
 

Field Detail

usesNativePartitioningSupport

protected java.lang.Boolean usesNativePartitioningSupport
Flag to indicate whether or not this particular repository instance inhibits and uses its own mechanism for indexing entities. If true, this will be the case (as we know it from RDBMSs). Furthermore, if this flag is true, partitioned repositories will reuse the repository instance across partitions. To improve search response time for repository partitions, the internal indexing mechanism must be applied whenever partitions are added.

Default is false.


supportsRecursiveIndexing

protected java.lang.Boolean supportsRecursiveIndexing
Flag to indicate whether or not this particular repository instance add entity members as first class entities in the repository. (a.k.a. recursive indexing). If true, this will be the case (as we know it from RDBMSs). Furthermore, if this flag is true, cascading puts, updates, and removals will also take place, if nothing else is stated in the Javadoc.

Default is false - only aggregate root is indexed/made searchable.

Constructor Detail

AbstractRepository

public AbstractRepository()
Method Detail

isPartitioningNatively

public java.lang.Boolean isPartitioningNatively()
Description copied from interface: Repository
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.

Specified by:
isPartitioningNatively in interface Repository<T extends Entity>
Returns:
true if repository utilizes some sort of native partitioning mechanism, e.g. RDBMS indices.

isIndexingEntitiesRecursively

public java.lang.Boolean isIndexingEntitiesRecursively()
Specified by:
isIndexingEntitiesRecursively in interface Repository<T extends Entity>
Returns:
true if member entities are stored recursively, and made searchable - false if only aggregate root is stored.

createUniqueSpecificationFor

protected abstract Specification<T> createUniqueSpecificationFor(T entity)
Template method for creating unique specification for given entity

Returns:
Guaranteed unique specification for given entity

contains

protected java.lang.Boolean contains(T entity)

onMakePartition

protected abstract void onMakePartition()
Template method for partitioning callbacks.


countAllEntitiesSpecifiedBy

public java.lang.Long countAllEntitiesSpecifiedBy(Specification<? extends T> specification)
Description copied from interface: Repository
Counts the number of entities approved by the given specification.

Specified by:
countAllEntitiesSpecifiedBy in interface Repository<T extends Entity>
Parameters:
specification - the entity specification
Returns:
the number of entities approved by the specification argument

countAll

public final java.lang.Long countAll(Specification<? extends T> specification)
Description copied from interface: Repository
Alias of countAllEntitiesSpecifiedBy(Specification).

Specified by:
countAll in interface Repository<T extends Entity>

count

public final java.lang.Long count(Specification<? extends T> specification)
Description copied from interface: Repository
Alias of countAllEntitiesSpecifiedBy(Specification).

Specified by:
count in interface Repository<T extends Entity>

iterateAll

public final <V extends T> java.util.Iterator<V> iterateAll(Specification<V> specification)
Description copied from interface: Repository
Alias of iterateAllEntitiesSpecifiedBy(Specification).

Specified by:
iterateAll in interface Repository<T extends Entity>

iterate

public final <V extends T> java.util.Iterator<V> iterate(Specification<V> specification)
Description copied from interface: Repository
Alias of iterateAllEntitiesSpecifiedBy(Specification).

Specified by:
iterate in interface Repository<T extends Entity>

findAll

public final <V extends T> java.util.Collection<V> findAll(Specification<V> specification)
Description copied from interface: Repository
Alias of findAllEntitiesSpecifiedBy(Specification).

Specified by:
findAll in interface Repository<T extends Entity>

find

public final <V extends T> java.util.Collection<V> find(Specification<V> specification)
Description copied from interface: Repository
Alias of findAllEntitiesSpecifiedBy(Specification).

Specified by:
find in interface Repository<T extends Entity>

findSingleEntitySpecifiedBy

public <V extends T> V findSingleEntitySpecifiedBy(Specification<V> specification)
Description copied from interface: Repository
Finds and returns one single entity approved by the given specification.

Specified by:
findSingleEntitySpecifiedBy in interface Repository<T extends Entity>
Parameters:
specification - the entity specification
Returns:
the sole entity specified by the specification argument, or null if no entity is found

findSingle

public final <V extends T> V findSingle(Specification<V> specification)
Description copied from interface: Repository
Alias of findSingleEntitySpecifiedBy(Specification).

Specified by:
findSingle in interface Repository<T extends Entity>

putAll

public void putAll(java.util.Collection<? extends T> collectionOfEntities)
Description copied from interface: Repository
Puts the given entities into this repository.

Specified by:
putAll in interface Repository<T extends Entity>
Parameters:
collectionOfEntities - the entities to be stored

update

public <V extends T> void update(V entity,
                                 Specification<?> deltaSpecification)
Description copied from interface: Repository
Updates an entity. When an entity is (re)-retrieved, all state changes will be visible, no matter what kinds of repository implementations being involved. Do notice that for all memory-based repositories (and possibly some delegated ones), 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.

Specified by:
update in interface Repository<T extends Entity>
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

removeAll

public final <V extends T> java.lang.Long removeAll(Specification<V> specification)
Description copied from interface: Repository
Alias of removeAllEntitiesSpecifiedBy(Specification).

Specified by:
removeAll in interface Repository<T extends Entity>

remove

public final <V extends T> java.lang.Long remove(Specification<V> specification)
Description copied from interface: Repository
Alias of removeAllEntitiesSpecifiedBy(Specification).

Specified by:
remove in interface Repository<T extends Entity>


Copyright © 2006-2010. All Rights Reserved.