Package com.buschmais.xo.neo4j.api

Source Code of com.buschmais.xo.neo4j.api.GraphDbDatastoreFactory

package com.buschmais.xo.neo4j.api;

import com.buschmais.xo.api.XOException;
import com.buschmais.xo.neo4j.impl.datastore.GraphDbNeo4jDatastore;
import org.neo4j.graphdb.GraphDatabaseService;

import java.net.MalformedURLException;
import java.net.URI;
import java.util.Properties;

/**
* A {@link DatastoreFactory} re-using an existing instance of a {@link GraphDatabaseService} which must be specified as a property of the {@link com.buschmais.xo.api.bootstrap.XOUnit}.
*/
public class GraphDbDatastoreFactory implements DatastoreFactory<GraphDbNeo4jDatastore> {

    @Override
    public GraphDbNeo4jDatastore createGraphDatabaseService(URI uri, Properties properties) throws MalformedURLException {
        String graphDbPropertyName = GraphDatabaseService.class.getName();
        GraphDatabaseService graphDatabaseService = (GraphDatabaseService) properties.get(graphDbPropertyName);
        if (graphDatabaseService == null) {
            throw new XOException("Property " + graphDbPropertyName + " is not specified.");
        }
        return new GraphDbNeo4jDatastore(graphDatabaseService);
    }
}
TOP

Related Classes of com.buschmais.xo.neo4j.api.GraphDbDatastoreFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.