2012-01-18 74 views
2

我想在嵌入模式下使用neo4j。正如我所看到的,不可能在不同的进程中共享GraphDatabase实例。现在我的想法是使用嵌入在OSGi容器中的neo4j为不同的组件共享相同的数据库。编写一个创建GraphDBBundleActivator是否是一个好主意,并将其公开给其他OSGi捆绑包并提供服务?嵌入OSGi的Neo4j

回答

2

An example template setup with tests从neo4j相关组件中创建超级捆绑。试着让我们知道它是如何发展的。请参阅here了解典型的Activator。

+0

试图构建示例失败:未能执行目标com.mycila.maven许可-插件:Maven的许可插件:1.9.0:在项目neo4j-osgi-examples上检查(检查许可证):某些文件没有预期的许可证标题 – 2013-02-07 22:16:43

1

现在你可以使用适当的DI来实例DB,像http://docs.neo4j.org/chunked/snapshot/tutorials-java-embedded-osgi.html

//the cache providers 
    ArrayList<CacheProvider> cacheList = new ArrayList<CacheProvider>(); 
    cacheList.add(new SoftCacheProvider()); 

    //the index providers 
    IndexProvider lucene = new LuceneIndexProvider(); 
    ArrayList<IndexProvider> provs = new ArrayList<IndexProvider>(); 
    provs.add(lucene); 
    ListIndexIterable providers = new ListIndexIterable(); 
    providers.setIndexProviders(provs); 

    //the database setup 
    GraphDatabaseFactory gdbf = new GraphDatabaseFactory(); 
    gdbf.setIndexProviders(providers); 
    gdbf.setCacheProviders(cacheList); 
    db = gdbf.newEmbeddedDatabase("target/db");