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

java.lang.Object
  extended by net.sourceforge.domian.repository.AbstractRepository<T>
      extended by net.sourceforge.domian.repository.AbstractDomianCoreRepository<T>
          extended by net.sourceforge.domian.repository.AbstractXStreamXmlFileRepository<T>
              extended by net.sourceforge.domian.repository.AbstractXStreamXmlFilePerEntityRepository<T>
                  extended by net.sourceforge.domian.repository.XStreamXmlFilePerEntityRepository<T>
All Implemented Interfaces:
HumanReadableFormatRepository<T>, PersistentRepository<T>, Repository<T>, TextualFormatRepository<T>

public class XStreamXmlFilePerEntityRepository<T extends Entity>
extends AbstractXStreamXmlFilePerEntityRepository<T>

A persistent repository backed by XStream functionality.

The only persistence definition supported by this repository is PersistenceDefinition.FILE. All repository operations are executed in an exclusive fashion, applying pessimistic locking. Translated into ACID terms, this corresponds to isolation level SERIALIZABLE.

All entities in this repository are persisted into individual XML files. The typical disc footprint is 1KB per entity. The persistence format is human readable XStream XML. The file encoding is UTF-8.

File-based stores counts as persistent storage media, although the nature of the synchronous writings to disc obviously depends on the file system implementations involved.

NB! When used as a partition repository, this repository implementation does not reflect altered state between partitions. When changing state in entities residing in more han one partition, for which at least one of them is a XStreamXmlFilePerEntityRepository, explicit updates for all partitions involved are needed.

Since:
0.4
Author:
Eirik Torske
See Also:
XStream, PersistenceDefinition.FILE

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.domian.repository.AbstractXStreamXmlFilePerEntityRepository
AbstractXStreamXmlFilePerEntityRepository.EntityId_NamedXStreamFilePersistenceStrategy, AbstractXStreamXmlFilePerEntityRepository.EntityIdNamedXStreamXmlSet<T extends Entity>, AbstractXStreamXmlFilePerEntityRepository.FindAllEntitiesSpecifiedBy<T>, AbstractXStreamXmlFilePerEntityRepository.IterateAllEntitiesSpecifiedBy<T>, AbstractXStreamXmlFilePerEntityRepository.Put<T extends Entity>, AbstractXStreamXmlFilePerEntityRepository.PutWithoutEntityExistsCheck<T extends Entity>, AbstractXStreamXmlFilePerEntityRepository.Remove<T extends Entity>, AbstractXStreamXmlFilePerEntityRepository.RemoveAllEntitiesSpecifiedBy<T extends Entity>, AbstractXStreamXmlFilePerEntityRepository.XStreamXmlFileEntityIterator<T>
 
Field Summary
protected static java.lang.String DEFAULT_REPOSITORY_ROOT_DIR_NAME
           
protected static java.lang.String DEFAULT_REPOSITORY_ROOT_PATH
           
 
Fields inherited from class net.sourceforge.domian.repository.AbstractXStreamXmlFileRepository
repositoryId, repositoryRootPath, XSTREAM_XML_FILE_SUFFIX
 
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
XStreamXmlFilePerEntityRepository(java.lang.String repositoryId)
           
XStreamXmlFilePerEntityRepository(java.lang.String repositoryRootPath, java.lang.String repositoryId)
           
XStreamXmlFilePerEntityRepository(java.lang.String repositoryRootPath, java.lang.String repositoryId, Synchronizer synchronizer)
           
XStreamXmlFilePerEntityRepository(java.lang.String repositoryId, Synchronizer synchronizer)
           
 
Method Summary
 void close()
           
 java.lang.Long countAllEntities()
           
<V extends T>
java.util.Collection<V>
findAllEntitiesSpecifiedBy(Specification<V> specification)
           
 java.lang.String getFormat()
           
 EntityMetaData getMetaDataFor(T entity)
           
 PersistenceDefinition getPersistenceDefinition()
           
<V extends T>
java.util.Iterator<V>
iterateAllEntitiesSpecifiedBy(Specification<V> specification)
           
 void load()
           
 void persist()
           
<V extends T>
void
put(V entity)
           
<V extends T>
java.lang.Boolean
remove(V entity)
           
<V extends T>
java.lang.Long
removeAllEntitiesSpecifiedBy(Specification<V> specification)
           
<V extends T>
void
update(V entity)
           
 
Methods inherited from class net.sourceforge.domian.repository.AbstractXStreamXmlFilePerEntityRepository
createRepositoryFilesIfNotExist, getEntityIdBasedFilenameFrom
 
Methods inherited from class net.sourceforge.domian.repository.AbstractXStreamXmlFileRepository
call, callConcurrently, callConcurrentlyInNewThread, callConcurrentlyWithRetry, callExclusively, callExclusivelyInNewThread, callExclusivelyWithRetry, getEncoding, getMaxNumberOfRetries, getRepositoryDirectory, getRepositoryId, getRepositoryPath, getRepositoryPathString, getRepositoryRootPath, getRetryTimeoutInMilliseconds, run, runAsynchronously, runConcurrently, setMaxNumberOfRetries, setRetryTimeoutInMilliseconds
 
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

DEFAULT_REPOSITORY_ROOT_DIR_NAME

protected static final java.lang.String DEFAULT_REPOSITORY_ROOT_DIR_NAME
See Also:
Constant Field Values

DEFAULT_REPOSITORY_ROOT_PATH

protected static final java.lang.String DEFAULT_REPOSITORY_ROOT_PATH
Constructor Detail

XStreamXmlFilePerEntityRepository

public XStreamXmlFilePerEntityRepository(java.lang.String repositoryId)

XStreamXmlFilePerEntityRepository

public XStreamXmlFilePerEntityRepository(java.lang.String repositoryId,
                                         Synchronizer synchronizer)

XStreamXmlFilePerEntityRepository

public XStreamXmlFilePerEntityRepository(java.lang.String repositoryRootPath,
                                         java.lang.String repositoryId)

XStreamXmlFilePerEntityRepository

public XStreamXmlFilePerEntityRepository(java.lang.String repositoryRootPath,
                                         java.lang.String repositoryId,
                                         Synchronizer synchronizer)
Method Detail

countAllEntities

public java.lang.Long countAllEntities()
Returns:
the total number of entities residing in this particular repository (partition)

iterateAllEntitiesSpecifiedBy

public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)

findAllEntitiesSpecifiedBy

public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)

put

public <V extends T> void put(V entity)

removeAllEntitiesSpecifiedBy

public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)

remove

public <V extends T> java.lang.Boolean remove(V entity)

getPersistenceDefinition

public PersistenceDefinition getPersistenceDefinition()

getFormat

public java.lang.String getFormat()

load

public void load()

persist

public void persist()

update

public <V extends T> void update(V entity)

getMetaDataFor

public EntityMetaData getMetaDataFor(T entity)

close

public void close()


Copyright © 2008-2010. All Rights Reserved.