Package org.nuxeo.ecm.core.storage.mem
Class MemRepository
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
-
- org.nuxeo.ecm.core.storage.mem.MemRepository
-
- All Implemented Interfaces:
LockManager
,Repository
,DBSRepository
public class MemRepository extends DBSRepositoryBase
In-memory implementation of aDBSRepository
.Internally, the repository is a map from id to document object.
A document object is a JSON-like document stored as a Map recursively containing the data, see
DBSDocument
for the description of the document.- Since:
- 5.9.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MemRepository.MemBlobFinder
-
Nested classes/interfaces inherited from class org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
DBSRepositoryBase.BlobFinder, DBSRepositoryBase.IdType
-
-
Field Summary
Fields Modifier and Type Field Description protected List<List<String>>
binaryPaths
protected static String
NOSCROLL_ID
protected Map<String,State>
states
The content of the repository, a map of document id -> object.-
Fields inherited from class org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
blobManager, changeTokenEnabled, DEBUG_UUIDS, fulltextConfiguration, idType, lockManager, repositoryName, selfRegisteredLockManager, TYPE_ROOT, UUID_ZERO, UUID_ZERO_DEBUG
-
-
Constructor Summary
Constructors Constructor Description MemRepository(MemRepositoryDescriptor descriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
generateNewId()
List<DBSRepositoryBase.IdType>
getAllowedIdTypes()
Gets the allowed id types for this DBS repository.MemConnection
getConnection()
Gets a new connection to this repository.Lock
getLock(String id)
Gets the lock on a document.protected void
initBlobsPaths()
protected void
initRepository()
void
markReferencedBinaries()
Marks the binaries in use by passing them to the binary manager(s)'s GC mark() method.protected void
markReferencedBinaries(State state, List<String> path, int start, DocumentBlobManager blobManager)
protected void
markReferencedBinary(Object value, DocumentBlobManager blobManager)
Lock
removeLock(String id, String owner)
Removes the lock from a document.Lock
setLock(String id, Lock lock)
Sets a lock on a document.void
shutdown()
boolean
supportsTransactions()
Checks whether this repository supports transactions.-
Methods inherited from class org.nuxeo.ecm.core.storage.dbs.DBSRepositoryBase
getBlobManager, getFulltextConfiguration, getIdType, getLockManager, getLockManagerName, getName, getSession, initLockManager, isChangeTokenEnabled, isFulltextDisabled, isFulltextSearchDisabled, isFulltextStoredInBlob
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager
-
Methods inherited from interface org.nuxeo.ecm.core.model.Repository
getActiveSessionsCount
-
-
-
-
Field Detail
-
NOSCROLL_ID
protected static final String NOSCROLL_ID
- See Also:
- Constant Field Values
-
states
protected Map<String,State> states
The content of the repository, a map of document id -> object.
-
binaryPaths
protected List<List<String>> binaryPaths
-
-
Constructor Detail
-
MemRepository
public MemRepository(MemRepositoryDescriptor descriptor)
-
-
Method Detail
-
getAllowedIdTypes
public List<DBSRepositoryBase.IdType> getAllowedIdTypes()
Description copied from class:DBSRepositoryBase
Gets the allowed id types for this DBS repository. The first one is the default.- Specified by:
getAllowedIdTypes
in classDBSRepositoryBase
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceRepository
- Overrides:
shutdown
in classDBSRepositoryBase
-
initRepository
protected void initRepository()
-
generateNewId
protected String generateNewId()
-
supportsTransactions
public boolean supportsTransactions()
Description copied from interface:DBSRepository
Checks whether this repository supports transactions.- Returns:
true
if the repository supports transactions- See Also:
DBSConnection.begin()
,DBSConnection.commit()
,DBSConnection.rollback()
-
getConnection
public MemConnection getConnection()
Description copied from interface:DBSRepository
Gets a new connection to this repository.- Returns:
- a new connection
-
getLock
public Lock getLock(String id)
Description copied from interface:LockManager
Gets the lock on a document.If the document does not exist,
null
is returned.- Specified by:
getLock
in interfaceLockManager
- Overrides:
getLock
in classDBSRepositoryBase
- Parameters:
id
- the document id- Returns:
- the existing lock, or
null
when there is no lock
-
setLock
public Lock setLock(String id, Lock lock)
Description copied from interface:LockManager
Sets a lock on a document.If the document is already locked, returns its existing lock status (there is no re-locking,
LockManager.removeLock(java.lang.String, java.lang.String)
must be called first).- Specified by:
setLock
in interfaceLockManager
- Overrides:
setLock
in classDBSRepositoryBase
- Parameters:
id
- the document idlock
- the lock to set- Returns:
null
if locking succeeded, or the existing lock if locking failed
-
removeLock
public Lock removeLock(String id, String owner)
Description copied from interface:LockManager
Removes the lock from a document.The previous lock is returned.
If
owner
isnull
then the lock is unconditionally removed.If
owner
is notnull
, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrue
forLock.getFailed()
.- Specified by:
removeLock
in interfaceLockManager
- Overrides:
removeLock
in classDBSRepositoryBase
- Parameters:
id
- the document idowner
- the owner to check, ornull
for no check- Returns:
- the previous lock (may be
null
), with a failed flag if locking failed
-
initBlobsPaths
protected void initBlobsPaths()
- Specified by:
initBlobsPaths
in classDBSRepositoryBase
-
markReferencedBinaries
public void markReferencedBinaries()
Description copied from interface:Repository
Marks the binaries in use by passing them to the binary manager(s)'s GC mark() method.
-
markReferencedBinaries
protected void markReferencedBinaries(State state, List<String> path, int start, DocumentBlobManager blobManager)
-
markReferencedBinary
protected void markReferencedBinary(Object value, DocumentBlobManager blobManager)
-
-