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

All Superinterfaces:
Repository<T>
All Known Implementing Classes:
PartitionRepositoryInvocationHandler, PartitionRepositoryReuseInvocationHandler

public interface PartitionRepository<T extends Entity>
extends Repository<T>

Interface for specification-based partitioned repositories.

Partitioned repositories will not consist of a single repository instance, but rather a directed acyclic graph (DAG) of repository instances. Each repository partition is defined by a Specification, and these partitions are organized following the semantics of specification subsumptions.

One might regard partitions as repository indices, and the routine of adding them as indexing the overall repository.

Since:
0.4
Author:
Eirik Torske
See Also:
Specifications subsumption generalizationOf, Specifications subsumption specialCaseOf

Method Summary
<V extends T>
PartitionRepository<V>
addPartitionFor(Specification<V> partitionSpecification)
          Adds a new partition to this repository.
<V extends T>
PartitionRepository<V>
addPartitionFor(Specification<V> partitionSpecification, Repository<? super V> partitionRepository)
          Adds a new partition to this repository.
<V extends T>
PartitionRepository<V>
addPartitionFor(Specification<V> partitionSpecification, java.lang.String repositoryId)
          Adds a new partition to this repository.
 void collectAllPartitions(java.util.Map<Specification<? extends T>,PartitionRepository> partitionMap)
          Populates the given map with a flattened and recursive view of all partitions in this repository.
<R extends Repository>
void
collectAllPartitionsWithRepositorySatisfying(Specification<R> specification, java.util.Map<Specification<? extends T>,PartitionRepository> partitionMap)
          Populates the given map with a flattened and recursive view of all partitions in this repository, satisfying the given specification.
<V extends T>
PartitionRepository
findPartitionFor(Specification<V> specification)
           
 java.util.Map<Specification<? extends T>,PartitionRepository> getAllPartitions()
          Optional: mainly added for testing purposes, may throw UnsupportedOperationException
<V extends T>
java.util.Set<V>
getPartitionOnlyEntities()
          This method applies to this partition only!
 java.util.Map<Specification<? extends T>,PartitionRepository> getPartitions()
          Optional: mainly added for testing purposes, may throw UnsupportedOperationException

This method applies to this partition only!

 Specification<T> getPartitionSpecification()
          This method applies to this partition only!
 PartitionRepository<? super T> getRootRepository()
           
 PartitionRepository<? super T> getSuperPartitionRepository()
          This method applies to this partition only!
 Repository<T> getTargetRepository()
          This method applies to this partition only!
 java.lang.Class<T> getType()
           
 java.lang.Boolean isLeafPartition()
          This method applies to this partition only!
 java.lang.Boolean isRootPartition()
          This method applies to this partition only!
 void repartition()
          Repartitions the entire repository.
<V extends T>
java.lang.Boolean
repartition(V entity)
          When an entity is altered, this method must be explicitely invoked to reassure proper placement in the repository partition hierarchy.
 void setPartitionSpecification(Specification<T> specification)
          This method applies to this partition only!
 void setSuperPartitionRepository(PartitionRepository<? super T> specification)
          This method applies to this partition only!
 void setSuperPartitionSpecification(Specification<? super T> specification)
          This method applies to this partition only!
 
Methods inherited from interface net.sourceforge.domian.repository.Repository
count, countAll, countAllEntitiesSpecifiedBy, find, findAll, findAllEntitiesSpecifiedBy, findSingle, findSingleEntitySpecifiedBy, isDoingNativePartitioning, isDoingRecursiveEntityAdding, iterate, iterateAll, iterateAllEntitiesSpecifiedBy, put, putAll, remove, remove, removeAll, removeAllEntitiesSpecifiedBy, setSynchronizer, update, update
 

Method Detail

getType

java.lang.Class<T> getType()
Returns:
the type of entities residing in this repository

isRootPartition

java.lang.Boolean isRootPartition()
This method applies to this partition only!

Returns:
true if this repository partition is the root partition (does not have a super partitions)

getRootRepository

PartitionRepository<? super T> getRootRepository()
Returns:
the root repository of this partitioned repository graph

isLeafPartition

java.lang.Boolean isLeafPartition()
This method applies to this partition only!

Returns:
true if this repository partition is a leaf partition (does not have any sub partitions)

addPartitionFor

<V extends T> PartitionRepository<V> addPartitionFor(Specification<V> partitionSpecification)
Adds a new partition to this repository. The partition is specified (indexed) by a Specification. The new partition repository will be of the same type as this repository.

Parameters:
partitionSpecification - the specification specifying the partition
Returns:
the newly created partition

addPartitionFor

<V extends T> PartitionRepository<V> addPartitionFor(Specification<V> partitionSpecification,
                                                     java.lang.String repositoryId)
Adds a new partition to this repository. The partition is specified (indexed) by a Specification. The new partition repository will be of the same type as this repository.

Parameters:
partitionSpecification - the specification specifying the partition
repositoryId - the repository id; a non-blank value is mandatory for all persistent repositories
Returns:
the newly created partition

addPartitionFor

<V extends T> PartitionRepository<V> addPartitionFor(Specification<V> partitionSpecification,
                                                     Repository<? super V> partitionRepository)
Adds a new partition to this repository. The partition is specified (indexed) by a Specification.

Parameters:
partitionSpecification - the specification specifying the partition
partitionRepository - the partition repository
Returns:
the newly created partition

repartition

<V extends T> java.lang.Boolean repartition(V entity)
When an entity is altered, this method must be explicitely invoked to reassure proper placement in the repository partition hierarchy.

If any repository implementation does this implicitly in some fashion, this should be documented, e.g. in the Javadoc.

Parameters:
entity - the entity to be repartitioned
Returns:
true if entity was repartitioned

repartition

void repartition()
Repartitions the entire repository.


findPartitionFor

<V extends T> PartitionRepository findPartitionFor(Specification<V> specification)
Parameters:
specification - sub-partition specification
Returns:
the most specialized generalization of the specified partition (possibly this partition), or null if none are found

setSuperPartitionSpecification

void setSuperPartitionSpecification(Specification<? super T> specification)
This method applies to this partition only!


getSuperPartitionRepository

PartitionRepository<? super T> getSuperPartitionRepository()
This method applies to this partition only!

Returns:
the repository in the super partition

setSuperPartitionRepository

void setSuperPartitionRepository(PartitionRepository<? super T> specification)
This method applies to this partition only!


getPartitionSpecification

Specification<T> getPartitionSpecification()
This method applies to this partition only!

Returns:
the specification defining this partition

setPartitionSpecification

void setPartitionSpecification(Specification<T> specification)
This method applies to this partition only!


getTargetRepository

Repository<T> getTargetRepository()
This method applies to this partition only!

This method is a ( at the moment) necessary workaround for missing functionality regarding runtime modification of the Repository instance. Not only the Repository instance in action must be modified, but all super partitions leading up to the root repository as well. Is it possible anyway...?

Returns:
the delegated repository instance for this partition if any; otherwise null

getPartitionOnlyEntities

<V extends T> java.util.Set<V> getPartitionOnlyEntities()
This method applies to this partition only!

Returns:
a set of all entities residing in this particular partition

getPartitions

java.util.Map<Specification<? extends T>,PartitionRepository> getPartitions()
Optional: mainly added for testing purposes, may throw UnsupportedOperationException

This method applies to this partition only!

Returns:
the direct sub-partitions of this PartitionRepository only
Throws:
java.lang.UnsupportedOperationException - if not supported

getAllPartitions

java.util.Map<Specification<? extends T>,PartitionRepository> getAllPartitions()
Optional: mainly added for testing purposes, may throw UnsupportedOperationException

Returns:
a flattened view of all sub-partitions from this PartitionRepository and below
Throws:
java.lang.UnsupportedOperationException - if not supported

collectAllPartitions

void collectAllPartitions(java.util.Map<Specification<? extends T>,PartitionRepository> partitionMap)
Populates the given map with a flattened and recursive view of all partitions in this repository.

Optional: mainly added for testing purposes, may throw UnsupportedOperationException

Parameters:
partitionMap - the index->partition map
Throws:
java.lang.IllegalArgumentException - if the partition map is null
java.lang.UnsupportedOperationException - if not supported

collectAllPartitionsWithRepositorySatisfying

<R extends Repository> void collectAllPartitionsWithRepositorySatisfying(Specification<R> specification,
                                                                         java.util.Map<Specification<? extends T>,PartitionRepository> partitionMap)
Populates the given map with a flattened and recursive view of all partitions in this repository, satisfying the given specification.

Optional: mainly added for testing purposes, may throw UnsupportedOperationException

Parameters:
specification - the specification to satisfy to be included in result map
partitionMap - the index->partition map
Throws:
java.lang.IllegalArgumentException - if the partition map is null
java.lang.UnsupportedOperationException - if not supported


Copyright © 2006-2009. All Rights Reserved.