net.sourceforge.domian.repository
Class InMemoryAndXStreamXmlFileRepository<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.AbstractXStreamSingleXmlFileRepository<T>
                  extended by net.sourceforge.domian.repository.InMemoryAndXStreamXmlFileRepository<T>
All Implemented Interfaces:
HumanReadableFormatRepository<T>, PersistentRepository<T>, Repository<T>, TextualFormatRepository<T>

public class InMemoryAndXStreamXmlFileRepository<T extends Entity>
extends AbstractXStreamSingleXmlFileRepository<T>
implements HumanReadableFormatRepository<T>

An in-memory repository with persistence capabilities. The persistence part is backed by XStream functionality.

The only persistence definition supported by this repository is PersistenceDefinition.INMEMORY_AND_FILE. All entities in this repository are persisted into one single file. 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.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class net.sourceforge.domian.repository.AbstractXStreamSingleXmlFileRepository
AbstractXStreamSingleXmlFileRepository.Load, AbstractXStreamSingleXmlFileRepository.Persist, AbstractXStreamSingleXmlFileRepository.Type_Id_Date_CustomDenomination_NamedXStreamFilePersistenceStrategy
 
Field Summary
protected static java.lang.String DEFAULT_REPOSITORY_ROOT_DIR_NAME
           
protected static java.lang.String DEFAULT_REPOSITORY_ROOT_FILE_NAME
           
protected static java.lang.String DEFAULT_REPOSITORY_ROOT_PATH
           
protected  InMemoryRepository<T> inMemoryRepositoryDelegate
          The repository delegate dealing with the in-memory stuff.
 
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
InMemoryAndXStreamXmlFileRepository(java.lang.String repositoryId)
           
InMemoryAndXStreamXmlFileRepository(java.lang.String repositoryRootPath, java.lang.String repositoryId)
           
InMemoryAndXStreamXmlFileRepository(java.lang.String repositoryRootPath, java.lang.String repositoryId, Synchronizer synchronizer)
           
InMemoryAndXStreamXmlFileRepository(java.lang.String repositoryId, Synchronizer synchronizer)
           
 
Method Summary
 void close()
           
<V extends T>
java.util.Collection<V>
findAllEntitiesSpecifiedBy(Specification<V> specification)
           
 java.lang.String getFormat()
           
 PersistenceDefinition getPersistenceDefinition()
           
protected  java.lang.String getRepositoryTypeName()
           
<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.AbstractXStreamSingleXmlFileRepository
createRepositoryRootPathIfNotExist, getMetaDataFor, purgeRepositoryEntitiesFileOnly_IfExist, purgeRepositoryFilesIfExist, purgeRepositoryFilesIfExist
 
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.TextualFormatRepository
getEncoding
 
Methods inherited from interface net.sourceforge.domian.repository.PersistentRepository
getMetaDataFor, getRepositoryDirectory, getRepositoryId
 
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_FILE_NAME

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

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

inMemoryRepositoryDelegate

protected InMemoryRepository<T extends Entity> inMemoryRepositoryDelegate
The repository delegate dealing with the in-memory stuff.

Constructor Detail

InMemoryAndXStreamXmlFileRepository

public InMemoryAndXStreamXmlFileRepository(java.lang.String repositoryId)

InMemoryAndXStreamXmlFileRepository

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

InMemoryAndXStreamXmlFileRepository

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

InMemoryAndXStreamXmlFileRepository

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

getRepositoryTypeName

protected java.lang.String getRepositoryTypeName()
Specified by:
getRepositoryTypeName in class AbstractXStreamSingleXmlFileRepository<T extends Entity>
Returns:
the repository type name; the name of the repository implementation (e.g. Unix-name-variant of the class simple name)

iterateAllEntitiesSpecifiedBy

public <V extends T> java.util.Iterator<V> iterateAllEntitiesSpecifiedBy(Specification<V> specification)
Specified by:
iterateAllEntitiesSpecifiedBy in interface Repository<T extends Entity>

findAllEntitiesSpecifiedBy

public <V extends T> java.util.Collection<V> findAllEntitiesSpecifiedBy(Specification<V> specification)
Specified by:
findAllEntitiesSpecifiedBy in interface Repository<T extends Entity>

put

public <V extends T> void put(V entity)
Specified by:
put in interface Repository<T extends Entity>

update

public <V extends T> void update(V entity)
Specified by:
update in interface Repository<T extends Entity>

removeAllEntitiesSpecifiedBy

public <V extends T> java.lang.Long removeAllEntitiesSpecifiedBy(Specification<V> specification)
Specified by:
removeAllEntitiesSpecifiedBy in interface Repository<T extends Entity>

remove

public <V extends T> java.lang.Boolean remove(V entity)
Specified by:
remove in interface Repository<T extends Entity>

getPersistenceDefinition

public PersistenceDefinition getPersistenceDefinition()
Specified by:
getPersistenceDefinition in interface PersistentRepository<T extends Entity>

getFormat

public java.lang.String getFormat()
Specified by:
getFormat in interface PersistentRepository<T extends Entity>

load

public void load()
Specified by:
load in interface PersistentRepository<T extends Entity>

persist

public void persist()
Specified by:
persist in interface PersistentRepository<T extends Entity>

close

public void close()
Specified by:
close in interface PersistentRepository<T extends Entity>


Copyright © 2008-2010. All Rights Reserved.