2012-01-18 41 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");