Search in sources :

Example 1 with ReadLock

use of org.qi4j.library.locking.ReadLock in project qi4j-sdk by Qi4j.

the class JdbmEntityStoreMixin method get.

@ReadLock
@Override
public Reader get(EntityReference entityReference) throws EntityStoreException {
    try {
        Long stateIndex = getStateIndex(entityReference.identity());
        if (stateIndex == null) {
            throw new EntityNotFoundException(entityReference);
        }
        byte[] serializedState = (byte[]) recordManager.fetch(stateIndex, serializer);
        if (serializedState == null) {
            throw new EntityNotFoundException(entityReference);
        }
        return new StringReader(new String(serializedState, "UTF-8"));
    } catch (IOException e) {
        throw new EntityStoreException(e);
    }
}
Also used : StringReader(java.io.StringReader) EntityNotFoundException(org.qi4j.spi.entitystore.EntityNotFoundException) IOException(java.io.IOException) EntityStoreException(org.qi4j.spi.entitystore.EntityStoreException) ReadLock(org.qi4j.library.locking.ReadLock)

Aggregations

IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ReadLock (org.qi4j.library.locking.ReadLock)1 EntityNotFoundException (org.qi4j.spi.entitystore.EntityNotFoundException)1 EntityStoreException (org.qi4j.spi.entitystore.EntityStoreException)1