All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.fortytwo.ripple.config.NativeStoreFactory Maven / Gradle / Ivy

There is a newer version: 1.5
Show newest version
package net.fortytwo.ripple.config;

import net.fortytwo.ripple.Ripple;
import net.fortytwo.ripple.RippleException;
import net.fortytwo.ripple.RippleProperties;
import net.fortytwo.ripple.URIMap;
import org.openrdf.sail.Sail;
import org.openrdf.sail.SailException;
import org.openrdf.sail.nativerdf.NativeStore;

import java.io.File;

/**
 * @author Joshua Shinavier (http://fortytwo.net)
 */
public class NativeStoreFactory implements SailFactory {
    @Override
    public Class getSailClass() {
        return NativeStore.class;
    }

    @Override
    public Sail createSail(URIMap uriMap, SailConfiguration config) throws RippleException {
        RippleProperties props = Ripple.getConfiguration();
        File dir = props.getFile(Ripple.NATIVESTORE_DIRECTORY);
        String indexes = props.getString(Ripple.NATIVESTORE_INDEXES, null);

        Sail sail = (null == indexes)
                ? new NativeStore(dir)
                : new NativeStore(dir, indexes.trim());
        try {
            sail.initialize();
        } catch (SailException e) {
            throw new RippleException(e);
        }

        return sail;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy