> However, it seems the the ServiceLoader approach is not really compatible
> with OSGi, see
> http://jbossosgi.blogspot.com/2010/01/suns-serviceloader-and-how-it-relates.htmlfor
> details. Eelco, did you solve this problem in some nice way so I can
> adjust the tests?

I'm afraid not. I dropped in the newer version of Lucene, and that
fixed the problem for me, but I'm not doing anything in particular
with OSGi.

If it matters, I'm using Guice for dependency injection, and using
Blueprint to wrap around Neo4J:

import com.google.inject.AbstractModule;
import com.teachscape.commons.settings.Settings;
import com.teachscape.commons.util.Files;
import com.tinkerpop.blueprints.pgm.Graph;
import com.tinkerpop.blueprints.pgm.TransactionalGraph;
import com.tinkerpop.blueprints.pgm.impls.neo4j.Neo4jGraph;
import java.io.File;

public class Neo4JModule extends AbstractModule {

    private final Settings settings;

    public Neo4JModule(Settings settings) {
        this.settings = settings;
    }

    @Override
    protected void configure() {
        String graphdir = settings.getSetting("neo4jdb.dir");
        File f = new File(graphdir);
        if (!f.isDirectory()) {
            f.mkdirs();
        }

        boolean startClean =
settings.getBooleanSetting("graphdb.startClean", true);
        if (startClean) {
            Files.delete(f); // Neo4jGraph will mark as 'fresh' when
it detects dir doesn't exist
            if (f.exists()) {
                throw new IllegalArgumentException(
                        String.format("graphdb.startClean=true, but
can't delete directory %s", f.getAbsolutePath()));
            }
        }
        Neo4jGraph graph = new Neo4jGraph(graphdir);
        graph.setTransactionMode(TransactionalGraph.Mode.MANUAL);
        bind(Graph.class).toInstance(graph);
        bind(Neo4jGraph.class).toInstance(graph);
        bind(GraphShutdownHookInit.class).asEagerSingleton();
    }
}

Blueprints 0.7, Neo4J 1.4-SNAPSHOT, Lucene 3.2.0.

In my test code, Index<Vertex> index = ((IndexableGraph)
graph).getIndex(Index.VERTICES, Vertex.class); then works, whereas at
first it didn't because of problem with the older Lucene.

Cheers,

Eelco
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to