Usage

TwoStore, like any Akubra system, is easily configured with Spring. Below is an example of Spring XML configuration. Please notice the use of the BitStringMapper before all TwoStores and the way that our TwoStore instance multiplexes two other BlobStores. Those are the two key components of the TwoStore approach.

                 
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    <bean name="org.fcrepo.server.storage.lowlevel.ILowlevelStorage"
        class="org.fcrepo.server.storage.lowlevel.akubra.AkubraLowlevelStorage">
        <description>Low-level storage for a repository.</description>
        <constructor-arg>
            <description>The store of serialized Fedora objects</description>
            <ref bean="objectStore"/>
        </constructor-arg>
        <constructor-arg>
            <description>The store of datastream content</description>
            <ref bean="datastreamStore"/>
        </constructor-arg>
        <constructor-arg value="true">
            <description>if true, replaceObject calls will be done in a way that ensures the old content
                is not deleted until the new content is safely written. If the objectStore already does
                this, this should be given as false</description>
        </constructor-arg>
        <constructor-arg value="true">
            <description>save as above, but for datastreamStore</description>
        </constructor-arg>
    </bean>
    
    <bean name="objectStore" class="org.akubraproject.map.IdMappingBlobStore">
        <description>A mapping store to use for serialized objects.</description>
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:objectStore">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="fileMappingObjectStore"/>
            <description>The underlying BlobStore to which to map this IdMappingBlobStore.</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaStoreMapper"/>
            <description>The ID mapper to use. This one (declared below) maps URIs to hashed URIs for use with TwoStore.</description>
        </constructor-arg>
    </bean>
    
    <bean name="fileMappingObjectStore" class="org.akubraproject.map.IdMappingBlobStore">
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:objectStore">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="fsObjectStore"/>
            <description>The underlying BlobStore to which to map this IdMappingBlobStore. This one is a concrete FSBlobStore, declared below.</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaFilePrefixMapper"/>
            <description>The ID mapper to use. This one (declared below) simply adds or subtracts the prefix "file:".</description>
        </constructor-arg>
    </bean>
                     
    <!-- datastream storage -->
    
    <bean name="datastreamStore" class="org.akubraproject.map.IdMappingBlobStore">
        <description>A mapping store to use for datastreams.</description>
        <constructor-arg value="urn:fedora:datastreamStore">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaDatastreamStore1"/>
            <description>The underlying BlobStore to which to map this IdMappingBlobStore. This one is a TwoStore, declared below. That means that it will itself multiplex two other BlobStores.</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaStoreMapper"/>
            <description>The ID mapper to use. This one (declared below) maps URIs to hashed URIs for use with TwoStore.</description>                            
        </constructor-arg>
    </bean>
    
    <bean name="uvaDatastreamStore1" class="edu.virginia.lib.ole.akubra.TwoStore">
        <description>A multiplexing store to use for datastreams.</description>
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:uvaDatastreamStore1">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaDatastreamStore2"/>
            <description>The "left-hand" BlobStore being multiplexed. This one is a IdMapping store declared below.</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaDatastreamStore3"/>
            <description>The "right-hand" BlobStore being multiplexed. This one is a IdMapping store declared below.</description>                   
        </constructor-arg>
    </bean>
    
    <bean name="uvaDatastreamStore2" class="org.akubraproject.map.IdMappingBlobStore"><description>A mapping store to use for datastreams.</description>
        <description>A mapping store to use for datastreams.</description>
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:uvafsDatastreamStore2">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="fsDatastreamStore1"/>
            <description>The underlying BlobStore to which to map this IdMappingBlobStore. This one is a concrete FSBlobStore, declared below.</description> 
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaFilePrefixMapper"/>
            <description>The ID mapper to use. This one (declared below) simply adds or subtracts the prefix "file:".</description>                     
        </constructor-arg>
    </bean>
    
    <bean name="uvaDatastreamStore3" class="org.akubraproject.map.IdMappingBlobStore">
        <description>A mapping store to use for datastreams.</description>                      
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:uvafsDatastreamStore3">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="fsDatastreamStore2"/>
            <description>The underlying BlobStore to which to map this IdMappingBlobStore. This one is a concrete FSBlobStore, declared below.</description>
        </constructor-arg>
        <constructor-arg>
            <ref bean="uvaFilePrefixMapper"/>
            <description>The ID mapper to use. This one (declared below) simply adds or subtracts the prefix "file:".</description>                   
        </constructor-arg>
    </bean>
    
    <bean name="uvaStoreMapper" class="edu.virginia.lib.ole.akubra.BitStringMapper">
        <description>An IDMapper that takes URIs and maps to hashes that are returned as binary strings for use with TwoStore.</description>
    </bean>
    
    <bean name="uvaFilePrefixMapper" class="edu.virginia.lib.ole.akubra.FilePrefixMapper">
        <description>An IDMapper that simply adds or subtracts the prefix "file:" for use with FSBlobStores.</description>
    </bean>
    
    <bean name="fsObjectStore" class="org.akubraproject.fs.FSBlobStore">
        <description>A concrete FSBlobStore.</description>
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:fsObjectStore">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg value="/lib_content38/objectStore">
            <description>Filesystem location for storage.</description>
        </constructor-arg>
    </bean>
    
    <bean name="fsDatastreamStore1" class="org.akubraproject.fs.FSBlobStore">
        <description>A concrete FSBlobStore.</description>
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:fsDatastreamStore1">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg value="/lib_content38/dataStore">
            <description>Filesystem location for storage.</description>
        </constructor-arg>
    </bean>
    
    <bean name="fsDatastreamStore2" class="org.akubraproject.fs.FSBlobStore">
        <description>A concrete FSBlobStore.</description>
        <constructor-arg value="urn:akubra.ole.lib.virginia.edu:fsDatastreamStore2">
            <description>The URI by which to address this BlobStore</description>
        </constructor-arg>
        <constructor-arg value="/lib_content39/dataStore">
            <description>Filesystem location for storage.</description>
        </constructor-arg>
    </bean>
    
</beans>