The object store is the central core of the in-memory repository. It is based on huge HashMap map mapping ids to objects in memory. To allow access from multiple threads a Java concurrent HashMap is used that allows parallel access methods.
Certain methods in the in-memory repository must guarantee constraints. For example a folder enforces that each child has a unique name. Therefore certain operations must occur in an atomic manner. In the example it must be guaranteed that no write access occurs to the map between acquiring the iterator to find the children and finishing the add operation when no name conflicts can occur. For this purpose this class has methods to lock an unlock the state of the repository. It is very important that the caller acquiring the lock enforces an unlock under all circumstances. Typical code is:
ObjectStoreImpl os = ... ; try { os.lock(); } finally { os.unlock(); }
The locking is very coarse-grained. Productive implementations would probably implement finer grained locks on a folder or document rather than the complete repository.